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++
Add an icon to the preset editor explaining preset is broken
Dmitry Kazakovf3fc03bb0872
diff --git a/libs/ui/forms/wdgpaintopsettings.ui b/libs/ui/forms/wdgpaintopsettings.uiindex a7e31adff5..4c8fa6f8b1 100644--- a/libs/ui/forms/wdgpaintopsettings.ui+++ b/libs/ui/forms/wdgpaintopsettings.ui@@ -284,6 +284,34 @@</property></widget></item>+ <item>+ <widget class="QPushButton" name="brokenPresetIndicatorButton">+ <property name="sizePolicy">+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">+ <horstretch>0</horstretch>+ <verstretch>0</verstretch>+ </sizepolicy>+ </property>+ <property name="minimumSize">+ <size>+ <width>30</width>+ <height>30</height>+ </size>+ </property>+ <property name="maximumSize">+ <size>+ <width>30</width>+ <height>30</height>+ </size>+ </property>+ <property name="text">+ <string/>+ </property>+ <property name="flat">+ <bool>true</bool>+ </property>+ </widget>+ </item><item><spacer name="horizontalSpacer_4"><property name="orientation">diff --git a/libs/ui/widgets/kis_paintop_presets_editor.cpp b/libs/ui/widgets/kis_paintop_presets_editor.cppindex ac534759e5..517999b305 100644--- a/libs/ui/widgets/kis_paintop_presets_editor.cpp+++ b/libs/ui/widgets/kis_paintop_presets_editor.cpp@@ -894,6 +894,7 @@ void KisPaintOpPresetsEditor::updateThemedIcons()m_d->uiWdgPaintOpPresetSettings.reloadPresetButton->setIcon(KisIconUtils::loadIcon("reload-preset-16"));m_d->uiWdgPaintOpPresetSettings.renameBrushPresetButton->setIcon(KisIconUtils::loadIcon("document-edit"));m_d->uiWdgPaintOpPresetSettings.dirtyPresetIndicatorButton->setIcon(KisIconUtils::loadIcon("warning"));+ m_d->uiWdgPaintOpPresetSettings.brokenPresetIndicatorButton->setIcon(KisIconUtils::loadIcon("broken-preset"));m_d->uiWdgPaintOpPresetSettings.newPresetEngineButton->setIcon(KisIconUtils::loadIcon("list-add"));m_d->uiWdgPaintOpPresetSettings.bnBlacklistPreset->setIcon(KisIconUtils::loadIcon("deletelayer"));@@ -929,14 +930,39 @@ void KisPaintOpPresetsEditor::slotUpdatePresetSettings()// hide options on UI if we are creating a brush preset from scratch to prevent confusionif (m_d->isCreatingBrushFromScratch) {m_d->uiWdgPaintOpPresetSettings.dirtyPresetIndicatorButton->setVisible(false);+ m_d->uiWdgPaintOpPresetSettings.brokenPresetIndicatorButton->setVisible(false);m_d->uiWdgPaintOpPresetSettings.reloadPresetButton->setVisible(false);m_d->uiWdgPaintOpPresetSettings.saveBrushPresetButton->setVisible(false);m_d->uiWdgPaintOpPresetSettings.renameBrushPresetButton->setVisible(false);} else {- bool isPresetDirty = m_d->resourceProvider->currentPreset()->isDirty();+ const bool isPresetDirty = m_d->resourceProvider->currentPreset()->isDirty();// don't need to reload or overwrite a clean presetm_d->uiWdgPaintOpPresetSettings.dirtyPresetIndicatorButton->setVisible(isPresetDirty);++ {+ bool isBroken = false;+ QString brokenReason;+ const int resourceId = m_d->resourceProvider->currentPreset()->resourceId();+ if (resourceId >= 0) {+ KisResourceModel model(ResourceType::PaintOpPresets);+ QModelIndex index = model.indexForResourceId(resourceId);+ if (index.isValid()) {+ isBroken = index.data(Qt::UserRole + KisAbstractResourceModel::BrokenStatus).toBool();+ brokenReason =+ QString(+ "<html><h3>%1</h3>"+ "%2"+ "</html>")+ .arg(i18n("Resource is broken!"),+ index.data(Qt::UserRole + KisAbstractResourceModel::BrokenStatusMessage).toString());+ }+ }++ m_d->uiWdgPaintOpPresetSettings.brokenPresetIndicatorButton->setVisible(isBroken);+ m_d->uiWdgPaintOpPresetSettings.brokenPresetIndicatorButton->setToolTip(brokenReason);+ }+m_d->uiWdgPaintOpPresetSettings.reloadPresetButton->setVisible(isPresetDirty);m_d->uiWdgPaintOpPresetSettings.saveBrushPresetButton->setEnabled(isPresetDirty);m_d->uiWdgPaintOpPresetSettings.renameBrushPresetButton->setVisible(true);