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
this, SLOT(slotCanvasResourceChanged(int,QVariant)));
m_resourceManager->setResource(KoCanvasResourceProvider::ApplicationSpeciality, KoCanvasResourceProvider::NoAdvancedText);
m_resourceManager->setResource(GamutMaskActive, false);
}
......@@ -163,6 +165,11 @@ KoGamutMask *KisCanvasResourceProvider::currentGamutMask() const
}
}
bool KisCanvasResourceProvider::gamutMaskActive() const
{
return m_resourceManager->resource(GamutMaskActive).toBool();
}
KisPaintOpPresetSP KisCanvasResourceProvider::currentPreset() const
{
KisPaintOpPresetSP preset = m_resourceManager->resource(CurrentPaintOpPreset).value<KisPaintOpPresetSP>();
......@@ -369,11 +376,15 @@ void KisCanvasResourceProvider::slotGamutMaskActivated(KoGamutMask *mask)
QVariant v;
v.setValue<KoGamutMask*>(mask);
m_resourceManager->setResource(CurrentGamutMask, v);
m_resourceManager->setResource(GamutMaskActive, QVariant::fromValue(true));
emit sigGamutMaskChanged(mask);
}
void KisCanvasResourceProvider::slotGamutMaskUnset()
{
m_resourceManager->setResource(GamutMaskActive, QVariant::fromValue(false));
m_resourceManager->clearResource(CurrentGamutMask);
emit sigGamutMaskUnset();
}
......@@ -383,6 +394,12 @@ void KisCanvasResourceProvider::slotGamutMaskPreviewUpdate()
emit sigGamutMaskPreviewUpdate();
}
void KisCanvasResourceProvider::slotGamutMaskDeactivate()
{
m_resourceManager->setResource(GamutMaskActive, QVariant::fromValue(false));
emit sigGamutMaskDeactivated();
}
void KisCanvasResourceProvider::slotResetEnableFGChange(bool b)
{
m_enablefGChange = b;
......
......@@ -55,6 +55,7 @@ public:
HdrExposure = KoCanvasResourceProvider::KritaStart + 1,
CurrentPattern,
CurrentGamutMask,
GamutMaskActive,
CurrentGradient,
CurrentDisplayProfile,
CurrentKritaNode,
......@@ -116,6 +117,7 @@ public:
KisNodeSP currentNode() const;
KoGamutMask* currentGamutMask() const;
bool gamutMaskActive() const;
KisPaintOpPresetSP currentPreset() const;
void setPaintOpPreset(const KisPaintOpPresetSP preset);
......@@ -185,6 +187,7 @@ public Q_SLOTS:
void slotGamutMaskActivated(KoGamutMask* mask);
void slotGamutMaskUnset();
void slotGamutMaskPreviewUpdate();
void slotGamutMaskDeactivate();
/**
* Set the image size in pixels. The resource provider will store
......@@ -226,6 +229,7 @@ Q_SIGNALS:
void sigGamutMaskChanged(KoGamutMask* mask);
void sigGamutMaskUnset();
void sigGamutMaskPreviewUpdate();
void sigGamutMaskDeactivated();
private:
......
......@@ -20,9 +20,11 @@
#include "KisGamutMaskToolbar.h"
#include <kis_icon_utils.h>
#include <kis_canvas_resource_provider.h>
#include <kis_signals_blocker.h>
KisGamutMaskToolbar::KisGamutMaskToolbar(QWidget* parent) : QWidget(parent)
, m_selectedMask(nullptr)
, m_selfUpdate(false)
{
m_ui = new Ui_wdgGamutMaskToolbar();
m_ui->setupUi(this);
......@@ -57,6 +59,12 @@ void KisGamutMaskToolbar::connectMaskSignals(KisCanvasResourceProvider* resource
connect(this, SIGNAL(sigGamutMaskChanged(KoGamutMask*)),
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)
......@@ -65,6 +73,10 @@ void KisGamutMaskToolbar::slotGamutMaskSet(KoGamutMask *mask)
return;
}
if (m_selfUpdate) {
return;
}
m_selectedMask = mask;
if (m_selectedMask) {
......@@ -81,6 +93,15 @@ void KisGamutMaskToolbar::slotGamutMaskUnset()
m_ui->labelMaskName->setText(m_textNoMask);
}
void KisGamutMaskToolbar::slotGamutMaskDeactivate()
{
if (m_selfUpdate) {
return;
}
slotGamutMaskToggle(false);
}
void KisGamutMaskToolbar::slotGamutMaskToggle(bool state)
{
bool b = (!m_selectedMask) ? false : state;
......@@ -95,14 +116,21 @@ void KisGamutMaskToolbar::slotGamutMaskToggle(bool state)
m_ui->rotationSlider->blockSignals(true);
m_ui->rotationSlider->setValue(m_selectedMask->rotation());
m_ui->rotationSlider->blockSignals(false);
m_selfUpdate = true;
emit sigGamutMaskChanged(m_selectedMask);
m_selfUpdate = false;
} else {
m_ui->bnToggleMask->setIcon(m_iconMaskOff);
m_ui->rotationSlider->hide();
m_ui->labelMaskName->show();
m_ui->labelMaskName->setText(m_textMaskDisabled);
}
emit sigGamutMaskToggle(state);
m_selfUpdate = true;
emit sigGamutMaskDeactivated();
m_selfUpdate = false;
}
}
void KisGamutMaskToolbar::slotGamutMaskRotate(int angle)
......
......@@ -37,12 +37,13 @@ public:
void connectMaskSignals(KisCanvasResourceProvider* resourceProvider);
Q_SIGNALS:
void sigGamutMaskToggle(bool state);
void sigGamutMaskChanged(KoGamutMask*);
void sigGamutMaskDeactivated();
public Q_SLOTS:
void slotGamutMaskSet(KoGamutMask* mask);
void slotGamutMaskUnset();
void slotGamutMaskDeactivate();
private Q_SLOTS:
void slotGamutMaskToggle(bool state);
......@@ -57,6 +58,8 @@ private:
QString m_textNoMask;
QString m_textMaskDisabled;
bool m_selfUpdate;
};
#endif // KISGAMUTMASKTOOLBAR_H
......@@ -176,6 +176,11 @@ void KisColorSelector::slotGamutMaskPreviewUpdate()
m_subComponent->updateGamutMaskPreview();
}
void KisColorSelector::slotGamutMaskDeactivate()
{
slotGamutMaskToggle(false);
}
void KisColorSelector::slotGamutMaskToggle(bool state)
{
m_mainComponent->toggleGamutMask(state);
......
......@@ -55,6 +55,7 @@ public Q_SLOTS:
void slotGamutMaskUnset();
void slotGamutMaskPreviewUpdate();
void slotGamutMaskToggle(bool state);
void slotGamutMaskDeactivate();
Q_SIGNALS:
void settingsButtonClicked();
......
......@@ -154,10 +154,10 @@ void KisColorSelectorContainer::setCanvas(KisCanvas2* canvas)
connect(m_canvas->viewManager()->canvasResourceProvider(), SIGNAL(sigGamutMaskPreviewUpdate()),
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
connect(m_gamutMaskToolbar, SIGNAL(sigGamutMaskToggle(bool)), m_colorSelector, SLOT(slotGamutMaskToggle(bool)), Qt::UniqueConnection);
m_gamutMaskToolbar->connectMaskSignals(m_canvas->viewManager()->canvasResourceProvider());
KActionCollection* actionCollection = canvas->viewManager()->actionCollection();
actionCollection->addAction("show_color_selector", m_colorSelAction);
......
......@@ -212,9 +212,6 @@ ArtisticColorSelectorDock::ArtisticColorSelectorDock()
connect(m_selectorUI->colorSelector , SIGNAL(sigFgColorChanged(KisColor)) , SLOT(slotFgColorChanged(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()));
setWidget(m_selectorUI);
......@@ -241,6 +238,9 @@ void ArtisticColorSelectorDock::setViewManager(KisViewManager* kisview)
connect(m_resourceProvider, SIGNAL(sigGamutMaskPreviewUpdate()),
this, SLOT(slotGamutMaskPreviewUpdate()), Qt::UniqueConnection);
connect(m_resourceProvider, SIGNAL(sigGamutMaskDeactivated()),
this, SLOT(slotGamutMaskDeactivate()), Qt::UniqueConnection);
m_selectorUI->gamutMaskToolbar->connectMaskSignals(m_resourceProvider);
}
......@@ -454,6 +454,11 @@ void ArtisticColorSelectorDock::slotGamutMaskPreviewUpdate()
m_selectorUI->colorSelector->setDirty();
}
void ArtisticColorSelectorDock::slotGamutMaskDeactivate()
{
slotGamutMaskToggle(false);
}
void ArtisticColorSelectorDock::slotSelectorSettingsChanged()
{
m_selectorUI->colorSelector->setDirty();
......
......@@ -66,6 +66,7 @@ private Q_SLOTS:
void slotGamutMaskSet(KoGamutMask* mask);
void slotGamutMaskUnset();
void slotGamutMaskPreviewUpdate();
void slotGamutMaskDeactivate();
void slotSelectorSettingsChanged();
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