Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Fix the current preset thumbnail to be present in the preset save dialog
Dmitry Kazakov429bb8493b4c
diff --git a/libs/ui/kis_paintop_box.cc b/libs/ui/kis_paintop_box.ccindex 00c73b4634..b50d4fd26d 100644--- a/libs/ui/kis_paintop_box.cc+++ b/libs/ui/kis_paintop_box.cc@@ -608,7 +608,6 @@ void KisPaintopBox::restoreResource(KoResourceSP resource)if (preset) {setCurrentPaintop(preset);- m_presetsEditor->setPresetImage(preset->image());m_presetsEditor->resourceSelected(resource);}}@@ -648,7 +647,6 @@ void KisPaintopBox::resourceSelected(KoResourceSP resource)dbgResources << "resourceSelected: preset" << preset << (preset ? QString("%1").arg(preset->valid()) : "");setCurrentPaintop(preset);- m_presetsEditor->setPresetImage(preset->image());m_presetsEditor->resourceSelected(resource);}}@@ -1395,7 +1393,6 @@ void KisPaintopBox::slotSwitchToPreviousPreset()i18n("%1\nselected",m_resourceProvider->currentPreset()->name()),QIcon(QPixmap::fromImage(m_resourceProvider->currentPreset()->image())));- m_presetsEditor->setPresetImage(m_resourceProvider->currentPreset()->image());}}diff --git a/libs/ui/widgets/kis_paintop_presets_editor.cpp b/libs/ui/widgets/kis_paintop_presets_editor.cppindex 6720e18393..e8c0e95dcc 100644--- a/libs/ui/widgets/kis_paintop_presets_editor.cpp+++ b/libs/ui/widgets/kis_paintop_presets_editor.cpp@@ -548,6 +548,9 @@ void KisPaintOpPresetsEditor::resourceSelected(KoResourceSP resource)// get the preset image and pop it into the thumbnail area on the top of the brush editorQSize thumbSize = QSize(55, 55)*devicePixelRatioF();QImage thumbImage = resource->image();++ m_d->uiWdgPaintOpPresetSettings.scratchPad->setPresetImage(thumbImage);+QPixmap thumbnail;if (!thumbImage.isNull()) {thumbnail = QPixmap::fromImage(thumbImage.scaled(thumbSize, Qt::KeepAspectRatio, Qt::SmoothTransformation));@@ -623,12 +626,6 @@ QString KisPaintOpPresetsEditor::currentPaintOpId() {return current_paintOpId;}-void KisPaintOpPresetsEditor::setPresetImage(const QImage& image)-{- m_d->uiWdgPaintOpPresetSettings.scratchPad->setPresetImage(image);- saveDialog->brushPresetThumbnailWidget->setPresetImage(image);-}-void KisPaintOpPresetsEditor::hideEvent(QHideEvent *event){if (m_d->ignoreHideEvents) {@@ -837,6 +834,8 @@ void KisPaintOpPresetsEditor::slotSaveBrushPreset() {// there is a dialog with save options, but we don't need to show it in this situationsaveDialog->useNewBrushDialog(false); // this mostly just makes sure we keep the existing brush preset name when saving+ const QImage thumbImage = m_d->resourceProvider->currentPreset() ? m_d->resourceProvider->currentPreset()->image() : QImage();+ saveDialog->brushPresetThumbnailWidget->setPresetImage(thumbImage);saveDialog->saveScratchPadThumbnailArea(m_d->uiWdgPaintOpPresetSettings.scratchPad->cutoutOverlay());saveDialog->loadExistingThumbnail(); // This makes sure we use the existing preset icon when updating the existing brush presetsaveDialog->showDialog();@@ -848,6 +847,8 @@ void KisPaintOpPresetsEditor::slotSaveBrushPreset() {void KisPaintOpPresetsEditor::slotSaveNewBrushPreset() {saveDialog->useNewBrushDialog(true);+ const QImage thumbImage = m_d->resourceProvider->currentPreset() ? m_d->resourceProvider->currentPreset()->image() : QImage();+ saveDialog->brushPresetThumbnailWidget->setPresetImage(thumbImage);saveDialog->saveScratchPadThumbnailArea(m_d->uiWdgPaintOpPresetSettings.scratchPad->cutoutOverlay());saveDialog->showDialog();}diff --git a/libs/ui/widgets/kis_paintop_presets_editor.h b/libs/ui/widgets/kis_paintop_presets_editor.hindex 81673fa568..01dc93f797 100644--- a/libs/ui/widgets/kis_paintop_presets_editor.h+++ b/libs/ui/widgets/kis_paintop_presets_editor.h@@ -54,10 +54,6 @@ public:/// returns the internal ID for the paint op (brush engine)QString currentPaintOpId();- ///fill the cutoutOverlay rect with the content of an image, used to get the image back when selecting a preset- ///@param image image that will be used, should be image of an existing preset resource- void setPresetImage(const QImage& image);-void resizeEvent(QResizeEvent* ) override;void updateViewSettings();