Krita Source Code Documentation
Loading...
Searching...
No Matches
KisPaintOpPresetsEditor Class Reference

#include <kis_paintop_presets_editor.h>

+ Inheritance diagram for KisPaintOpPresetsEditor:

Classes

struct  Private
 

Public Slots

void resourceSelected (KoResourceSP resource)
 
void slotCreateNewBrushPresetEngine ()
 
void slotRenameBrushActivated ()
 
void slotRenameBrushDeactivated ()
 
void slotSaveRenameCurrentBrush ()
 
void slotUpdatePresetSettings ()
 
void updateThemedIcons ()
 

Signals

void brushEditorShown ()
 
void createPresetFromScratch (const QString &paintOpName)
 
void defaultPresetClicked ()
 
void dirtyPresetToggled (bool value)
 
void eraserBrushOpacityToggled (bool value)
 
void eraserBrushSizeToggled (bool value)
 
void paintopActivated (const QString &presetName)
 
void reloadPresetClicked ()
 
void saveBrushPreset ()
 
void savePresetClicked ()
 
void signalResourceSelected (KoResourceSP resource)
 
void toggleDetachState (bool detach)
 

Public Member Functions

QString currentPaintOpId ()
 returns the internal ID for the paint op (brush engine)
 
void currentPresetChanged (KisPaintOpPresetSP preset)
 
QImage cutOutOverlay ()
 
 KisPaintOpPresetsEditor (KisCanvasResourceProvider *resourceProvider, KisFavoriteResourceManager *favoriteResourceManager, KisPresetSaveWidget *savePresetWidget, QWidget *parent=0)
 
void readOptionSetting (const KisPropertiesConfigurationSP setting)
 
void resizeEvent (QResizeEvent *) override
 
void setCreatingBrushFromScratch (bool enable)
 
void setCurrentPaintOpId (const QString &paintOpId)
 
void setPaintOpList (const QList< KisPaintOpFactory * > &list)
 
void setPaintOpSettingsWidget (QWidget *widget)
 
void updateViewSettings ()
 
void writeOptionSetting (KisPropertiesConfigurationSP setting) const
 
 ~KisPaintOpPresetsEditor () override
 

Public Attributes

KisPresetSaveWidget * saveDialog
 

Protected Member Functions

void contextMenuEvent (QContextMenuEvent *) override
 
void hideEvent (QHideEvent *) override
 
void showEvent (QShowEvent *) override
 

Private Slots

void slotBlackListCurrentPreset ()
 we do not delete brush presets, but blacklist them so they disappear from the interface
 
void slotSaveBrushPreset ()
 
void slotSaveNewBrushPreset ()
 
void slotSwitchScratchpad (bool visible)
 
void slotSwitchShowEditor (bool visible)
 
void slotSwitchShowPresets (bool visible)
 
void slotToggleDetach (bool detach)
 
void slotUpdateEffectiveLodAvailable (bool value)
 
void slotUpdatePaintOpFilter ()
 

Private Member Functions

void toggleBrushRenameUIActive (bool isRenaming)
 

Private Attributes

const int brushPresetsPanelInitWidth = 200
 
const int brushPresetsPanelMinWidth = 80
 
QString current_paintOpId
 
Private *const m_d
 
QList< QAction * > newBrushEngineOptions
 
QMenu * newPresetBrushEnginesMenu
 
const int scratchPadPanelInitWidth = 200
 
const int scratchPadPanelMinWidth = 80
 
QList< KisPaintOpInfo > sortedBrushEnginesList
 

Detailed Description

Popup widget for presets with built-in functionality for adding and removing presets.

Definition at line 30 of file kis_paintop_presets_editor.h.

Constructor & Destructor Documentation

◆ KisPaintOpPresetsEditor()

KisPaintOpPresetsEditor::KisPaintOpPresetsEditor ( KisCanvasResourceProvider * resourceProvider,
KisFavoriteResourceManager * favoriteResourceManager,
KisPresetSaveWidget * savePresetWidget,
QWidget * parent = 0 )

Definition at line 80 of file kis_paintop_presets_editor.cpp.

84 : QWidget(parent)
85 , m_d(new Private())
86{
87 setObjectName("KisPaintOpPresetsEditor");
88
89 KisConfig cfg(true);
90
92
93 m_d->resourceProvider = resourceProvider;
94 m_d->favoriteResManager = favoriteResourceManager;
95
96 m_d->uiWdgPaintOpPresetSettings.setupUi(this);
97
98 m_d->layout = new QGridLayout(m_d->uiWdgPaintOpPresetSettings.frmOptionWidgetContainer);
99
100 m_d->uiWdgPaintOpPresetSettings.scratchPad->setupScratchPad(resourceProvider, Qt::white);
101 m_d->uiWdgPaintOpPresetSettings.scratchPad->setCutoutOverlayRect(QRect(25, 25, 200, 200));
102
103 m_d->uiWdgPaintOpPresetSettings.dirtyPresetIndicatorButton->setToolTip(i18n("The settings for this preset have changed from their default."));
104
105 m_d->uiWdgPaintOpPresetSettings.showPresetsButton->setToolTip(i18n("Toggle showing presets"));
106
107 m_d->uiWdgPaintOpPresetSettings.showScratchpadButton->setToolTip(i18n("Toggle showing scratchpad"));
108
109 m_d->uiWdgPaintOpPresetSettings.reloadPresetButton->setToolTip(i18n("Reload the brush preset"));
110 m_d->uiWdgPaintOpPresetSettings.renameBrushPresetButton->setToolTip(i18n("Rename the brush preset"));
111
112
113 // creating a new preset from scratch. Part of the brush presets area
114 // the menu options will get filled up later when we are generating all available paintops
115 // in the filter drop-down
116 newPresetBrushEnginesMenu = new QMenu();
117
118 // overwrite existing preset and saving a new preset use the same dialog
119 saveDialog = savePresetWidget;
120 saveDialog->scratchPadSetup(resourceProvider);
121 saveDialog->setFavoriteResourceManager(m_d->favoriteResManager); // this is needed when saving the preset
122 saveDialog->hide();
123
124 // the area on the brush editor for renaming the brush. make sure edit fields are hidden by default
126
127 // Brush Preset Left Panel
128 {
129 // Container
130 QVBoxLayout* containerLayout = dynamic_cast<QVBoxLayout*>(m_d->uiWdgPaintOpPresetSettings.presetsContainer->layout());
131 containerLayout->setAlignment(Qt::AlignmentFlag::AlignTop); // spacers are not required
132
133 // Show Panel Button
134 m_d->uiWdgPaintOpPresetSettings.showPresetsButton->setCheckable(true);
135 m_d->uiWdgPaintOpPresetSettings.showPresetsButton->setChecked(cfg.presetStripVisible());
136
137 connect(m_d->uiWdgPaintOpPresetSettings.showPresetsButton, SIGNAL(clicked(bool)), this, SLOT(slotSwitchShowPresets(bool)));
138
139 // Brush Engine Filter
140 connect(m_d->uiWdgPaintOpPresetSettings.brushEngineComboBox, SIGNAL(currentIndexChanged(int)),
141 this, SLOT(slotUpdatePaintOpFilter()));
142
143 // Brush Presets
144 KisPresetChooser* presetChooser = m_d->uiWdgPaintOpPresetSettings.presetWidget;
145 presetChooser->showTaggingBar(true);
146
147 // Brush Presets ViewMode Menu
148 QMenu* viewModeMenu = new QMenu(this);
149 {
150 viewModeMenu->setStyleSheet("margin: 6px");
151
152 // View Modes Btns
153 viewModeMenu->addSection(i18nc("@title Which elements to display (e.g., thumbnails or details)", "Display"));
154 KisPresetChooser::ViewMode mode = (KisPresetChooser::ViewMode)cfg.presetChooserViewMode();
155 QActionGroup *actionGroup = new QActionGroup(this);
156
157 QAction* action = viewModeMenu->addAction(KisIconUtils::loadIcon("view-preview"), i18n("Thumbnails"));
158 action->setCheckable(true);
159 action->setChecked(mode == KisPresetChooser::THUMBNAIL);
160 action->setActionGroup(actionGroup);
161
162 connect(action, &QAction::triggered,
164
165 action = viewModeMenu->addAction(KisIconUtils::loadIcon("krita_tool_freehand"),i18n("Strokes"));
166 action->setCheckable(true);
167 action->setChecked(mode == KisPresetChooser::STROKE);
168 action->setActionGroup(actionGroup);
169
170 connect(action, &QAction::triggered,
172
173 action = viewModeMenu->addAction(KisIconUtils::loadIcon("krita_tool_freehand"),i18n("Thumbnails and Strokes"));
174 action->setCheckable(true);
175 action->setChecked(mode == KisPresetChooser::STROKE_THUMBNAIL);
176 action->setActionGroup(actionGroup);
177
178 connect(action, &QAction::triggered,
180
181 // Icon Size Slider
182 viewModeMenu->addSection(i18n("Icon Size"));
183
184 QSlider* iconSizeSlider = new QSlider(this);
185 iconSizeSlider->setOrientation(Qt::Horizontal);
186 iconSizeSlider->setRange(30, 80);
187 iconSizeSlider->setValue(m_d->uiWdgPaintOpPresetSettings.presetWidget->iconSize());
188 iconSizeSlider->setMinimumHeight(20);
189 iconSizeSlider->setMinimumWidth(40);
190 iconSizeSlider->setTickInterval(10);
191
192 connect(iconSizeSlider, &QSlider::valueChanged,
194
195 connect(iconSizeSlider, &QSlider::sliderReleased,
197
198 QWidgetAction *sliderAction= new QWidgetAction(this);
199 sliderAction->setDefaultWidget(iconSizeSlider);
200
201 viewModeMenu->addAction(sliderAction);
202 }
203
204 KisResourceItemChooser* resourceChooser = presetChooser->itemChooser();
205 resourceChooser->viewModeButton()->setPopupWidget(viewModeMenu);
206
207 // Bottom Bar Buttons
208 m_d->uiWdgPaintOpPresetSettings.newPresetEngineButton->setPopupMode(QToolButton::InstantPopup); // loading preset from scratch option
209 connect(m_d->uiWdgPaintOpPresetSettings.bnBlacklistPreset,SIGNAL(clicked()),
210 this, SLOT(slotBlackListCurrentPreset())); // TODO: add confirm dialog
211 }
212
213 // show/hide buttons
214 m_d->uiWdgPaintOpPresetSettings.showScratchpadButton->setCheckable(true);
215 m_d->uiWdgPaintOpPresetSettings.showScratchpadButton->setChecked(cfg.scratchpadVisible());
216
217 QMenu *viewOptionsMenu = new QMenu(this);
218 QAction *detachBrushEditorAction = viewOptionsMenu->addAction(i18n("Detach Brush Editor"));
219 detachBrushEditorAction->setCheckable(true);
220 detachBrushEditorAction->setChecked(cfg.paintopPopupDetached());
221 m_d->uiWdgPaintOpPresetSettings.viewOptionButton->setMenu(viewOptionsMenu);
222
223 // Connections
224 connect(m_d->uiWdgPaintOpPresetSettings.paintPresetIcon, SIGNAL(clicked()),
225 m_d->uiWdgPaintOpPresetSettings.scratchPad, SLOT(paintPresetImage()));
226
227 connect(saveDialog, SIGNAL(resourceSelected(KoResourceSP )), this, SLOT(resourceSelected(KoResourceSP )));
228
229 connect (m_d->uiWdgPaintOpPresetSettings.renameBrushPresetButton, SIGNAL(clicked(bool)),
230 this, SLOT(slotRenameBrushActivated()));
231
232 connect (m_d->uiWdgPaintOpPresetSettings.cancelBrushNameUpdateButton, SIGNAL(clicked(bool)),
233 this, SLOT(slotRenameBrushDeactivated()));
234
235 connect(m_d->uiWdgPaintOpPresetSettings.updateBrushNameButton, SIGNAL(clicked(bool)),
236 this, SLOT(slotSaveRenameCurrentBrush()));
237
238 connect(m_d->uiWdgPaintOpPresetSettings.renameBrushNameTextField, SIGNAL(returnPressed()),
240
241 connect(m_d->uiWdgPaintOpPresetSettings.showScratchpadButton, SIGNAL(clicked(bool)),
242 this, SLOT(slotSwitchScratchpad(bool)));
243
244 connect(detachBrushEditorAction, SIGNAL(toggled(bool)),
245 this, SLOT(slotToggleDetach(bool)));
246
247 connect(m_d->uiWdgPaintOpPresetSettings.eraseScratchPad, SIGNAL(clicked()),
248 m_d->uiWdgPaintOpPresetSettings.scratchPad, SLOT(fillDefault()));
249
250 connect(m_d->uiWdgPaintOpPresetSettings.fillLayer, SIGNAL(clicked()),
251 m_d->uiWdgPaintOpPresetSettings.scratchPad, SLOT(fillDocument()));
252
253 connect(m_d->uiWdgPaintOpPresetSettings.fillGradient, SIGNAL(clicked()),
254 m_d->uiWdgPaintOpPresetSettings.scratchPad, SLOT(fillGradient()));
255
256 connect(m_d->uiWdgPaintOpPresetSettings.fillSolid, SIGNAL(clicked()),
257 m_d->uiWdgPaintOpPresetSettings.scratchPad, SLOT(fillBackground()));
258
259
260 m_d->settingsWidget = 0;
261
262 connect(m_d->uiWdgPaintOpPresetSettings.saveBrushPresetButton, SIGNAL(clicked()),
263 this, SLOT(slotSaveBrushPreset()));
264
265 connect(m_d->uiWdgPaintOpPresetSettings.saveNewBrushPresetButton, SIGNAL(clicked()),
266 this, SLOT(slotSaveNewBrushPreset()));
267
268 connect(m_d->uiWdgPaintOpPresetSettings.reloadPresetButton, SIGNAL(clicked()),
269 this, SIGNAL(reloadPresetClicked()));
270
271 connect(m_d->uiWdgPaintOpPresetSettings.dirtyPresetCheckBox, SIGNAL(toggled(bool)),
272 this, SIGNAL(dirtyPresetToggled(bool)));
273
274 connect(m_d->uiWdgPaintOpPresetSettings.eraserBrushSizeCheckBox, SIGNAL(toggled(bool)),
275 this, SIGNAL(eraserBrushSizeToggled(bool)));
276
277 connect(m_d->uiWdgPaintOpPresetSettings.eraserBrushOpacityCheckBox, SIGNAL(toggled(bool)),
278 this, SIGNAL(eraserBrushOpacityToggled(bool)));
279
280
281 // preset widget connections
282 connect(m_d->uiWdgPaintOpPresetSettings.presetWidget, SIGNAL(resourceSelected(KoResourceSP )),
283 this, SIGNAL(signalResourceSelected(KoResourceSP )));
284
285 connect(m_d->uiWdgPaintOpPresetSettings.reloadPresetButton, SIGNAL(clicked()),
286 m_d->uiWdgPaintOpPresetSettings.presetWidget, SLOT(updateViewSettings()));
287
288 connect(m_d->uiWdgPaintOpPresetSettings.reloadPresetButton, SIGNAL(clicked()), SLOT(slotUpdatePresetSettings()));
289
290 m_d->ignoreHideEvents = false;
291
292 m_d->uiWdgPaintOpPresetSettings.dirtyPresetCheckBox->setChecked(cfg.useDirtyPresets());
293 m_d->uiWdgPaintOpPresetSettings.eraserBrushSizeCheckBox->setChecked(cfg.useEraserBrushSize());
294 m_d->uiWdgPaintOpPresetSettings.eraserBrushOpacityCheckBox->setChecked(cfg.useEraserBrushOpacity());
295
296 connect(m_d->uiWdgPaintOpPresetSettings.brushEngineComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdatePaintOpFilter()));
297 connect(m_d->uiWdgPaintOpPresetSettings.bnBlacklistPreset, SIGNAL(clicked()), this, SLOT(slotBlackListCurrentPreset()));
298
300
301 // setup things like the scene construct images, layers, etc that is a one-time thing
302 m_d->uiWdgPaintOpPresetSettings.liveBrushPreviewView->setup(resourceProvider->resourceManager());
303
304 // Register the live preview view with the cache for preview generation.
306 m_d->uiWdgPaintOpPresetSettings.liveBrushPreviewView);
307
308 // Responsive Layout
309 m_d->horzSplitter = new QSplitter(this); // you can't add QSplitter to a UI file
310 m_d->horzSplitter->setChildrenCollapsible(false);
311
312 m_d->horzSplitter->addWidget(m_d->uiWdgPaintOpPresetSettings.presetsContainer);
313 m_d->horzSplitter->setStretchFactor(0, 0);
314 m_d->horzSplitter->addWidget(m_d->uiWdgPaintOpPresetSettings.brushEditorSettingsControls);
315 m_d->horzSplitter->setStretchFactor(1, 2);
316 m_d->horzSplitter->addWidget(m_d->uiWdgPaintOpPresetSettings.scratchpadControls);
317 m_d->horzSplitter->setStretchFactor(2, 0);
318
319 m_d->uiWdgPaintOpPresetSettings.gridLayout->addWidget(m_d->horzSplitter, 3, 0, 1, 3);
320
321 // The side panels' sizeHints must be retrieved while they are visible.
322 // The center widget's sizeHint must be retrieved later.
323 m_d->defaultSplitterSizes << m_d->horzSplitter->widget(0)->sizeHint().width()
324 << m_d->horzSplitter->widget(1)->sizeHint().width()
325 << m_d->horzSplitter->widget(2)->sizeHint().width();
326
327 // Default Configuration
328 slotSwitchShowPresets(cfg.presetStripVisible());
329 slotSwitchScratchpad(cfg.scratchpadVisible());
330}
static KisBrushStrokePreviewCache * instance()
void registerLivePreviewView(KisPresetLivePreviewView *view)
Register live preview view for generating stroke previews.
KoCanvasResourceProvider * resourceManager()
void eraserBrushSizeToggled(bool value)
void resourceSelected(KoResourceSP resource)
void eraserBrushOpacityToggled(bool value)
void slotBlackListCurrentPreset()
we do not delete brush presets, but blacklist them so they disappear from the interface
void signalResourceSelected(KoResourceSP resource)
void toggleBrushRenameUIActive(bool isRenaming)
void dirtyPresetToggled(bool value)
void setPopupWidget(QWidget *widget)
@ STROKE_THUMBNAIL
Shows thumbnails.
@ STROKE
Shows stroke previews with text and thumbnail.
void saveIconSize()
saves the icon size for the presets. called by the horizontal slider release event.
void setIconSize(int newSize)
sets the icon size. Used by slider in view menu
void showTaggingBar(bool show)
Sets the visibility of tagging klineEdits.
KisResourceItemChooser * itemChooser()
void scratchPadSetup(KisCanvasResourceProvider *resourceProvider)
void setFavoriteResourceManager(KisFavoriteResourceManager *favManager)
QIcon loadIcon(const QString &name)
KisFavoriteResourceManager * favoriteResManager

References current_paintOpId, KisPaintOpPresetsEditor::Private::defaultSplitterSizes, dirtyPresetToggled(), eraserBrushOpacityToggled(), eraserBrushSizeToggled(), KisPaintOpPresetsEditor::Private::favoriteResManager, KisPaintOpPresetsEditor::Private::horzSplitter, KisPaintOpPresetsEditor::Private::ignoreHideEvents, KisBrushStrokePreviewCache::instance(), KisPresetChooser::itemChooser(), KisPaintOpPresetsEditor::Private::layout, KisIconUtils::loadIcon(), m_d, newPresetBrushEnginesMenu, KisConfig::paintopPopupDetached(), KisConfig::presetChooserViewMode(), KisConfig::presetStripVisible(), KisBrushStrokePreviewCache::registerLivePreviewView(), reloadPresetClicked(), KisCanvasResourceProvider::resourceManager(), KisPaintOpPresetsEditor::Private::resourceProvider, resourceSelected(), saveDialog, KisPresetChooser::saveIconSize(), KisPresetSaveWidget::scratchPadSetup(), KisConfig::scratchpadVisible(), KisPresetSaveWidget::setFavoriteResourceManager(), KisPresetChooser::setIconSize(), KisPopupButton::setPopupWidget(), KisPaintOpPresetsEditor::Private::settingsWidget, KisPresetChooser::setViewModeToStroke(), KisPresetChooser::setViewModeToStrokeThumbnail(), KisPresetChooser::setViewModeToThumbnail(), KisPresetChooser::showTaggingBar(), signalResourceSelected(), slotBlackListCurrentPreset(), slotRenameBrushActivated(), slotRenameBrushDeactivated(), slotSaveBrushPreset(), slotSaveNewBrushPreset(), slotSaveRenameCurrentBrush(), slotSwitchScratchpad(), slotSwitchShowPresets(), slotToggleDetach(), slotUpdatePaintOpFilter(), slotUpdatePresetSettings(), KisPresetChooser::STROKE, KisPresetChooser::STROKE_THUMBNAIL, KisPresetChooser::THUMBNAIL, toggleBrushRenameUIActive(), KisPaintOpPresetsEditor::Private::uiWdgPaintOpPresetSettings, updateThemedIcons(), updateViewSettings(), KisConfig::useDirtyPresets(), KisConfig::useEraserBrushOpacity(), KisConfig::useEraserBrushSize(), and KisResourceItemChooser::viewModeButton.

◆ ~KisPaintOpPresetsEditor()

KisPaintOpPresetsEditor::~KisPaintOpPresetsEditor ( )
override

Definition at line 423 of file kis_paintop_presets_editor.cpp.

424{
425 if (m_d->settingsWidget) {
426 m_d->layout->removeWidget(m_d->settingsWidget);
427 m_d->settingsWidget->hide();
428 m_d->settingsWidget->setParent(0);
429 m_d->settingsWidget = 0;
430 }
431 delete m_d;
433}

References KisPaintOpPresetsEditor::Private::layout, m_d, newPresetBrushEnginesMenu, and KisPaintOpPresetsEditor::Private::settingsWidget.

Member Function Documentation

◆ brushEditorShown

void KisPaintOpPresetsEditor::brushEditorShown ( )
signal

◆ contextMenuEvent()

void KisPaintOpPresetsEditor::contextMenuEvent ( QContextMenuEvent * e)
overrideprotected

Definition at line 497 of file kis_paintop_presets_editor.cpp.

498{
499 Q_UNUSED(e);
500}

◆ createPresetFromScratch

void KisPaintOpPresetsEditor::createPresetFromScratch ( const QString & paintOpName)
signal

◆ currentPaintOpId()

QString KisPaintOpPresetsEditor::currentPaintOpId ( )

returns the internal ID for the paint op (brush engine)

Definition at line 632 of file kis_paintop_presets_editor.cpp.

632 {
633 return current_paintOpId;
634}

References current_paintOpId.

◆ currentPresetChanged()

void KisPaintOpPresetsEditor::currentPresetChanged ( KisPaintOpPresetSP preset)

Definition at line 886 of file kis_paintop_presets_editor.cpp.

887{
888 if (preset) {
889 m_d->uiWdgPaintOpPresetSettings.presetWidget->setCurrentResource(preset);
890 setCurrentPaintOpId(preset->paintOp().id());
891 }
892}
void setCurrentPaintOpId(const QString &paintOpId)

References m_d, setCurrentPaintOpId(), and KisPaintOpPresetsEditor::Private::uiWdgPaintOpPresetSettings.

◆ cutOutOverlay()

QImage KisPaintOpPresetsEditor::cutOutOverlay ( )

Image for preset preview

Returns
image cut out from the scratchpad

Definition at line 492 of file kis_paintop_presets_editor.cpp.

493{
494 return m_d->uiWdgPaintOpPresetSettings.scratchPad->cutoutOverlay();
495}

References m_d, and KisPaintOpPresetsEditor::Private::uiWdgPaintOpPresetSettings.

◆ defaultPresetClicked

void KisPaintOpPresetsEditor::defaultPresetClicked ( )
signal

◆ dirtyPresetToggled

void KisPaintOpPresetsEditor::dirtyPresetToggled ( bool value)
signal

◆ eraserBrushOpacityToggled

void KisPaintOpPresetsEditor::eraserBrushOpacityToggled ( bool value)
signal

◆ eraserBrushSizeToggled

void KisPaintOpPresetsEditor::eraserBrushSizeToggled ( bool value)
signal

◆ hideEvent()

void KisPaintOpPresetsEditor::hideEvent ( QHideEvent * event)
overrideprotected

Definition at line 636 of file kis_paintop_presets_editor.cpp.

637{
638 if (m_d->ignoreHideEvents) {
639 return;
640 }
641
642 KisConfig cfg(false);
643
644 QList<int> splitterSizes = m_d->horzSplitter->sizes();
645 if (!cfg.presetStripVisible()) {
646 splitterSizes[0] = m_d->presetPanelWidth;
647 }
648
649 if (!cfg.scratchpadVisible()) {
650 splitterSizes[2] = m_d->scratchPanelWidth;
651 }
652
653 cfg.writeList<int>("brushEditorSplitterSizes", splitterSizes);
654
655 QWidget *frame = this->parentWidget();
656 cfg.writeEntry("brushEditorWindowGeometry", frame->saveGeometry());
657
658 QWidget::hideEvent(event);
659}

References KisPaintOpPresetsEditor::Private::horzSplitter, KisPaintOpPresetsEditor::Private::ignoreHideEvents, m_d, KisPaintOpPresetsEditor::Private::presetPanelWidth, KisConfig::presetStripVisible(), KisConfig::scratchpadVisible(), KisPaintOpPresetsEditor::Private::scratchPanelWidth, KisConfig::writeEntry(), and KisConfig::writeList().

◆ paintopActivated

void KisPaintOpPresetsEditor::paintopActivated ( const QString & presetName)
signal

◆ readOptionSetting()

void KisPaintOpPresetsEditor::readOptionSetting ( const KisPropertiesConfigurationSP setting)

◆ reloadPresetClicked

void KisPaintOpPresetsEditor::reloadPresetClicked ( )
signal

◆ resizeEvent()

void KisPaintOpPresetsEditor::resizeEvent ( QResizeEvent * event)
override

Definition at line 699 of file kis_paintop_presets_editor.cpp.

700{
701 QWidget::resizeEvent(event);
702 if (parentWidget()) {
703 // Make sure resizing doesn't push this widget out of the screen
704 QRect screenRect = this->screen()->availableGeometry();
705 QRect newPositionRect = kisEnsureInRect(parentWidget()->geometry(), screenRect);
706 parentWidget()->setGeometry(newPositionRect);
707 }
708}
QRect kisEnsureInRect(QRect rc, const QRect &bounds)
Definition kis_global.h:291

References kisEnsureInRect().

◆ resourceSelected

void KisPaintOpPresetsEditor::resourceSelected ( KoResourceSP resource)
slot

Definition at line 525 of file kis_paintop_presets_editor.cpp.

526{
527 // this gets called every time the brush editor window is opened
528 // TODO: this gets called multiple times whenever the preset is changed in the presets area
529 // the connections probably need to be thought about with this a bit more to keep things in sync
530
531 m_d->uiWdgPaintOpPresetSettings.presetWidget->setCurrentResource(resource);
532
533 // find the display name of the brush engine and append it to the selected preset display
534 QString currentBrushEngineName;
535 QPixmap currentBrushEngineIcon = QPixmap(26, 26);
536 currentBrushEngineIcon.fill(Qt::transparent);
537 for(int i=0; i < sortedBrushEnginesList.length(); i++) {
538 if (sortedBrushEnginesList.at(i).id == currentPaintOpId() ) {
539 currentBrushEngineName = sortedBrushEnginesList.at(i).name;
540 currentBrushEngineIcon = sortedBrushEnginesList.at(i).icon.pixmap(26, 26);
541 }
542 }
543
544 // brush names have underscores as part of the file name (to help with building). We don't really need underscores
545 // when viewing the names, so replace them with spaces
546 QString formattedBrushName = resource->name().replace("_", " ");
547
548 m_d->uiWdgPaintOpPresetSettings.currentBrushNameLabel->setToolTip(formattedBrushName);
549 formattedBrushName = this->fontMetrics().elidedText(formattedBrushName, Qt::ElideRight, m_d->uiWdgPaintOpPresetSettings.currentBrushNameLabel->width());
550 m_d->uiWdgPaintOpPresetSettings.currentBrushNameLabel->setText(formattedBrushName);
551 m_d->uiWdgPaintOpPresetSettings.currentBrushEngineLabel->setText(i18nc("%1 is the name of a brush engine", "%1 Engine", currentBrushEngineName));
552 m_d->uiWdgPaintOpPresetSettings.currentBrushEngineIcon->setPixmap(currentBrushEngineIcon);
553 m_d->uiWdgPaintOpPresetSettings.renameBrushNameTextField->setText(resource->name());
554
555 // get the preset image and pop it into the thumbnail area on the top of the brush editor
556 QSize thumbSize = QSize(55, 55)*devicePixelRatioF();
557 QImage thumbImage = resource->image();
558
559 m_d->uiWdgPaintOpPresetSettings.scratchPad->setPresetImage(thumbImage);
560
561 QPixmap thumbnail;
562 if (!thumbImage.isNull()) {
563 thumbnail = QPixmap::fromImage(thumbImage.scaled(thumbSize, Qt::KeepAspectRatio, Qt::SmoothTransformation));
564 } else {
565 thumbnail = QPixmap();
566 }
567
568 thumbnail.setDevicePixelRatio(devicePixelRatioF());
569 m_d->uiWdgPaintOpPresetSettings.presetThumbnailicon->setPixmap(thumbnail);
570
571 toggleBrushRenameUIActive(false); // reset the UI state of renaming a brush if we are changing brush presets
572 slotUpdatePresetSettings(); // check to see if the dirty preset icon needs to be shown
573}
QList< KisPaintOpInfo > sortedBrushEnginesList
QString currentPaintOpId()
returns the internal ID for the paint op (brush engine)

References currentPaintOpId(), m_d, slotUpdatePresetSettings(), sortedBrushEnginesList, toggleBrushRenameUIActive(), and KisPaintOpPresetsEditor::Private::uiWdgPaintOpPresetSettings.

◆ saveBrushPreset

void KisPaintOpPresetsEditor::saveBrushPreset ( )
signal

◆ savePresetClicked

void KisPaintOpPresetsEditor::savePresetClicked ( )
signal

◆ setCreatingBrushFromScratch()

void KisPaintOpPresetsEditor::setCreatingBrushFromScratch ( bool enable)

◆ setCurrentPaintOpId()

void KisPaintOpPresetsEditor::setCurrentPaintOpId ( const QString & paintOpId)

Definition at line 626 of file kis_paintop_presets_editor.cpp.

627{
628 current_paintOpId = paintOpId;
629}

References current_paintOpId.

◆ setPaintOpList()

void KisPaintOpPresetsEditor::setPaintOpList ( const QList< KisPaintOpFactory * > & list)

Definition at line 580 of file kis_paintop_presets_editor.cpp.

581{
582 m_d->uiWdgPaintOpPresetSettings.brushEngineComboBox->clear(); // reset combobox list just in case
583
584
585 // create a new list so we can sort it and populate the brush engine combo box
586 sortedBrushEnginesList.clear(); // just in case this function is called again, don't keep adding to the list
587
588 for(int i=0; i < list.length(); i++) {
589 KisPaintOpInfo paintOpInfo;
590 paintOpInfo.id = list.at(i)->id();
591 paintOpInfo.name = list.at(i)->name();
592 paintOpInfo.icon = list.at(i)->icon();
593 paintOpInfo.priority = list.at(i)->priority();
594
595 sortedBrushEnginesList.append(paintOpInfo);
596 }
597
598 std::stable_sort(sortedBrushEnginesList.begin(), sortedBrushEnginesList.end(), variantLessThan );
599
600 // add an "All" option at the front to show all presets
601 QPixmap emptyPixmap = QPixmap(22,22);
602 emptyPixmap.fill(Qt::transparent);
603
604 // if we create a new brush from scratch, we need a full list of paintops to choose from
605 // we don't want "All", so populate the list before that is added
606 newPresetBrushEnginesMenu->actions().clear(); // clean out list in case we run this again
607 newBrushEngineOptions.clear();
608
609 for (int j = 0; j < sortedBrushEnginesList.length(); j++) {
610 auto * newEngineAction = newPresetBrushEnginesMenu->addAction(sortedBrushEnginesList[j].name);
611 newEngineAction->setObjectName(sortedBrushEnginesList[j].id); // we need the ID for changing the paintop when action triggered
612 newEngineAction->setIcon(sortedBrushEnginesList[j].icon);
613 newBrushEngineOptions.append(newEngineAction);
614 connect(newEngineAction, SIGNAL(triggered()), this, SLOT(slotCreateNewBrushPresetEngine()));
615 }
616 m_d->uiWdgPaintOpPresetSettings.newPresetEngineButton->setMenu(newPresetBrushEnginesMenu);
617
618 // fill the list into the brush combo box
619 sortedBrushEnginesList.push_front(KisPaintOpInfo(QString("all_options"), i18n("All"), QString(""), QIcon(emptyPixmap), 0 ));
620 for (int m = 0; m < sortedBrushEnginesList.length(); m++) {
621 m_d->uiWdgPaintOpPresetSettings.brushEngineComboBox->addItem(sortedBrushEnginesList[m].icon, sortedBrushEnginesList[m].name, QVariant(sortedBrushEnginesList[m].id));
622 }
623}
bool variantLessThan(const KisPaintOpInfo v1, const KisPaintOpInfo v2)

References KisPaintOpInfo::icon, KisPaintOpInfo::id, m_d, KisPaintOpInfo::name, newBrushEngineOptions, newPresetBrushEnginesMenu, KisPaintOpInfo::priority, slotCreateNewBrushPresetEngine(), sortedBrushEnginesList, KisPaintOpPresetsEditor::Private::uiWdgPaintOpPresetSettings, and variantLessThan().

◆ setPaintOpSettingsWidget()

void KisPaintOpPresetsEditor::setPaintOpSettingsWidget ( QWidget * widget)

Definition at line 435 of file kis_paintop_presets_editor.cpp.

436{
437 if (m_d->settingsWidget) {
438 m_d->layout->removeWidget(m_d->settingsWidget);
439 m_d->uiWdgPaintOpPresetSettings.frmOptionWidgetContainer->updateGeometry();
440 }
441 m_d->layout->update();
442 updateGeometry();
443
445 m_d->settingsWidget = 0;
446
447 if (widget) {
448
449 m_d->settingsWidget = dynamic_cast<KisPaintOpConfigWidget*>(widget);
451
452 KisConfig cfg(true);
453 if (m_d->settingsWidget->supportScratchBox() && cfg.scratchpadVisible()) {
455 } else {
457 }
458
459 slotSwitchShowPresets(cfg.presetStripVisible());
460
465 m_d->uiWdgPaintOpPresetSettings.wdgLodAvailability->setLodAvailabilityModel(model);
466
467 widget->setFont(m_d->smallFont);
468
469 m_d->layout->addWidget(widget);
470
471 // hook up connections that will monitor if our preset is dirty or not. Show a notification if it is
473
475 m_d->widgetConnections.addConnection(preset->updateProxy(), SIGNAL(sigSettingsChanged()),
476 this, SLOT(slotUpdatePresetSettings()));
477 }
478
479 m_d->widgetConnections.addConnection(model, SIGNAL(effectiveLodAvailableChanged(bool)),
480 this, SLOT(slotUpdateEffectiveLodAvailable(bool)));
481 slotUpdateEffectiveLodAvailable(model->effectiveLodAvailable());
482
483 m_d->widgetConnections.addConnection(model, SIGNAL(sigConfigurationItemChanged()),
484 widget, SIGNAL(sigConfigurationItemChanged()));
485
486 m_d->layout->update();
487 widget->show();
488
489 }
490}
KisPaintOpPresetSP currentPreset() const
virtual lager::reader< qreal > effectiveBrushSize() const =0
virtual lager::reader< KisPaintopLodLimitations > lodLimitationsReader() const =0
void addConnection(Sender sender, Signal signal, Receiver receiver, Method method, Qt::ConnectionType type=Qt::AutoConnection)
#define KIS_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:75
KisSignalAutoConnectionsStore widgetConnections

References KisSignalAutoConnectionsStore::addConnection(), KisSignalAutoConnectionsStore::clear(), KisCanvasResourceProvider::currentPreset(), KisPaintOpConfigWidget::effectiveBrushSize(), KIS_ASSERT_RECOVER_RETURN, KisPaintOpPresetsEditor::Private::layout, KisPaintOpPresetsEditor::Private::lodAvailabilityData, KisPaintOpConfigWidget::lodLimitationsReader(), m_d, KisConfig::presetStripVisible(), KisPaintOpPresetsEditor::Private::resourceProvider, KisConfig::scratchpadVisible(), KisPaintOpPresetsEditor::Private::settingsWidget, slotSwitchScratchpad(), slotSwitchShowPresets(), slotUpdateEffectiveLodAvailable(), slotUpdatePresetSettings(), KisPaintOpPresetsEditor::Private::smallFont, KisPaintOpConfigWidget::supportScratchBox(), KisPaintOpPresetsEditor::Private::uiWdgPaintOpPresetSettings, and KisPaintOpPresetsEditor::Private::widgetConnections.

◆ showEvent()

void KisPaintOpPresetsEditor::showEvent ( QShowEvent * )
overrideprotected

Definition at line 661 of file kis_paintop_presets_editor.cpp.

662{
663 KisConfig cfg(false);
664
665 // The center widget's size will be cut off if not re-retrieved.
666 m_d->defaultSplitterSizes[1] = m_d->horzSplitter->widget(1)->sizeHint().width();
667 QList<int> splitterSizes = cfg.readList<int>("brushEditorSplitterSizes", m_d->defaultSplitterSizes);
668
669 m_d->presetPanelWidth = splitterSizes[0];
670 m_d->scratchPanelWidth = splitterSizes[2];
671
672 if (!cfg.presetStripVisible()) {
673 splitterSizes[0] = 0;
674 }
675 if (!cfg.scratchpadVisible()) {
676 splitterSizes[2] = 0;
677 }
678
679 QWidget *frame = this->parentWidget();
680 QByteArray frameGeometry = cfg.readEntry("brushEditorWindowGeometry", QByteArray());
681 if (!frameGeometry.isEmpty()) {
682 frame->restoreGeometry(frameGeometry);
683 }
684 else {
685 int presetPanelWidth = splitterSizes[0] != 0 ? splitterSizes[0] : m_d->uiWdgPaintOpPresetSettings.showPresetsButton->width();
686 int scratchPanelWidth =
687 splitterSizes[2] != 0 ? splitterSizes[2] : m_d->uiWdgPaintOpPresetSettings.showScratchpadButton->width();
688 const QMargins margins = m_d->layout->contentsMargins();
689 int width = presetPanelWidth + splitterSizes[1] + scratchPanelWidth +
690 margins.bottom() + margins.left() + margins.top() + margins.right();
691 QRect defaultGeometry = QRect(frame->geometry().x(), frame->geometry().y(), width, frame->geometry().height());
692 frame->setGeometry(defaultGeometry);
693 }
694 m_d->horzSplitter->setSizes(splitterSizes);
695
696 Q_EMIT brushEditorShown();
697}

References brushEditorShown(), KisPaintOpPresetsEditor::Private::defaultSplitterSizes, KisPaintOpPresetsEditor::Private::horzSplitter, KisPaintOpPresetsEditor::Private::layout, m_d, KisPaintOpPresetsEditor::Private::presetPanelWidth, KisConfig::presetStripVisible(), KisConfig::readEntry(), KisConfig::readList(), KisConfig::scratchpadVisible(), KisPaintOpPresetsEditor::Private::scratchPanelWidth, and KisPaintOpPresetsEditor::Private::uiWdgPaintOpPresetSettings.

◆ signalResourceSelected

void KisPaintOpPresetsEditor::signalResourceSelected ( KoResourceSP resource)
signal

◆ slotBlackListCurrentPreset

void KisPaintOpPresetsEditor::slotBlackListCurrentPreset ( )
privateslot

we do not delete brush presets, but blacklist them so they disappear from the interface

Definition at line 332 of file kis_paintop_presets_editor.cpp.

333{
336 rServer->removeResourceFromServer(curPreset);
337}
static KisResourceServerProvider * instance()
KisPaintOpPresetResourceServer * paintOpPresetServer()
bool removeResourceFromServer(QSharedPointer< T > resource)
Remove a resource from Resource Server but not from a file.

References KisCanvasResourceProvider::currentPreset(), KisResourceServerProvider::instance(), m_d, KisResourceServerProvider::paintOpPresetServer(), KoResourceServer< T >::removeResourceFromServer(), and KisPaintOpPresetsEditor::Private::resourceProvider.

◆ slotCreateNewBrushPresetEngine

void KisPaintOpPresetsEditor::slotCreateNewBrushPresetEngine ( )
slot

Definition at line 876 of file kis_paintop_presets_editor.cpp.

877{
878 Q_EMIT createPresetFromScratch(sender()->objectName());
879}
void createPresetFromScratch(const QString &paintOpName)

References createPresetFromScratch().

◆ slotRenameBrushActivated

void KisPaintOpPresetsEditor::slotRenameBrushActivated ( )
slot

Definition at line 339 of file kis_paintop_presets_editor.cpp.

340{
342}

References toggleBrushRenameUIActive().

◆ slotRenameBrushDeactivated

void KisPaintOpPresetsEditor::slotRenameBrushDeactivated ( )
slot

Definition at line 344 of file kis_paintop_presets_editor.cpp.

345{
347}

References toggleBrushRenameUIActive().

◆ slotSaveBrushPreset

void KisPaintOpPresetsEditor::slotSaveBrushPreset ( )
privateslot

Definition at line 838 of file kis_paintop_presets_editor.cpp.

838 {
839 // here we are assuming that people want to keep their existing preset icon. We will just update the
840 // settings and save a new copy with the same name.
841 // there is a dialog with save options, but we don't need to show it in this situation
842
843 saveDialog->useNewBrushDialog(false); // this mostly just makes sure we keep the existing brush preset name when saving
844 const QImage thumbImage = m_d->resourceProvider->currentPreset() ? m_d->resourceProvider->currentPreset()->image() : QImage();
845 saveDialog->brushPresetThumbnailWidget->setPresetImage(thumbImage);
847 saveDialog->loadExistingThumbnail(); // This makes sure we use the existing preset icon when updating the existing brush preset
849
850 // refresh the view settings so the brush doesn't appear dirty
851 // tiar 2021: I'm not sure if it's needed anymore; seems to work without it...
853}
void saveScratchPadThumbnailArea(const QImage image)
void useNewBrushDialog(bool show)
determines if we should show the save as dialog (true) or save in the background (false)

References KisCanvasResourceProvider::currentPreset(), KisPresetSaveWidget::loadExistingThumbnail(), m_d, KisPaintOpPresetsEditor::Private::resourceProvider, saveDialog, KisPresetSaveWidget::saveScratchPadThumbnailArea(), KisPresetSaveWidget::showDialog(), slotUpdatePresetSettings(), KisPaintOpPresetsEditor::Private::uiWdgPaintOpPresetSettings, and KisPresetSaveWidget::useNewBrushDialog().

◆ slotSaveNewBrushPreset

◆ slotSaveRenameCurrentBrush

void KisPaintOpPresetsEditor::slotSaveRenameCurrentBrush ( )
slot

Definition at line 376 of file kis_paintop_presets_editor.cpp.

377{
378 // if you are renaming a brush, that is different than updating the settings
379 // make sure we are in a clean state before renaming. This logic might change,
380 // but that is what we are going with for now
381 KisPaintOpSettingsSP prevSettings = m_d->resourceProvider->currentPreset()->settings()->clone();
382 bool isDirty = m_d->resourceProvider->currentPreset()->isDirty();
383
384 // this returns the UI to its original state after saving
386 slotUpdatePresetSettings(); // update visibility of dirty preset and icon
387
388 // get a reference to the existing (and new) file name and path that we are working with
390 // in case the preset is dirty, we need an id to get the actual non-dirty preset to save just the name change
391 // into the database
392 int currentPresetResourceId = curPreset->resourceId();
393
394 QString renamedPresetName = m_d->uiWdgPaintOpPresetSettings.renameBrushNameTextField->text();
395
396 // If the id < 0, this is a new preset that hasn't been added to the storage and the database yet.
397 if (currentPresetResourceId < 0) {
398 curPreset->setName(renamedPresetName);
399 slotUpdatePresetSettings(); // update visibility of dirty preset and icon
400 return;
401 }
402
403 Q_EMIT reloadPresetClicked();
404
405 // create a new brush preset with the name specified and add to resource provider
407 KoResourceSP properCleanResource = model.resourceForId(currentPresetResourceId);
408 const bool success = KisResourceUserOperations::renameResourceWithUserInput(this, properCleanResource, renamedPresetName);
409
410 if (isDirty) {
411 properCleanResource.dynamicCast<KisPaintOpPreset>()->setSettings(prevSettings);
412 properCleanResource.dynamicCast<KisPaintOpPreset>()->setDirty(isDirty);
413 }
414
415 // refresh and select our freshly renamed resource
416 if (success) resourceSelected(properCleanResource);
417
419
420 slotUpdatePresetSettings(); // update visibility of dirty preset and icon
421}
The KisResourceModel class provides the main access to resources. It is possible to filter the resour...
static bool renameResourceWithUserInput(QWidget *widgetParent, KoResourceSP resource, QString resourceName)
const QString PaintOpPresets

References KisCanvasResourceProvider::currentPreset(), KisPaintOpPresetsEditor::Private::favoriteResManager, m_d, ResourceType::PaintOpPresets, reloadPresetClicked(), KisResourceUserOperations::renameResourceWithUserInput(), KisResourceModel::resourceForId(), KisPaintOpPresetsEditor::Private::resourceProvider, resourceSelected(), slotUpdatePresetSettings(), toggleBrushRenameUIActive(), KisPaintOpPresetsEditor::Private::uiWdgPaintOpPresetSettings, and KisFavoriteResourceManager::updateFavoritePresets().

◆ slotSwitchScratchpad

void KisPaintOpPresetsEditor::slotSwitchScratchpad ( bool visible)
privateslot

Definition at line 710 of file kis_paintop_presets_editor.cpp.

711{
712 bool sameVisibility = m_d->uiWdgPaintOpPresetSettings.scratchPad->isVisible() == visible;
713
714 // hide all the internal controls except the toggle button
715 m_d->uiWdgPaintOpPresetSettings.scratchPad->setVisible(visible);
716 m_d->uiWdgPaintOpPresetSettings.paintPresetIcon->setVisible(visible);
717 m_d->uiWdgPaintOpPresetSettings.fillGradient->setVisible(visible);
718 m_d->uiWdgPaintOpPresetSettings.fillLayer->setVisible(visible);
719 m_d->uiWdgPaintOpPresetSettings.fillSolid->setVisible(visible);
720 m_d->uiWdgPaintOpPresetSettings.eraseScratchPad->setVisible(visible);
721 m_d->uiWdgPaintOpPresetSettings.scratchpadSidebarLabel->setVisible(visible);
722
723 if (sameVisibility) {
724 return;
725 }
726
727 QPushButton* showBtn = m_d->uiWdgPaintOpPresetSettings.showScratchpadButton;
728 QGroupBox *container = m_d->uiWdgPaintOpPresetSettings.scratchpadControls;
729
730 const QMargins margins = m_d->layout->contentsMargins();
731 int emptyContainerWidth = showBtn->width() + margins.left() + margins.right();
732
733 if (visible) {
734 showBtn->setIcon(KisIconUtils::loadIcon("arrow-left"));
735
736 container->setMinimumWidth(scratchPadPanelMinWidth);
737 container->setMaximumWidth(0xFF'FFFF);
738
739 QList<int> splitterSizes = m_d->horzSplitter->sizes();
741 QWidget *frame = this->parentWidget();
742 QRect currentGeometry = frame->geometry();
743 currentGeometry.setRight(currentGeometry.right() + (splitterSizes[2] - emptyContainerWidth));
744 frame->setGeometry(currentGeometry);
745 m_d->horzSplitter->setSizes(splitterSizes);
746 } else {
747 showBtn->setIcon(KisIconUtils::loadIcon("arrow-right"));
748
749 container->setMinimumWidth(emptyContainerWidth);
750 container->setMaximumWidth(emptyContainerWidth);
751
752 QList<int> splitterSizes = m_d->horzSplitter->sizes();
754 QWidget *frame = this->parentWidget();
755 QRect currentGeometry = frame->geometry();
756 currentGeometry.setRight(currentGeometry.right() - (m_d->scratchPanelWidth - emptyContainerWidth));
757 frame->setGeometry(currentGeometry);
758
759 splitterSizes[1] = 0xFF'FFFF;
760 splitterSizes[2] = emptyContainerWidth;
761 m_d->horzSplitter->setSizes(splitterSizes);
762 }
763
764 KisConfig cfg(false);
765 cfg.setScratchpadVisible(visible);
766}

References KisPaintOpPresetsEditor::Private::horzSplitter, KisPaintOpPresetsEditor::Private::layout, KisIconUtils::loadIcon(), m_d, scratchPadPanelInitWidth, scratchPadPanelMinWidth, KisPaintOpPresetsEditor::Private::scratchPanelWidth, KisConfig::setScratchpadVisible(), and KisPaintOpPresetsEditor::Private::uiWdgPaintOpPresetSettings.

◆ slotSwitchShowEditor

void KisPaintOpPresetsEditor::slotSwitchShowEditor ( bool visible)
privateslot

Definition at line 768 of file kis_paintop_presets_editor.cpp.

768 {
769 m_d->uiWdgPaintOpPresetSettings.brushEditorSettingsControls->setVisible(visible);
770}

References m_d, and KisPaintOpPresetsEditor::Private::uiWdgPaintOpPresetSettings.

◆ slotSwitchShowPresets

void KisPaintOpPresetsEditor::slotSwitchShowPresets ( bool visible)
privateslot

Definition at line 772 of file kis_paintop_presets_editor.cpp.

773{
774 bool sameVisibility = m_d->uiWdgPaintOpPresetSettings.presetsSidebarLabel->isVisible() == visible;
775
776 m_d->uiWdgPaintOpPresetSettings.presetsSidebarLabel->setVisible(visible);
777 m_d->uiWdgPaintOpPresetSettings.engineFilterLabel->setVisible(visible);
778 m_d->uiWdgPaintOpPresetSettings.brushEngineComboBox->setVisible(visible);
779 m_d->uiWdgPaintOpPresetSettings.presetWidget->setVisible(visible);
780 m_d->uiWdgPaintOpPresetSettings.newPresetEngineButton->setVisible(visible);
781 m_d->uiWdgPaintOpPresetSettings.bnBlacklistPreset->setVisible(visible);
782
783 if (sameVisibility) {
784 return;
785 }
786
787 QPushButton* showBtn = m_d->uiWdgPaintOpPresetSettings.showPresetsButton;
788 QGroupBox *container = m_d->uiWdgPaintOpPresetSettings.presetsContainer;
789
790 const QMargins margins = m_d->layout->contentsMargins();
791 int emptyContainerWidth = showBtn->width() + margins.left() + margins.right();
792
793 if (visible) {
794 showBtn->setIcon(KisIconUtils::loadIcon("arrow-right"));
795
796 container->setMinimumWidth(brushPresetsPanelMinWidth);
797 container->setMaximumWidth(0xFF'FFFF);
798
799 QList<int> splitterSizes = m_d->horzSplitter->sizes();
800 splitterSizes[0] = m_d->presetPanelWidth;
801 QWidget *frame = this->parentWidget();
802 QRect currentGeometry = frame->geometry();
803 currentGeometry.setLeft(currentGeometry.left() - (splitterSizes[0] - emptyContainerWidth));
804 frame->setGeometry(currentGeometry);
805 m_d->horzSplitter->setSizes(splitterSizes);
806 } else {
807 showBtn->setIcon(KisIconUtils::loadIcon("arrow-left"));
808
809 container->setMinimumWidth(emptyContainerWidth);
810 container->setMaximumWidth(emptyContainerWidth);
811
812 QList<int> splitterSizes = m_d->horzSplitter->sizes();
814 QWidget *frame = this->parentWidget();
815 QRect currentGeometry = frame->geometry();
816 currentGeometry.setLeft(currentGeometry.left() + (m_d->presetPanelWidth - emptyContainerWidth));
817 frame->setGeometry(currentGeometry);
818
819 splitterSizes[0] = emptyContainerWidth;
820 splitterSizes[1] = 0xFF'FFFF;
821 m_d->horzSplitter->setSizes(splitterSizes);
822 }
823
824 KisConfig cfg(false);
825 cfg.setPresetStripVisible(visible);
826}

References brushPresetsPanelInitWidth, brushPresetsPanelMinWidth, KisPaintOpPresetsEditor::Private::horzSplitter, KisPaintOpPresetsEditor::Private::layout, KisIconUtils::loadIcon(), m_d, KisPaintOpPresetsEditor::Private::presetPanelWidth, KisConfig::setPresetStripVisible(), and KisPaintOpPresetsEditor::Private::uiWdgPaintOpPresetSettings.

◆ slotToggleDetach

void KisPaintOpPresetsEditor::slotToggleDetach ( bool detach)
privateslot

Definition at line 863 of file kis_paintop_presets_editor.cpp.

864{
865 Q_EMIT toggleDetachState(detach);
866 KisConfig cfg(false);
867 cfg.setPaintopPopupDetached(detach);
868}
void toggleDetachState(bool detach)

References KisConfig::setPaintopPopupDetached(), and toggleDetachState().

◆ slotUpdateEffectiveLodAvailable

void KisPaintOpPresetsEditor::slotUpdateEffectiveLodAvailable ( bool value)
privateslot

◆ slotUpdatePaintOpFilter

void KisPaintOpPresetsEditor::slotUpdatePaintOpFilter ( )
privateslot

Definition at line 828 of file kis_paintop_presets_editor.cpp.

828 {
829 QVariant userData = m_d->uiWdgPaintOpPresetSettings.brushEngineComboBox->currentData(); // grab paintOpID from data
830 QString filterPaintOpId = userData.toString();
831
832 if (filterPaintOpId == "all_options") {
833 filterPaintOpId = "";
834 }
835 m_d->uiWdgPaintOpPresetSettings.presetWidget->setPresetFilter(filterPaintOpId);
836}

References m_d, and KisPaintOpPresetsEditor::Private::uiWdgPaintOpPresetSettings.

◆ slotUpdatePresetSettings

void KisPaintOpPresetsEditor::slotUpdatePresetSettings ( )
slot

Definition at line 933 of file kis_paintop_presets_editor.cpp.

934{
935 if (!m_d->resourceProvider) {
936 return;
937 }
938
940 return;
941 }
942
943 // hide options on UI if we are creating a brush preset from scratch to prevent confusion
945 m_d->uiWdgPaintOpPresetSettings.dirtyPresetIndicatorButton->setVisible(false);
946 m_d->uiWdgPaintOpPresetSettings.brokenPresetIndicatorButton->setVisible(false);
947 m_d->uiWdgPaintOpPresetSettings.reloadPresetButton->setVisible(false);
948 m_d->uiWdgPaintOpPresetSettings.saveBrushPresetButton->setVisible(false);
949 m_d->uiWdgPaintOpPresetSettings.renameBrushPresetButton->setVisible(false);
950 } else {
951 const bool isPresetDirty = m_d->resourceProvider->currentPreset()->isDirty();
952
953 // don't need to reload or overwrite a clean preset
954 m_d->uiWdgPaintOpPresetSettings.dirtyPresetIndicatorButton->setVisible(isPresetDirty);
955
956 {
957 bool isBroken = false;
958 QString brokenReason;
959 const int resourceId = m_d->resourceProvider->currentPreset()->resourceId();
960 if (resourceId >= 0) {
962 QModelIndex index = model.indexForResourceId(resourceId);
963 if (index.isValid()) {
964 isBroken = index.data(Qt::UserRole + KisAbstractResourceModel::BrokenStatus).toBool();
965 brokenReason =
966 QString(
967 "<html><body style=\"margin: 20px;\"><h3>%1</h3>"
968 "%2"
969 "</body></html>")
970 .arg(i18n("Resource is broken!"),
971 index.data(Qt::UserRole + KisAbstractResourceModel::BrokenStatusMessage).toString());
972 }
973 }
974
975 m_d->uiWdgPaintOpPresetSettings.brokenPresetIndicatorButton->setVisible(isBroken);
976 m_d->uiWdgPaintOpPresetSettings.brokenPresetIndicatorButton->setToolTip(brokenReason);
977 }
978
979 m_d->uiWdgPaintOpPresetSettings.reloadPresetButton->setVisible(isPresetDirty);
980 m_d->uiWdgPaintOpPresetSettings.saveBrushPresetButton->setEnabled(isPresetDirty);
981 m_d->uiWdgPaintOpPresetSettings.renameBrushPresetButton->setVisible(true);
982 }
983
984 // update live preview area in here...
985 // don't update the live preview if the widget is not visible.
986 if (m_d->uiWdgPaintOpPresetSettings.liveBrushPreviewView->isVisible()) {
987 m_d->uiWdgPaintOpPresetSettings.liveBrushPreviewView->setCurrentPreset(m_d->resourceProvider->currentPreset());
988 m_d->uiWdgPaintOpPresetSettings.liveBrushPreviewView->requestUpdateStroke();
989 }
990}
@ BrokenStatus
Whether the resource is broken (bool)

References KisAbstractResourceModel::BrokenStatus, KisAbstractResourceModel::BrokenStatusMessage, KisCanvasResourceProvider::currentPreset(), KisResourceModel::indexForResourceId(), KisPaintOpPresetsEditor::Private::isCreatingBrushFromScratch, m_d, ResourceType::PaintOpPresets, KisPaintOpPresetsEditor::Private::resourceProvider, and KisPaintOpPresetsEditor::Private::uiWdgPaintOpPresetSettings.

◆ toggleBrushRenameUIActive()

void KisPaintOpPresetsEditor::toggleBrushRenameUIActive ( bool isRenaming)
private

Definition at line 349 of file kis_paintop_presets_editor.cpp.

350{
351 // This function doesn't really do anything except get the UI in a state to rename a brush preset
352 m_d->uiWdgPaintOpPresetSettings.renameBrushNameTextField->setVisible(isRenaming);
353 m_d->uiWdgPaintOpPresetSettings.updateBrushNameButton->setVisible(isRenaming);
354 m_d->uiWdgPaintOpPresetSettings.cancelBrushNameUpdateButton->setVisible(isRenaming);
355
356
357 // hide these below areas while renaming
358 m_d->uiWdgPaintOpPresetSettings.currentBrushNameLabel->setVisible(!isRenaming);
359 m_d->uiWdgPaintOpPresetSettings.renameBrushPresetButton->setVisible(!isRenaming);
360 m_d->uiWdgPaintOpPresetSettings.saveBrushPresetButton->setEnabled(!isRenaming);
361 m_d->uiWdgPaintOpPresetSettings.saveBrushPresetButton->setVisible(!isRenaming);
362 m_d->uiWdgPaintOpPresetSettings.saveNewBrushPresetButton->setEnabled(!isRenaming);
363 m_d->uiWdgPaintOpPresetSettings.saveNewBrushPresetButton->setVisible(!isRenaming);
364
365 // if the presets area is shown, only then can you show/hide the load default brush
366 // need to think about weird state when you are in the middle of renaming a brush
367 // what happens if you try to change presets. maybe we should auto-hide (or disable)
368 // the presets area in this case
369 if (m_d->uiWdgPaintOpPresetSettings.presetWidget->isVisible()) {
370 m_d->uiWdgPaintOpPresetSettings.newPresetEngineButton->setVisible(!isRenaming);
371 m_d->uiWdgPaintOpPresetSettings.bnBlacklistPreset->setVisible(!isRenaming);
372 }
373
374}

References m_d, and KisPaintOpPresetsEditor::Private::uiWdgPaintOpPresetSettings.

◆ toggleDetachState

void KisPaintOpPresetsEditor::toggleDetachState ( bool detach)
signal

◆ updateThemedIcons

void KisPaintOpPresetsEditor::updateThemedIcons ( )
slot

Definition at line 894 of file kis_paintop_presets_editor.cpp.

895{
896 m_d->uiWdgPaintOpPresetSettings.viewOptionButton->setIcon(KisIconUtils::loadIcon("view-choose"));
897
898 m_d->uiWdgPaintOpPresetSettings.paintPresetIcon->setIcon(KisIconUtils::loadIcon("krita_tool_freehand"));
899 m_d->uiWdgPaintOpPresetSettings.fillLayer->setIcon(KisIconUtils::loadIcon("document-new"));
900 m_d->uiWdgPaintOpPresetSettings.fillLayer->hide();
901 m_d->uiWdgPaintOpPresetSettings.fillGradient->setIcon(KisIconUtils::loadIcon("krita_tool_gradient"));
902 m_d->uiWdgPaintOpPresetSettings.fillSolid->setIcon(KisIconUtils::loadIcon("krita_tool_color_fill"));
903 m_d->uiWdgPaintOpPresetSettings.eraseScratchPad->setIcon(KisIconUtils::loadIcon("edit-delete"));
904
905 m_d->uiWdgPaintOpPresetSettings.newPresetEngineButton->setIcon(KisIconUtils::loadIcon("list-add"));
906 m_d->uiWdgPaintOpPresetSettings.bnBlacklistPreset->setIcon(KisIconUtils::loadIcon("deletelayer"));
907 m_d->uiWdgPaintOpPresetSettings.reloadPresetButton->setIcon(KisIconUtils::loadIcon("reload-preset-16"));
908 m_d->uiWdgPaintOpPresetSettings.renameBrushPresetButton->setIcon(KisIconUtils::loadIcon("document-edit"));
909 m_d->uiWdgPaintOpPresetSettings.dirtyPresetIndicatorButton->setIcon(KisIconUtils::loadIcon("warning"));
910 m_d->uiWdgPaintOpPresetSettings.brokenPresetIndicatorButton->setIcon(KisIconUtils::loadIcon("broken-preset"));
911
912 m_d->uiWdgPaintOpPresetSettings.newPresetEngineButton->setIcon(KisIconUtils::loadIcon("list-add"));
913 m_d->uiWdgPaintOpPresetSettings.bnBlacklistPreset->setIcon(KisIconUtils::loadIcon("deletelayer"));
914 //m_d->uiWdgPaintOpPresetSettings.presetChangeViewToolButton->setIcon(KisIconUtils::loadIcon("view-choose"));
915
916 // store if the scratchpad or brush presets are visible in the config
917 KisConfig cfg(true);
918 if (cfg.presetStripVisible()) {
919 //m_d->uiWdgPaintOpPresetSettings.presetsSpacer->changeSize(0,0, QSizePolicy::Ignored,QSizePolicy::Ignored);
920 m_d->uiWdgPaintOpPresetSettings.showPresetsButton->setIcon(KisIconUtils::loadIcon("arrow-right"));
921 } else {
922 //m_d->uiWdgPaintOpPresetSettings.presetsSpacer->changeSize(0,0, QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding);
923 m_d->uiWdgPaintOpPresetSettings.showPresetsButton->setIcon(KisIconUtils::loadIcon("arrow-left"));
924 }
925
926 if (cfg.scratchpadVisible()) {
927 m_d->uiWdgPaintOpPresetSettings.showScratchpadButton->setIcon(KisIconUtils::loadIcon("arrow-left"));
928 } else {
929 m_d->uiWdgPaintOpPresetSettings.showScratchpadButton->setIcon(KisIconUtils::loadIcon("arrow-right"));
930 }
931}

References KisIconUtils::loadIcon(), m_d, KisConfig::presetStripVisible(), KisConfig::scratchpadVisible(), and KisPaintOpPresetsEditor::Private::uiWdgPaintOpPresetSettings.

◆ updateViewSettings()

void KisPaintOpPresetsEditor::updateViewSettings ( )

Definition at line 881 of file kis_paintop_presets_editor.cpp.

882{
883 m_d->uiWdgPaintOpPresetSettings.presetWidget->updateViewSettings();
884}

References m_d, and KisPaintOpPresetsEditor::Private::uiWdgPaintOpPresetSettings.

◆ writeOptionSetting()

Member Data Documentation

◆ brushPresetsPanelInitWidth

const int KisPaintOpPresetsEditor::brushPresetsPanelInitWidth = 200
private

Definition at line 119 of file kis_paintop_presets_editor.h.

◆ brushPresetsPanelMinWidth

const int KisPaintOpPresetsEditor::brushPresetsPanelMinWidth = 80
private

Definition at line 118 of file kis_paintop_presets_editor.h.

◆ current_paintOpId

QString KisPaintOpPresetsEditor::current_paintOpId
private

Definition at line 123 of file kis_paintop_presets_editor.h.

◆ m_d

Private* const KisPaintOpPresetsEditor::m_d
private

Definition at line 117 of file kis_paintop_presets_editor.h.

◆ newBrushEngineOptions

QList<QAction*> KisPaintOpPresetsEditor::newBrushEngineOptions
private

Definition at line 127 of file kis_paintop_presets_editor.h.

◆ newPresetBrushEnginesMenu

QMenu* KisPaintOpPresetsEditor::newPresetBrushEnginesMenu
private

Definition at line 126 of file kis_paintop_presets_editor.h.

◆ saveDialog

KisPresetSaveWidget* KisPaintOpPresetsEditor::saveDialog

Definition at line 63 of file kis_paintop_presets_editor.h.

◆ scratchPadPanelInitWidth

const int KisPaintOpPresetsEditor::scratchPadPanelInitWidth = 200
private

Definition at line 121 of file kis_paintop_presets_editor.h.

◆ scratchPadPanelMinWidth

const int KisPaintOpPresetsEditor::scratchPadPanelMinWidth = 80
private

Definition at line 120 of file kis_paintop_presets_editor.h.

◆ sortedBrushEnginesList

QList<KisPaintOpInfo> KisPaintOpPresetsEditor::sortedBrushEnginesList
private

Definition at line 124 of file kis_paintop_presets_editor.h.


The documentation for this class was generated from the following files: