diff --git a/libs/ui/forms/wdgpaintopsettings.ui b/libs/ui/forms/wdgpaintopsettings.ui
--- a/libs/ui/forms/wdgpaintopsettings.ui
+++ b/libs/ui/forms/wdgpaintopsettings.ui
@@ -330,6 +330,13 @@
+ -
+
+
+ Save Color
+
+
+
-
diff --git a/libs/ui/kis_canvas_resource_provider.cpp b/libs/ui/kis_canvas_resource_provider.cpp
--- a/libs/ui/kis_canvas_resource_provider.cpp
+++ b/libs/ui/kis_canvas_resource_provider.cpp
@@ -43,6 +43,9 @@
#include "KisViewManager.h"
#include "canvas/kis_canvas2.h"
+const QString FIXED_COLOR_FOREGROUND = "color/fixed_foreground";
+const QString FIXED_COLOR_BACKGROUND = "color/fixed_background";
+
KisCanvasResourceProvider::KisCanvasResourceProvider(KisViewManager * view)
: m_view(view)
{
@@ -178,6 +181,12 @@
dbgUI << "setPaintOpPreset" << preset->paintOp();
+ KisPaintOpSettingsSP settings = preset->settings();
+ if (settings->hasProperty(FIXED_COLOR_FOREGROUND) && preset != previousPreset()) {
+ setFGColor(settings->getColor(FIXED_COLOR_FOREGROUND));
+ setBGColor(settings->getColor(FIXED_COLOR_BACKGROUND));
+ }
+
QVariant v;
v.setValue(preset);
m_resourceManager->setResource(CurrentPaintOpPreset, v);
diff --git a/libs/ui/widgets/kis_paintop_presets_popup.h b/libs/ui/widgets/kis_paintop_presets_popup.h
--- a/libs/ui/widgets/kis_paintop_presets_popup.h
+++ b/libs/ui/widgets/kis_paintop_presets_popup.h
@@ -125,6 +125,8 @@
void slotSwitchShowPresets(bool visible);
void slotSaveBrushPreset();
void slotSaveNewBrushPreset();
+ void slotSaveCurrentColorToggled(bool);
+ void slotReloadPresetClicked();
/// we do not delete brushe presets, but blacklist them so they disappear from the interface
void slotBlackListCurrentPreset();
diff --git a/libs/ui/widgets/kis_paintop_presets_popup.cpp b/libs/ui/widgets/kis_paintop_presets_popup.cpp
--- a/libs/ui/widgets/kis_paintop_presets_popup.cpp
+++ b/libs/ui/widgets/kis_paintop_presets_popup.cpp
@@ -60,6 +60,10 @@
#include
#include
+#include "kis_paintop_settings.h"
+const QString FIXED_COLOR_FOREGROUND = "color/fixed_foreground";
+const QString FIXED_COLOR_BACKGROUND = "color/fixed_background";
+
struct KisPaintOpPresetsPopup::Private
{
@@ -85,8 +89,8 @@
KisFavoriteResourceManager* favoriteResourceManager,
KisPresetSaveWidget* savePresetWidget,
QWidget * parent)
- : QWidget(parent)
- , m_d(new Private())
+ : QWidget(parent)
+ , m_d(new Private())
{
setObjectName("KisPaintOpPresetsPopup");
setFont(KoDockRegistry::dockFont());
@@ -245,6 +249,9 @@
m_d->settingsWidget = 0;
setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
+ connect(m_d->uiWdgPaintOpPresetSettings.saveCurrentColor, SIGNAL(toggled(bool)),
+ this, SLOT(slotSaveCurrentColorToggled(bool)));
+
connect(m_d->uiWdgPaintOpPresetSettings.saveBrushPresetButton, SIGNAL(clicked()),
this, SLOT(slotSaveBrushPreset()));
@@ -252,7 +259,7 @@
this, SLOT(slotSaveNewBrushPreset()));
connect(m_d->uiWdgPaintOpPresetSettings.reloadPresetButton, SIGNAL(clicked()),
- this, SIGNAL(reloadPresetClicked()));
+ this, SLOT(slotReloadPresetClicked()));
connect(m_d->uiWdgPaintOpPresetSettings.dirtyPresetCheckBox, SIGNAL(toggled(bool)),
this, SIGNAL(dirtyPresetToggled(bool)));
@@ -268,13 +275,6 @@
connect(m_d->uiWdgPaintOpPresetSettings.presetWidget->smallPresetChooser, SIGNAL(resourceSelected(KoResource*)),
this, SIGNAL(signalResourceSelected(KoResource*)));
- connect(m_d->uiWdgPaintOpPresetSettings.reloadPresetButton, SIGNAL(clicked()),
- m_d->uiWdgPaintOpPresetSettings.presetWidget->smallPresetChooser, SLOT(updateViewSettings()));
-
-
-
- connect(m_d->uiWdgPaintOpPresetSettings.reloadPresetButton, SIGNAL(clicked()), SLOT(slotUpdatePresetSettings()));
-
m_d->detached = false;
m_d->ignoreHideEvents = false;
m_d->minimumSettingsWidgetSize = QSize(0, 0);
@@ -637,7 +637,8 @@
}
-QString KisPaintOpPresetsPopup::currentPaintOpId() {
+QString KisPaintOpPresetsPopup::currentPaintOpId()
+{
return current_paintOpId;
}
@@ -704,11 +705,13 @@
cfg.setScratchpadVisible(visible);
}
-void KisPaintOpPresetsPopup::slotSwitchShowEditor(bool visible) {
+void KisPaintOpPresetsPopup::slotSwitchShowEditor(bool visible)
+{
m_d->uiWdgPaintOpPresetSettings.brushEditorSettingsControls->setVisible(visible);
}
-void KisPaintOpPresetsPopup::slotSwitchShowPresets(bool visible) {
+void KisPaintOpPresetsPopup::slotSwitchShowPresets(bool visible)
+{
m_d->uiWdgPaintOpPresetSettings.presetWidget->setVisible(visible);
m_d->uiWdgPaintOpPresetSettings.presetChangeViewToolButton->setVisible(visible);
@@ -730,7 +733,8 @@
}
-void KisPaintOpPresetsPopup::slotUpdatePaintOpFilter() {
+void KisPaintOpPresetsPopup::slotUpdatePaintOpFilter()
+{
QVariant userData = m_d->uiWdgPaintOpPresetSettings.brushEgineComboBox->currentData(); // grab paintOpID from data
QString filterPaintOpId = userData.toString();
@@ -740,7 +744,8 @@
m_d->uiWdgPaintOpPresetSettings.presetWidget->setPresetFilter(filterPaintOpId);
}
-void KisPaintOpPresetsPopup::slotSaveBrushPreset() {
+void KisPaintOpPresetsPopup::slotSaveBrushPreset()
+{
// here we are assuming that people want to keep their existing preset icon. We will just update the
// settings and save a new copy with the same name.
// there is a dialog with save options, but we don't need to show it in this situation
@@ -753,12 +758,52 @@
slotUpdatePresetSettings();
}
-void KisPaintOpPresetsPopup::slotSaveNewBrushPreset() {
+void KisPaintOpPresetsPopup::slotSaveNewBrushPreset()
+{
saveDialog->useNewBrushDialog(true);
saveDialog->saveScratchPadThumbnailArea(m_d->uiWdgPaintOpPresetSettings.scratchPad->cutoutOverlay());
saveDialog->showDialog();
}
+void KisPaintOpPresetsPopup::slotSaveCurrentColorToggled(bool)
+{
+ KisPaintOpPresetSP currentPreset = m_d->resourceProvider->currentPreset();
+ KisPaintOpSettingsSP currentSettings = currentPreset->settings();
+ if (m_d->uiWdgPaintOpPresetSettings.saveCurrentColor->isChecked()) {
+ if (!currentSettings->hasProperty(FIXED_COLOR_FOREGROUND)) {
+ QVariant foreground;
+ foreground.setValue(m_d->resourceProvider->fgColor());
+ QVariant background;
+ background.setValue(m_d->resourceProvider->bgColor());
+ currentSettings->setProperty(FIXED_COLOR_FOREGROUND, foreground);
+ currentSettings->setProperty(FIXED_COLOR_BACKGROUND, background);
+ }
+ }
+ else {
+ if (currentSettings->hasProperty(FIXED_COLOR_FOREGROUND)) {
+ currentSettings->removeProperty(FIXED_COLOR_FOREGROUND);
+ currentSettings->removeProperty(FIXED_COLOR_BACKGROUND);
+ currentPreset->setPresetDirty(true);
+ }
+ }
+ slotUpdatePresetSettings();
+}
+
+void KisPaintOpPresetsPopup::slotReloadPresetClicked()
+{
+ emit reloadPresetClicked();
+ m_d->uiWdgPaintOpPresetSettings.presetWidget->smallPresetChooser->updateViewSettings();
+ KisPaintOpSettingsSP settings = m_d->resourceProvider->currentPreset()->settings();
+ bool hasColor = settings->hasProperty(FIXED_COLOR_FOREGROUND);
+ if (hasColor) {
+ m_d->resourceProvider->setFGColor(settings->getColor(FIXED_COLOR_FOREGROUND));
+ m_d->resourceProvider->setBGColor(settings->getColor(FIXED_COLOR_BACKGROUND));
+ }
+ m_d->uiWdgPaintOpPresetSettings.saveCurrentColor->setChecked(hasColor);
+
+ slotUpdatePresetSettings();
+}
+
void KisPaintOpPresetsPopup::slotCreateNewBrushPresetEngine()
{
emit createPresetFromScratch(sender()->objectName());
@@ -772,6 +817,9 @@
void KisPaintOpPresetsPopup::currentPresetChanged(KisPaintOpPresetSP preset)
{
if (preset) {
+ bool hasColor = preset->settings()->hasProperty(FIXED_COLOR_FOREGROUND);
+ m_d->uiWdgPaintOpPresetSettings.saveCurrentColor->setText(hasColor ? "Has Color" : "Save Current Color");
+ m_d->uiWdgPaintOpPresetSettings.saveCurrentColor->setChecked(hasColor);
m_d->uiWdgPaintOpPresetSettings.presetWidget->smallPresetChooser->setCurrentResource(preset.data());
setCurrentPaintOpId(preset->paintOp().id());
}
@@ -831,6 +879,7 @@
m_d->uiWdgPaintOpPresetSettings.reloadPresetButton->setVisible(false);
m_d->uiWdgPaintOpPresetSettings.saveBrushPresetButton->setVisible(false);
m_d->uiWdgPaintOpPresetSettings.renameBrushPresetButton->setVisible(false);
+ m_d->uiWdgPaintOpPresetSettings.saveCurrentColor->setChecked(false);
} else {
bool isPresetDirty = m_d->resourceProvider->currentPreset()->isPresetDirty();
@@ -839,6 +888,9 @@
m_d->uiWdgPaintOpPresetSettings.reloadPresetButton->setVisible(isPresetDirty);
m_d->uiWdgPaintOpPresetSettings.saveBrushPresetButton->setEnabled(isPresetDirty);
m_d->uiWdgPaintOpPresetSettings.renameBrushPresetButton->setVisible(true);
+ bool hasColor = m_d->resourceProvider->currentPreset()->settings()->hasProperty(FIXED_COLOR_FOREGROUND);
+ m_d->uiWdgPaintOpPresetSettings.saveCurrentColor->setChecked(hasColor);
+ m_d->uiWdgPaintOpPresetSettings.saveCurrentColor->setText(hasColor ? "Has Color" : "Save Current Color");
}
// update live preview area in here...