Commit 35d78951 authored by Anna Medonosová's avatar Anna Medonosová Committed by Anna Medonosová

Gamut masking: share activation state in KisCanvasResourceProvider

KisCanvasResource provider stores activation state of current gamut
mask. Activation state is synchronized across color selectors and
their gamut masking toolbars.
parent 39f8f675
...@@ -84,6 +84,8 @@ void KisCanvasResourceProvider::setResourceManager(KoCanvasResourceProvider *res ...@@ -84,6 +84,8 @@ void KisCanvasResourceProvider::setResourceManager(KoCanvasResourceProvider *res
this, SLOT(slotCanvasResourceChanged(int,QVariant))); this, SLOT(slotCanvasResourceChanged(int,QVariant)));
m_resourceManager->setResource(KoCanvasResourceProvider::ApplicationSpeciality, KoCanvasResourceProvider::NoAdvancedText); m_resourceManager->setResource(KoCanvasResourceProvider::ApplicationSpeciality, KoCanvasResourceProvider::NoAdvancedText);
m_resourceManager->setResource(GamutMaskActive, false);
} }
...@@ -163,6 +165,11 @@ KoGamutMask *KisCanvasResourceProvider::currentGamutMask() const ...@@ -163,6 +165,11 @@ KoGamutMask *KisCanvasResourceProvider::currentGamutMask() const
} }
} }
bool KisCanvasResourceProvider::gamutMaskActive() const
{
return m_resourceManager->resource(GamutMaskActive).toBool();
}
KisPaintOpPresetSP KisCanvasResourceProvider::currentPreset() const KisPaintOpPresetSP KisCanvasResourceProvider::currentPreset() const
{ {
KisPaintOpPresetSP preset = m_resourceManager->resource(CurrentPaintOpPreset).value<KisPaintOpPresetSP>(); KisPaintOpPresetSP preset = m_resourceManager->resource(CurrentPaintOpPreset).value<KisPaintOpPresetSP>();
...@@ -369,11 +376,15 @@ void KisCanvasResourceProvider::slotGamutMaskActivated(KoGamutMask *mask) ...@@ -369,11 +376,15 @@ void KisCanvasResourceProvider::slotGamutMaskActivated(KoGamutMask *mask)
QVariant v; QVariant v;
v.setValue<KoGamutMask*>(mask); v.setValue<KoGamutMask*>(mask);
m_resourceManager->setResource(CurrentGamutMask, v); m_resourceManager->setResource(CurrentGamutMask, v);
m_resourceManager->setResource(GamutMaskActive, QVariant::fromValue(true));
emit sigGamutMaskChanged(mask); emit sigGamutMaskChanged(mask);
} }
void KisCanvasResourceProvider::slotGamutMaskUnset() void KisCanvasResourceProvider::slotGamutMaskUnset()
{ {
m_resourceManager->setResource(GamutMaskActive, QVariant::fromValue(false));
m_resourceManager->clearResource(CurrentGamutMask); m_resourceManager->clearResource(CurrentGamutMask);
emit sigGamutMaskUnset(); emit sigGamutMaskUnset();
} }
...@@ -383,6 +394,12 @@ void KisCanvasResourceProvider::slotGamutMaskPreviewUpdate() ...@@ -383,6 +394,12 @@ void KisCanvasResourceProvider::slotGamutMaskPreviewUpdate()
emit sigGamutMaskPreviewUpdate(); emit sigGamutMaskPreviewUpdate();
} }
void KisCanvasResourceProvider::slotGamutMaskDeactivate()
{
m_resourceManager->setResource(GamutMaskActive, QVariant::fromValue(false));
emit sigGamutMaskDeactivated();
}
void KisCanvasResourceProvider::slotResetEnableFGChange(bool b) void KisCanvasResourceProvider::slotResetEnableFGChange(bool b)
{ {
m_enablefGChange = b; m_enablefGChange = b;
......
...@@ -55,6 +55,7 @@ public: ...@@ -55,6 +55,7 @@ public:
HdrExposure = KoCanvasResourceProvider::KritaStart + 1, HdrExposure = KoCanvasResourceProvider::KritaStart + 1,
CurrentPattern, CurrentPattern,
CurrentGamutMask, CurrentGamutMask,
GamutMaskActive,
CurrentGradient, CurrentGradient,
CurrentDisplayProfile, CurrentDisplayProfile,
CurrentKritaNode, CurrentKritaNode,
...@@ -116,6 +117,7 @@ public: ...@@ -116,6 +117,7 @@ public:
KisNodeSP currentNode() const; KisNodeSP currentNode() const;
KoGamutMask* currentGamutMask() const; KoGamutMask* currentGamutMask() const;
bool gamutMaskActive() const;
KisPaintOpPresetSP currentPreset() const; KisPaintOpPresetSP currentPreset() const;
void setPaintOpPreset(const KisPaintOpPresetSP preset); void setPaintOpPreset(const KisPaintOpPresetSP preset);
...@@ -185,6 +187,7 @@ public Q_SLOTS: ...@@ -185,6 +187,7 @@ public Q_SLOTS:
void slotGamutMaskActivated(KoGamutMask* mask); void slotGamutMaskActivated(KoGamutMask* mask);
void slotGamutMaskUnset(); void slotGamutMaskUnset();
void slotGamutMaskPreviewUpdate(); void slotGamutMaskPreviewUpdate();
void slotGamutMaskDeactivate();
/** /**
* Set the image size in pixels. The resource provider will store * Set the image size in pixels. The resource provider will store
...@@ -226,6 +229,7 @@ Q_SIGNALS: ...@@ -226,6 +229,7 @@ Q_SIGNALS:
void sigGamutMaskChanged(KoGamutMask* mask); void sigGamutMaskChanged(KoGamutMask* mask);
void sigGamutMaskUnset(); void sigGamutMaskUnset();
void sigGamutMaskPreviewUpdate(); void sigGamutMaskPreviewUpdate();
void sigGamutMaskDeactivated();
private: private:
......
...@@ -20,9 +20,11 @@ ...@@ -20,9 +20,11 @@
#include "KisGamutMaskToolbar.h" #include "KisGamutMaskToolbar.h"
#include <kis_icon_utils.h> #include <kis_icon_utils.h>
#include <kis_canvas_resource_provider.h> #include <kis_canvas_resource_provider.h>
#include <kis_signals_blocker.h>
KisGamutMaskToolbar::KisGamutMaskToolbar(QWidget* parent) : QWidget(parent) KisGamutMaskToolbar::KisGamutMaskToolbar(QWidget* parent) : QWidget(parent)
, m_selectedMask(nullptr) , m_selectedMask(nullptr)
, m_selfUpdate(false)
{ {
m_ui = new Ui_wdgGamutMaskToolbar(); m_ui = new Ui_wdgGamutMaskToolbar();
m_ui->setupUi(this); m_ui->setupUi(this);
...@@ -57,6 +59,12 @@ void KisGamutMaskToolbar::connectMaskSignals(KisCanvasResourceProvider* resource ...@@ -57,6 +59,12 @@ void KisGamutMaskToolbar::connectMaskSignals(KisCanvasResourceProvider* resource
connect(this, SIGNAL(sigGamutMaskChanged(KoGamutMask*)), connect(this, SIGNAL(sigGamutMaskChanged(KoGamutMask*)),
resourceProvider, SLOT(slotGamutMaskActivated(KoGamutMask*)), Qt::UniqueConnection); resourceProvider, SLOT(slotGamutMaskActivated(KoGamutMask*)), Qt::UniqueConnection);
connect(this, SIGNAL(sigGamutMaskDeactivated()),
resourceProvider, SLOT(slotGamutMaskDeactivate()), Qt::UniqueConnection);
connect(resourceProvider, SIGNAL(sigGamutMaskDeactivated()),
this, SLOT(slotGamutMaskDeactivate()), Qt::UniqueConnection);
} }
void KisGamutMaskToolbar::slotGamutMaskSet(KoGamutMask *mask) void KisGamutMaskToolbar::slotGamutMaskSet(KoGamutMask *mask)
...@@ -65,6 +73,10 @@ void KisGamutMaskToolbar::slotGamutMaskSet(KoGamutMask *mask) ...@@ -65,6 +73,10 @@ void KisGamutMaskToolbar::slotGamutMaskSet(KoGamutMask *mask)
return; return;
} }
if (m_selfUpdate) {
return;
}
m_selectedMask = mask; m_selectedMask = mask;
if (m_selectedMask) { if (m_selectedMask) {
...@@ -81,6 +93,15 @@ void KisGamutMaskToolbar::slotGamutMaskUnset() ...@@ -81,6 +93,15 @@ void KisGamutMaskToolbar::slotGamutMaskUnset()
m_ui->labelMaskName->setText(m_textNoMask); m_ui->labelMaskName->setText(m_textNoMask);
} }
void KisGamutMaskToolbar::slotGamutMaskDeactivate()
{
if (m_selfUpdate) {
return;
}
slotGamutMaskToggle(false);
}
void KisGamutMaskToolbar::slotGamutMaskToggle(bool state) void KisGamutMaskToolbar::slotGamutMaskToggle(bool state)
{ {
bool b = (!m_selectedMask) ? false : state; bool b = (!m_selectedMask) ? false : state;
...@@ -95,14 +116,21 @@ void KisGamutMaskToolbar::slotGamutMaskToggle(bool state) ...@@ -95,14 +116,21 @@ void KisGamutMaskToolbar::slotGamutMaskToggle(bool state)
m_ui->rotationSlider->blockSignals(true); m_ui->rotationSlider->blockSignals(true);
m_ui->rotationSlider->setValue(m_selectedMask->rotation()); m_ui->rotationSlider->setValue(m_selectedMask->rotation());
m_ui->rotationSlider->blockSignals(false); m_ui->rotationSlider->blockSignals(false);
m_selfUpdate = true;
emit sigGamutMaskChanged(m_selectedMask);
m_selfUpdate = false;
} else { } else {
m_ui->bnToggleMask->setIcon(m_iconMaskOff); m_ui->bnToggleMask->setIcon(m_iconMaskOff);
m_ui->rotationSlider->hide(); m_ui->rotationSlider->hide();
m_ui->labelMaskName->show(); m_ui->labelMaskName->show();
m_ui->labelMaskName->setText(m_textMaskDisabled); m_ui->labelMaskName->setText(m_textMaskDisabled);
}
emit sigGamutMaskToggle(state); m_selfUpdate = true;
emit sigGamutMaskDeactivated();
m_selfUpdate = false;
}
} }
void KisGamutMaskToolbar::slotGamutMaskRotate(int angle) void KisGamutMaskToolbar::slotGamutMaskRotate(int angle)
......
...@@ -37,12 +37,13 @@ public: ...@@ -37,12 +37,13 @@ public:
void connectMaskSignals(KisCanvasResourceProvider* resourceProvider); void connectMaskSignals(KisCanvasResourceProvider* resourceProvider);
Q_SIGNALS: Q_SIGNALS:
void sigGamutMaskToggle(bool state);
void sigGamutMaskChanged(KoGamutMask*); void sigGamutMaskChanged(KoGamutMask*);
void sigGamutMaskDeactivated();
public Q_SLOTS: public Q_SLOTS:
void slotGamutMaskSet(KoGamutMask* mask); void slotGamutMaskSet(KoGamutMask* mask);
void slotGamutMaskUnset(); void slotGamutMaskUnset();
void slotGamutMaskDeactivate();
private Q_SLOTS: private Q_SLOTS:
void slotGamutMaskToggle(bool state); void slotGamutMaskToggle(bool state);
...@@ -57,6 +58,8 @@ private: ...@@ -57,6 +58,8 @@ private:
QString m_textNoMask; QString m_textNoMask;
QString m_textMaskDisabled; QString m_textMaskDisabled;
bool m_selfUpdate;
}; };
#endif // KISGAMUTMASKTOOLBAR_H #endif // KISGAMUTMASKTOOLBAR_H
...@@ -176,6 +176,11 @@ void KisColorSelector::slotGamutMaskPreviewUpdate() ...@@ -176,6 +176,11 @@ void KisColorSelector::slotGamutMaskPreviewUpdate()
m_subComponent->updateGamutMaskPreview(); m_subComponent->updateGamutMaskPreview();
} }
void KisColorSelector::slotGamutMaskDeactivate()
{
slotGamutMaskToggle(false);
}
void KisColorSelector::slotGamutMaskToggle(bool state) void KisColorSelector::slotGamutMaskToggle(bool state)
{ {
m_mainComponent->toggleGamutMask(state); m_mainComponent->toggleGamutMask(state);
......
...@@ -55,6 +55,7 @@ public Q_SLOTS: ...@@ -55,6 +55,7 @@ public Q_SLOTS:
void slotGamutMaskUnset(); void slotGamutMaskUnset();
void slotGamutMaskPreviewUpdate(); void slotGamutMaskPreviewUpdate();
void slotGamutMaskToggle(bool state); void slotGamutMaskToggle(bool state);
void slotGamutMaskDeactivate();
Q_SIGNALS: Q_SIGNALS:
void settingsButtonClicked(); void settingsButtonClicked();
......
...@@ -154,10 +154,10 @@ void KisColorSelectorContainer::setCanvas(KisCanvas2* canvas) ...@@ -154,10 +154,10 @@ void KisColorSelectorContainer::setCanvas(KisCanvas2* canvas)
connect(m_canvas->viewManager()->canvasResourceProvider(), SIGNAL(sigGamutMaskPreviewUpdate()), connect(m_canvas->viewManager()->canvasResourceProvider(), SIGNAL(sigGamutMaskPreviewUpdate()),
m_colorSelector, SLOT(slotGamutMaskPreviewUpdate()), Qt::UniqueConnection); m_colorSelector, SLOT(slotGamutMaskPreviewUpdate()), Qt::UniqueConnection);
m_gamutMaskToolbar->connectMaskSignals(m_canvas->viewManager()->canvasResourceProvider()); connect(m_canvas->viewManager()->canvasResourceProvider(), SIGNAL(sigGamutMaskDeactivated()),
m_colorSelector, SLOT(slotGamutMaskDeactivate()), Qt::UniqueConnection);
// gamut mask connections m_gamutMaskToolbar->connectMaskSignals(m_canvas->viewManager()->canvasResourceProvider());
connect(m_gamutMaskToolbar, SIGNAL(sigGamutMaskToggle(bool)), m_colorSelector, SLOT(slotGamutMaskToggle(bool)), Qt::UniqueConnection);
KActionCollection* actionCollection = canvas->viewManager()->actionCollection(); KActionCollection* actionCollection = canvas->viewManager()->actionCollection();
actionCollection->addAction("show_color_selector", m_colorSelAction); actionCollection->addAction("show_color_selector", m_colorSelAction);
......
...@@ -212,9 +212,6 @@ ArtisticColorSelectorDock::ArtisticColorSelectorDock() ...@@ -212,9 +212,6 @@ ArtisticColorSelectorDock::ArtisticColorSelectorDock()
connect(m_selectorUI->colorSelector , SIGNAL(sigFgColorChanged(KisColor)) , SLOT(slotFgColorChanged(KisColor))); connect(m_selectorUI->colorSelector , SIGNAL(sigFgColorChanged(KisColor)) , SLOT(slotFgColorChanged(KisColor)));
connect(m_selectorUI->colorSelector , SIGNAL(sigBgColorChanged(KisColor)) , SLOT(slotBgColorChanged(KisColor))); connect(m_selectorUI->colorSelector , SIGNAL(sigBgColorChanged(KisColor)) , SLOT(slotBgColorChanged(KisColor)));
// gamut mask connections
connect(m_selectorUI->gamutMaskToolbar, SIGNAL(sigGamutMaskToggle(bool)), SLOT(slotGamutMaskToggle(bool)));
connect(m_hsxButtons , SIGNAL(buttonClicked(int)) , SLOT(slotColorSpaceSelected())); connect(m_hsxButtons , SIGNAL(buttonClicked(int)) , SLOT(slotColorSpaceSelected()));
setWidget(m_selectorUI); setWidget(m_selectorUI);
...@@ -241,6 +238,9 @@ void ArtisticColorSelectorDock::setViewManager(KisViewManager* kisview) ...@@ -241,6 +238,9 @@ void ArtisticColorSelectorDock::setViewManager(KisViewManager* kisview)
connect(m_resourceProvider, SIGNAL(sigGamutMaskPreviewUpdate()), connect(m_resourceProvider, SIGNAL(sigGamutMaskPreviewUpdate()),
this, SLOT(slotGamutMaskPreviewUpdate()), Qt::UniqueConnection); this, SLOT(slotGamutMaskPreviewUpdate()), Qt::UniqueConnection);
connect(m_resourceProvider, SIGNAL(sigGamutMaskDeactivated()),
this, SLOT(slotGamutMaskDeactivate()), Qt::UniqueConnection);
m_selectorUI->gamutMaskToolbar->connectMaskSignals(m_resourceProvider); m_selectorUI->gamutMaskToolbar->connectMaskSignals(m_resourceProvider);
} }
...@@ -454,6 +454,11 @@ void ArtisticColorSelectorDock::slotGamutMaskPreviewUpdate() ...@@ -454,6 +454,11 @@ void ArtisticColorSelectorDock::slotGamutMaskPreviewUpdate()
m_selectorUI->colorSelector->setDirty(); m_selectorUI->colorSelector->setDirty();
} }
void ArtisticColorSelectorDock::slotGamutMaskDeactivate()
{
slotGamutMaskToggle(false);
}
void ArtisticColorSelectorDock::slotSelectorSettingsChanged() void ArtisticColorSelectorDock::slotSelectorSettingsChanged()
{ {
m_selectorUI->colorSelector->setDirty(); m_selectorUI->colorSelector->setDirty();
......
...@@ -66,6 +66,7 @@ private Q_SLOTS: ...@@ -66,6 +66,7 @@ private Q_SLOTS:
void slotGamutMaskSet(KoGamutMask* mask); void slotGamutMaskSet(KoGamutMask* mask);
void slotGamutMaskUnset(); void slotGamutMaskUnset();
void slotGamutMaskPreviewUpdate(); void slotGamutMaskPreviewUpdate();
void slotGamutMaskDeactivate();
void slotSelectorSettingsChanged(); void slotSelectorSettingsChanged();
private: private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment