Krita Source Code Documentation
Loading...
Searching...
No Matches
WGColorSelectorDock Class Reference

#include <WGColorSelectorDock.h>

+ Inheritance diagram for WGColorSelectorDock:

Public Types

enum  ColorSpaceSource { LayerColorSpace , ImageColorSpace , FixedColorSpace }
 

Public Member Functions

KisUniqueColorSetcolorHistoryModel () const
 
const KisVisualColorModelcolorModel () const
 
KisDisplayColorConverterdisplayColorConverter (bool rawPointer=false) const
 
bool selectingBackground () const
 
void setChannelValues (const QVector4D &values)
 Set new channel values; takes effect immediately!
 
 WGColorSelectorDock ()
 
- Public Member Functions inherited from KisMainwindowObserver
 KisMainwindowObserver ()
 
 ~KisMainwindowObserver () override
 
- Public Member Functions inherited from KoCanvasObserverBase
 KoCanvasObserverBase ()
 
KoCanvasBaseobservedCanvas () const
 
virtual QString observerName ()
 
void setObservedCanvas (KoCanvasBase *canvas)
 
void unsetObservedCanvas ()
 
virtual ~KoCanvasObserverBase ()
 

Protected Member Functions

void disconnectFromCanvas ()
 
bool eventFilter (QObject *obj, QEvent *ev) override
 
void setCanvas (KoCanvasBase *canvas) override
 
void setViewManager (KisViewManager *viewManager) override
 
void unsetCanvas () override
 
void updateLayout ()
 

Private Slots

void slotCanvasResourceChanged (int key, const QVariant &value)
 
void slotColorInteraction (bool active)
 
void slotColorSelected (const KoColor &color)
 
void slotColorSourceToggled (bool selectingBg)
 
void slotConfigurationChanged ()
 
void slotDisplayConfigurationChanged ()
 
void slotFGColorUsed (const KoColor &color)
 
void slotOpenSettings ()
 
void slotSetNewColors ()
 
void slotShowGamutMaskToolbar (bool show)
 

Private Attributes

WGActionManagerm_actionManager {0}
 
QPointer< KisCanvas2m_canvas
 
KisSignalCompressorm_colorChangeCompressor
 
bool m_colorHistoryFromDocument {false}
 
KisVisualColorModelSP m_colorModelBG
 
KisVisualColorModelSP m_colorModelFG
 
WGColorPreviewToolTipm_colorTooltip {0}
 
WGColorPatchesm_commonColors {0}
 
WGCommonColorSetm_commonColorSet {0}
 
QToolButton * m_configButton {0}
 
ColorSpaceSource m_CSSource {LayerColorSpace}
 
const KoColorSpacem_customCS {0}
 
WGSelectorDisplayConfigSP m_displayConfig
 
KisUniqueColorSetm_documentColorHistoryModel {0}
 
std::unique_ptr< KisUniqueColorSetm_fallbackColorHistoryModel
 
KisGamutMaskToolbarm_gamutToolbar
 
KisUniqueColorSetm_globalColorHistoryModel {0}
 
WGColorPatchesm_history {0}
 
QWidget * m_mainWidget
 
QBoxLayout * m_mainWidgetLayout {0}
 
bool m_pendingBgUpdate {false}
 
bool m_pendingFgUpdate {false}
 
QWidgetAction * m_quickSettingAction {0}
 
WGQuickSettingsWidgetm_quickSettings {0}
 
KisVisualColorSelectorm_selector {0}
 
QBoxLayout * m_selectorAreaLayout {0}
 
WGShadeSelectorm_shadeSelector {0}
 
KisColorSourceTogglem_toggle {0}
 
QBoxLayout * m_verticalElementsLayout {0}
 

Detailed Description

Definition at line 38 of file WGColorSelectorDock.h.

Member Enumeration Documentation

◆ ColorSpaceSource

Enumerator
LayerColorSpace 
ImageColorSpace 
FixedColorSpace 

Definition at line 42 of file WGColorSelectorDock.h.

Constructor & Destructor Documentation

◆ WGColorSelectorDock()

WGColorSelectorDock::WGColorSelectorDock ( )

Definition at line 41 of file WGColorSelectorDock.cpp.

42 : QDockWidget()
48 , m_mainWidget(new QWidget())
49{
50 setWindowTitle(i18n("Wide Gamut Color Selector"));
51
52 QWidget *mainWidget = m_mainWidget;
53 mainWidget->installEventFilter(this);
54
55 m_mainWidgetLayout = new QVBoxLayout(mainWidget);
56 m_verticalElementsLayout = new QHBoxLayout();
57 m_selectorAreaLayout = new QBoxLayout(QBoxLayout::TopToBottom);
58
59 m_selector = new KisVisualColorSelector(mainWidget);
61 connect(m_selector, SIGNAL(sigNewColor(KoColor)), SLOT(slotColorSelected(KoColor)));
62 connect(m_selector, SIGNAL(sigInteraction(bool)), SLOT(slotColorInteraction(bool)));
63 connect(m_colorChangeCompressor, SIGNAL(timeout()), SLOT(slotSetNewColors()));
65
66 // Header
67 QWidget *headerWidget = new QWidget(mainWidget);
68 QHBoxLayout *headerLayout = new QHBoxLayout(headerWidget);
69
70 m_toggle = new KisColorSourceToggle(mainWidget);
71 connect(m_toggle, SIGNAL(toggled(bool)), SLOT(slotColorSourceToggled(bool)));
72 headerLayout->addWidget(m_toggle);
74 m_gamutToolbar->setContentsMargins(0, 0, 0, 5);
75 m_gamutToolbar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
76 headerLayout->addWidget(m_gamutToolbar);
77 headerLayout->addStretch();
78 headerLayout->setContentsMargins(0, 0, 0, 0);
79
80 connect(m_selector, SIGNAL(sigGamutMaskSupportChanged(bool)), SLOT(slotShowGamutMaskToolbar(bool)));
81
82 m_configButton = new QToolButton(this);
83 m_configButton->setIcon(KisIconUtils::loadIcon("view-choose"));
84 m_configButton->setAutoRaise(true);
85 m_configButton->setPopupMode(QToolButton::InstantPopup);
86 headerLayout->addWidget(m_configButton);
87
88 m_mainWidgetLayout->addWidget(headerWidget);
91
93
97 connect(m_shadeSelector, SIGNAL(sigColorInteraction(bool)), SLOT(slotColorInteraction(bool)));
98
99 // eventually it should made be a global history, not specific to any plugin
103
106 connect(m_history, SIGNAL(sigColorChanged(KoColor)), SLOT(slotColorSelected(KoColor)));
107 connect(m_history, SIGNAL(sigColorInteraction(bool)), SLOT(slotColorInteraction(bool)));
108
109 // Common Colors (Colors from Image)
111
114 connect(m_commonColors, SIGNAL(sigColorChanged(KoColor)), SLOT(slotColorSelected(KoColor)));
115 connect(m_commonColors, SIGNAL(sigColorInteraction(bool)), SLOT(slotColorInteraction(bool)));
116
117 connect(WGConfig::notifier(), SIGNAL(configChanged()), SLOT(slotConfigurationChanged()));
118
119 setWidget(mainWidget);
121 setEnabled(false);
122}
The KisVisualColorModel class allows manipulating a KoColor using various color models.
The KisVisualColorSelector class.
KisVisualColorModelSP selectorModel() const
void setPreset(Preset preset)
void slotColorSelected(const KoColor &color)
QBoxLayout * m_selectorAreaLayout
KisGamutMaskToolbar * m_gamutToolbar
void slotShowGamutMaskToolbar(bool show)
void slotColorInteraction(bool active)
WGCommonColorSet * m_commonColorSet
WGShadeSelector * m_shadeSelector
KisVisualColorModelSP m_colorModelBG
KisColorSourceToggle * m_toggle
QBoxLayout * m_mainWidgetLayout
void slotColorSourceToggled(bool selectingBg)
WGColorPatches * m_history
WGActionManager * m_actionManager
KisSignalCompressor * m_colorChangeCompressor
KisVisualColorModelSP m_colorModelFG
KisUniqueColorSet * m_documentColorHistoryModel
std::unique_ptr< KisUniqueColorSet > m_fallbackColorHistoryModel
KisVisualColorSelector * m_selector
QBoxLayout * m_verticalElementsLayout
KisUniqueColorSet * m_globalColorHistoryModel
WGColorPatches * m_commonColors
WGSelectorDisplayConfigSP m_displayConfig
WGColorPreviewToolTip * m_colorTooltip
QIcon loadIcon(const QString &name)
WGConfigNotifier * notifier()
Definition WGConfig.cpp:190

References WGColorPatches::CommonColors, WGColorPatches::History, KisIconUtils::loadIcon(), m_colorChangeCompressor, m_colorModelFG, m_commonColors, m_commonColorSet, m_configButton, m_displayConfig, m_documentColorHistoryModel, m_fallbackColorHistoryModel, m_gamutToolbar, m_globalColorHistoryModel, m_history, m_mainWidget, m_mainWidgetLayout, m_selector, m_selectorAreaLayout, m_shadeSelector, m_toggle, m_verticalElementsLayout, WGConfig::notifier(), KisVisualColorSelector::selectorModel(), KisVisualColorSelector::setMinimumSliderWidth(), WGColorPatches::setPreset(), slotColorInteraction(), slotColorSelected(), slotColorSourceToggled(), slotConfigurationChanged(), slotSetNewColors(), and slotShowGamutMaskToolbar().

Member Function Documentation

◆ colorHistoryModel()

◆ colorModel()

const KisVisualColorModel & WGColorSelectorDock::colorModel ( ) const

Definition at line 124 of file WGColorSelectorDock.cpp.

125{
126 // currently always return foreground model;
127 // do lazy conversion to current HSX model if required
128 if (selectingBackground() && m_colorModelBG->isHSXModel()) {
129 m_colorModelFG->setRGBColorModel(m_colorModelBG->colorModel());
130 }
131 return *(m_colorModelFG);
132}

References m_colorModelBG, m_colorModelFG, and selectingBackground().

◆ disconnectFromCanvas()

void WGColorSelectorDock::disconnectFromCanvas ( )
protected

Definition at line 243 of file WGColorSelectorDock.cpp.

244{
245 m_canvas->disconnectCanvasObserver(this);
246 m_canvas->displayColorConverter()->displayRendererInterface()->disconnect(this);
247 m_canvas->imageView()->resourceProvider()->disconnect(m_selector);
248 m_canvas = 0;
249}
QPointer< KisCanvas2 > m_canvas

References m_canvas, and m_selector.

◆ displayColorConverter()

KisDisplayColorConverter * WGColorSelectorDock::displayColorConverter ( bool rawPointer = false) const

Definition at line 134 of file WGColorSelectorDock.cpp.

135{
136 KisDisplayColorConverter *converter = nullptr;
137 if (m_canvas) {
138 converter = m_canvas->displayColorConverter();
139 }
140 return (rawPointer || converter) ? converter : KisDisplayColorConverter::dumbConverterInstance();
141}
static KisDisplayColorConverter * dumbConverterInstance()

References KisDisplayColorConverter::dumbConverterInstance(), and m_canvas.

◆ eventFilter()

bool WGColorSelectorDock::eventFilter ( QObject * obj,
QEvent * ev )
overrideprotected

Definition at line 514 of file WGColorSelectorDock.cpp.

515{
516 Q_UNUSED(obj);
517
518 // Get the leave event of the inner widget, for when the docker is borrowed and doesn't properly handle leave events
519 if (e->type() == QEvent::Leave) {
520 m_colorTooltip->hide();
521 }
522
523 return false;
524}

References m_colorTooltip.

◆ selectingBackground()

bool WGColorSelectorDock::selectingBackground ( ) const

Definition at line 143 of file WGColorSelectorDock.cpp.

144{
145 return m_toggle->isChecked();
146}

References m_toggle.

◆ setCanvas()

void WGColorSelectorDock::setCanvas ( KoCanvasBase * canvas)
overrideprotectedvirtual

re-implement this method in your canvas observer. It will be called whenever a canvas becomes active. Note that you are responsible for not connecting more than one time to the signals of a canvas or any of the QObjects you can access through the canvas.

Implements KoCanvasObserverBase.

Definition at line 170 of file WGColorSelectorDock.cpp.

171{
172 if (m_canvas.data() == canvas)
173 {
174 // not sure why setCanvas gets called 3 times for new canvas, just skip
175 return;
176 }
177 if (m_canvas) {
179 }
180 m_actionManager->setCanvas(qobject_cast<KisCanvas2*>(canvas), m_canvas);
181 m_canvas = qobject_cast<KisCanvas2*>(canvas);
182 // TODO: unset display converters if canvas is null
183 if (m_canvas) {
184 KoColorDisplayRendererInterface *dri = m_canvas->displayColorConverter()->displayRendererInterface();
185 KisCanvasResourceProvider *resourceProvider = m_canvas->imageView()->resourceProvider();
186
187 m_globalColorHistoryModel = resourceProvider->colorHistoryModel();
188 m_documentColorHistoryModel = m_canvas->imageView()->document()->colorHistoryModel();
189
192
194 m_displayConfig->setDisplayConverter(m_canvas->displayColorConverter());
196 //m_toggle->setBackgroundColor(dri->toQColor(color));
197 connect(dri, SIGNAL(displayConfigurationChanged()), this, SLOT(slotDisplayConfigurationChanged()));
198 connect(m_canvas->resourceManager(), SIGNAL(canvasResourceChanged(int,QVariant)),
199 this, SLOT(slotCanvasResourceChanged(int,QVariant)));
200 connect(resourceProvider, SIGNAL(sigFGColorUsed(KoColor)),
201 this, SLOT(slotFGColorUsed(KoColor)), Qt::UniqueConnection);
202
203 // Gamut Mask
204 connect(resourceProvider, SIGNAL(sigGamutMaskChanged(KoGamutMaskSP)),
205 m_selector, SLOT(slotGamutMaskChanged(KoGamutMaskSP)), Qt::UniqueConnection);
206
207 connect(resourceProvider, SIGNAL(sigGamutMaskPreviewUpdate()),
208 m_selector, SLOT(slotGamutMaskPreviewUpdate()), Qt::UniqueConnection);
209
210 connect(resourceProvider, SIGNAL(sigGamutMaskUnset()),
211 m_selector, SLOT(slotGamutMaskUnset()), Qt::UniqueConnection);
212
213 connect(resourceProvider, SIGNAL(sigGamutMaskDeactivated()),
214 m_selector, SLOT(slotGamutMaskUnset()), Qt::UniqueConnection);
215
216 m_gamutToolbar->connectMaskSignals(resourceProvider);
217
218 // quirk note: displayConfigurationChanged signal gets sent *before* the new canvas gets
219 // passed, through the display converter of the now inactive canvas! So we need to repeat...
221 }
222 setEnabled(canvas != 0);
223}
KisUniqueColorSet * colorHistoryModel() const
void connectMaskSignals(KisCanvasResourceProvider *resourceProvider)
void setDisplayRenderer(const KoColorDisplayRendererInterface *displayRenderer) override
void setCanvas(KisCanvas2 *canvas, KisCanvas2 *oldCanvas)
void setColorHistoryModel(KisUniqueColorSet *history)
KisUniqueColorSet * colorHistoryModel() const
void slotFGColorUsed(const KoColor &color)
void slotCanvasResourceChanged(int key, const QVariant &value)
void setImage(KisImageSP image)

References KisCanvasResourceProvider::colorHistoryModel(), colorHistoryModel(), KisGamutMaskToolbar::connectMaskSignals(), disconnectFromCanvas(), m_actionManager, m_canvas, m_commonColorSet, m_displayConfig, m_documentColorHistoryModel, m_gamutToolbar, m_globalColorHistoryModel, m_history, m_selector, WGActionManager::setCanvas(), WGColorPatches::setColorHistoryModel(), KisVisualColorSelector::setDisplayRenderer(), WGCommonColorSet::setImage(), slotCanvasResourceChanged(), slotDisplayConfigurationChanged(), slotFGColorUsed(), and WGActionManager::updateColorHistoryModel().

◆ setChannelValues()

void WGColorSelectorDock::setChannelValues ( const QVector4D & values)

Set new channel values; takes effect immediately!

This is intended for synchronization when color gets adjusted outside of the docker, like in WGActionManager

Parameters
values

Definition at line 148 of file WGColorSelectorDock.cpp.

149{
150 // currently always set foreground color
151 if (!m_canvas) {
152 return;
153 }
154
155 // This could be nicer...if setting active model, this triggers slotColorSelected()
156 // and leaves timer running with NOP, otherwise the resource update is detected as
157 // external event and updates UI.
158 m_colorModelFG->slotSetChannelValues(values);
159
160 m_canvas->resourceManager()->setForegroundColor(m_colorModelFG->currentColor());
161 m_pendingFgUpdate = false;
162}

References m_canvas, m_colorModelFG, and m_pendingFgUpdate.

◆ setViewManager()

void WGColorSelectorDock::setViewManager ( KisViewManager * viewManager)
overrideprotectedvirtual

Implements KisMainwindowObserver.

Definition at line 238 of file WGColorSelectorDock.cpp.

239{
240 m_actionManager->registerActions(viewManager);
241}
void registerActions(KisViewManager *viewManager)

References m_actionManager, and WGActionManager::registerActions().

◆ slotCanvasResourceChanged

void WGColorSelectorDock::slotCanvasResourceChanged ( int key,
const QVariant & value )
privateslot

Definition at line 478 of file WGColorSelectorDock.cpp.

479{
480 switch (key) {
482 if (!m_pendingFgUpdate) {
483 KoColor color = value.value<KoColor>();
485 m_colorModelFG->slotSetColor(color);
486 }
487 break;
489 if (!m_pendingBgUpdate) {
490 KoColor color = value.value<KoColor>();
492 m_colorModelBG->slotSetColor(color);
493 }
494 default:
495 break;
496 }
497}
float value(const T *src, size_t ch)
void setBackgroundColor(const QColor &color)
void setForegroundColor(const QColor &color)
QColor toQColor(const KoColor &c, bool proofToPaintColors=false) const
KisDisplayColorConverter * displayColorConverter(bool rawPointer=false) const
@ BackgroundColor
The active background color selected for this canvas.
@ ForegroundColor
The active foreground color selected for this canvas.

References KoCanvasResource::BackgroundColor, displayColorConverter(), KoCanvasResource::ForegroundColor, m_colorModelBG, m_colorModelFG, m_pendingBgUpdate, m_pendingFgUpdate, m_toggle, KisColorSourceToggle::setBackgroundColor(), KisColorSourceToggle::setForegroundColor(), KisDisplayColorConverter::toQColor(), and value().

◆ slotColorInteraction

void WGColorSelectorDock::slotColorInteraction ( bool active)
privateslot

Definition at line 439 of file WGColorSelectorDock.cpp.

440{
441 if (active) {
442 QColor baseCol = m_displayConfig->displayConverter()->toQColor(m_selector->getCurrentColor());
445 if (sender() == m_shadeSelector) {
447 } else {
449 }
450 }
451}
KoColor getCurrentColor() const override
void show(const QWidget *focus=nullptr)
void setCurrentColor(const QColor &color)
void setPreviousColor(const QColor &color)

References KisVisualColorSelector::getCurrentColor(), m_colorTooltip, m_displayConfig, m_mainWidget, m_selector, m_shadeSelector, WGColorPreviewToolTip::setCurrentColor(), WGColorPreviewToolTip::setPreviousColor(), and WGColorPreviewToolTip::show().

◆ slotColorSelected

◆ slotColorSourceToggled

void WGColorSelectorDock::slotColorSourceToggled ( bool selectingBg)
privateslot

Definition at line 417 of file WGColorSelectorDock.cpp.

418{
419 if (selectingBg) {
420 if (m_colorModelFG->isHSXModel()) {
421 m_colorModelBG->setRGBColorModel(m_colorModelFG->colorModel());
422 }
425 }
426 else {
427 if (m_colorModelBG->isHSXModel()) {
428 m_colorModelFG->setRGBColorModel(m_colorModelBG->colorModel());
429 }
432 }
433 // currently, only the color space of the active model is updated, so it may be outdated
434 if (m_canvas) {
436 }
437}
void setSelectorModel(KisVisualColorModelSP model)
void setModel(KisVisualColorModelSP colorModel) override

References m_canvas, m_colorModelBG, m_colorModelFG, m_selector, m_shadeSelector, WGShadeSelector::setModel(), KisVisualColorSelector::setSelectorModel(), and slotDisplayConfigurationChanged().

◆ slotConfigurationChanged

void WGColorSelectorDock::slotConfigurationChanged ( )
privateslot

Definition at line 302 of file WGColorSelectorDock.cpp.

303{
306 m_selector->selectorModel()->setRGBColorModel(cfg.get(WGConfig::rgbColorModel));
307 KisColorSelectorConfiguration selectorCfg = cfg.colorSelectorConfiguration();
308 m_selector->setConfiguration(&selectorCfg);
311 m_customCS = cfg.customSelectionColorSpace();
312 }
313 bool proofColors = cfg.get(WGConfig::proofToPaintingColors);
314 m_selector->setProofColors(proofColors);
315 m_displayConfig->setPreviewInPaintingCS(proofColors);
317
322
325 // Quick settings menu
326 if (cfg.get(WGConfig::quickSettingsEnabled)) {
327 if (!m_configButton->menu()) {
328 m_configButton->disconnect(this);
329 QMenu *configureMenu = new QMenu(this);
331 // prevents hover indicator being stuck on other menu entries
332 m_quickSettings->setMouseTracking(true);
333 m_quickSettingAction = new QWidgetAction(this);
334 m_quickSettingAction->setDefaultWidget(m_quickSettings);
335
336 configureMenu->addAction(m_quickSettingAction);
337 QAction *cfgAction = configureMenu->addAction(i18nc("Wide Gamut Color Selector", "Configure..."));
338 connect(cfgAction, SIGNAL(triggered(bool)), SLOT(slotOpenSettings()));
339 m_configButton->setMenu(configureMenu);
340 } else {
341 // WORKAROUND: force geometry update by re-adding action, all other attempts failed...
342 QMenu *menu = m_configButton->menu();
343 menu->removeAction(m_quickSettingAction);
344 menu->insertAction(menu->actions().constFirst(), m_quickSettingAction);
345 }
347 } else {
348 if (m_configButton->menu()) {
349 m_configButton->menu()->deleteLater();
350 m_configButton->setMenu(0);
353 m_quickSettings = 0;
354 }
355 connect(m_configButton, SIGNAL(clicked(bool)), SLOT(slotOpenSettings()), Qt::UniqueConnection);
356 }
357
358 updateLayout();
359
360 if (m_canvas) {
362 }
363}
void setRenderMode(RenderMode mode)
void setConfiguration(const KisColorSelectorConfiguration *config)
Explicitly set the shape configuration. Accepts all valid combinations of Advanced Color Selector,...
void updateSettings() override
const KoColorSpace * m_customCS
WGQuickSettingsWidget * m_quickSettings
QWidgetAction * m_quickSettingAction
ColorSpaceSource m_CSSource
void setAutoUpdate(bool enabled)
void updateSettings() override
const GenericSetting< bool > colorHistoryFromDocument
Definition WGConfig.cpp:239
const NumericSetting< KisVisualColorSelector::RenderMode > selectorRenderMode
Definition WGConfig.cpp:256
const NumericSetting< WGColorSelectorDock::ColorSpaceSource > colorSpaceSource
const NumericSetting< KisVisualColorModel::ColorModel > rgbColorModel
Definition WGConfig.cpp:253
class WGConfig Accessor
const GenericSetting< bool > proofToPaintingColors
Definition WGConfig.cpp:237
const GenericSetting< bool > quickSettingsEnabled
Definition WGConfig.cpp:244
const GenericSetting< bool > commonColorsAutoUpdate
Definition WGConfig.cpp:242

References WGConfig::colorHistoryFromDocument, colorHistoryModel(), WGConfig::colorSpaceSource, WGConfig::commonColorsAutoUpdate, FixedColorSpace, WGQuickSettingsWidget::loadConfiguration(), m_actionManager, m_canvas, m_colorHistoryFromDocument, m_commonColors, m_commonColorSet, m_configButton, m_CSSource, m_customCS, m_displayConfig, m_history, m_quickSettingAction, m_quickSettings, m_selector, m_shadeSelector, WGConfig::proofToPaintingColors, WGConfig::quickSettingsEnabled, WGConfig::rgbColorModel, KisVisualColorSelector::selectorModel(), WGConfig::selectorRenderMode, WGCommonColorSet::setAutoUpdate(), WGColorPatches::setColorHistoryModel(), KisVisualColorSelector::setConfiguration(), KisVisualColorSelector::setProofColors(), KisVisualColorSelector::setRenderMode(), slotDisplayConfigurationChanged(), slotOpenSettings(), WGActionManager::updateColorHistoryModel(), updateLayout(), WGColorPatches::updateSettings(), and WGShadeSelector::updateSettings().

◆ slotDisplayConfigurationChanged

void WGColorSelectorDock::slotDisplayConfigurationChanged ( )
privateslot

Definition at line 365 of file WGColorSelectorDock.cpp.

366{
367 if (!m_canvas) {
368 return;
369 }
370
371 const KoColorSpace *selectionCS = nullptr;
372
373 // Note: displayConfigurationChanged is also emitted on image color space changes,
374 // so there's no need to handle extra signals, although it's a bit convoluted
376 selectionCS = m_canvas->image()->colorSpace();
377 } else if (m_CSSource == FixedColorSpace) {
378 selectionCS = m_customCS;
379 } else {
380 selectionCS = m_canvas->displayColorConverter()->nodeColorSpace();
381 }
382
383 // TODO: use m_viewManager->canvasResourceProvider()->fgColor();
384 KoColor fgColor = m_canvas->resourceManager()->foregroundColor();
385 KoColor bgColor = m_canvas->resourceManager()->backgroundColor();
386
387 bool proof = m_displayConfig->previewInPaintingCS();
388 m_toggle->setForegroundColor(displayColorConverter()->toQColor(fgColor, proof));
389 m_toggle->setBackgroundColor(displayColorConverter()->toQColor(bgColor, proof));
391
392 if (selectionCS && selectionCS != activeModel->colorSpace()) {
393 activeModel->slotSetColorSpace(selectionCS);
394 activeModel->slotSetColor(activeModel == m_colorModelFG ? fgColor : bgColor);
395 }
396}

References displayColorConverter(), FixedColorSpace, ImageColorSpace, m_canvas, m_colorModelFG, m_CSSource, m_customCS, m_displayConfig, m_selector, m_toggle, KisVisualColorSelector::selectorModel(), KisColorSourceToggle::setBackgroundColor(), and KisColorSourceToggle::setForegroundColor().

◆ slotFGColorUsed

void WGColorSelectorDock::slotFGColorUsed ( const KoColor & color)
privateslot

◆ slotOpenSettings

void WGColorSelectorDock::slotOpenSettings ( )
privateslot

Definition at line 499 of file WGColorSelectorDock.cpp.

500{
501 if (!m_canvas) return;
502
504 if (settings.exec() == QDialog::Accepted) {
505 //WGConfig::notifier()->notifyConfigChanged();
506 }
507}

References m_canvas.

◆ slotSetNewColors

void WGColorSelectorDock::slotSetNewColors ( )
privateslot

Definition at line 465 of file WGColorSelectorDock.cpp.

466{
467 //KIS_SAFE_ASSERT_RECOVER_RETURN(m_pendingFgUpdate || m_pendingBgUpdate);
468 if (m_pendingFgUpdate) {
469 m_canvas->resourceManager()->setForegroundColor(m_colorModelFG->currentColor());
470 m_pendingFgUpdate = false;
471 }
472 if (m_pendingBgUpdate) {
473 m_canvas->resourceManager()->setBackgroundColor(m_colorModelBG->currentColor());
474 m_pendingBgUpdate = false;
475 }
476}

References m_canvas, m_colorModelBG, m_colorModelFG, m_pendingBgUpdate, and m_pendingFgUpdate.

◆ slotShowGamutMaskToolbar

void WGColorSelectorDock::slotShowGamutMaskToolbar ( bool show)
privateslot

Definition at line 509 of file WGColorSelectorDock.cpp.

510{
511 m_gamutToolbar->setVisible(show);
512}

References m_gamutToolbar.

◆ unsetCanvas()

void WGColorSelectorDock::unsetCanvas ( )
overrideprotectedvirtual

Re-implement to notify the observer that its canvas is no longer among the living. The daisies, it is pushing up. This means you don't have to disconnect, it's dead.

The old canvas should be deleted already, so if you stored a pointer to it, don't touch!

Note that currently there is a bug where in certain specific circumstances unsetCanvas can be called when it shouldn't, see for example KWStatisticsDocker for a workaround for this problem.

Implements KoCanvasObserverBase.

Definition at line 225 of file WGColorSelectorDock.cpp.

226{
227 setEnabled(false);
229 m_displayConfig->setDisplayConverter(0);
232
235 m_canvas = 0;
236}
KisSharedPtr< KisImage > KisImageSP
Definition kis_types.h:69

References m_actionManager, m_canvas, m_commonColorSet, m_displayConfig, m_documentColorHistoryModel, m_globalColorHistoryModel, m_history, m_selector, WGActionManager::setCanvas(), WGColorPatches::setColorHistoryModel(), KisVisualColorSelector::setDisplayRenderer(), and WGCommonColorSet::setImage().

◆ updateLayout()

void WGColorSelectorDock::updateLayout ( )
protected

Definition at line 251 of file WGColorSelectorDock.cpp.

252{
254
255 bool historyEnabled = cfg.get(WGConfig::colorHistoryEnabled);
256 Qt::Orientation historyOrientation = cfg.get(WGConfig::colorHistory.orientation);
257
258 m_verticalElementsLayout->removeWidget(m_history);
260 m_mainWidgetLayout->removeWidget(m_history);
261 m_mainWidgetLayout->removeWidget(m_commonColors);
262
263 if (historyEnabled) {
264 if (historyOrientation == Qt::Vertical) {
266 }
267 else {
268 m_mainWidgetLayout->addWidget(m_history);
269 }
270 m_history->show();
271 }
272 else {
273 m_history->hide();
274 }
275
277 Qt::Orientation commonColorsOrientation = cfg.get(WGConfig::commonColors.orientation);
278
279 if (commonColorsEnabled) {
280 if (commonColorsOrientation == Qt::Vertical) {
282 }
283 else {
285 }
286 m_commonColors->show();
287 }
288 else {
289 m_commonColors->hide();
290 }
291
292 bool shadeSelectorEnabled = cfg.get(WGConfig::minimalShadeSelectorEnabled);
293 if (shadeSelectorEnabled) {
294 m_shadeSelector->show();
295 }
296 else {
297 m_shadeSelector->hide();
298 }
299
300}
const GenericSetting< bool > colorHistoryEnabled
Definition WGConfig.cpp:238
const ColorPatches commonColors
Definition WGConfig.cpp:221
const GenericSetting< bool > minimalShadeSelectorEnabled
Definition WGConfig.cpp:247
const GenericSetting< bool > commonColorsEnabled
Definition WGConfig.cpp:240
const ColorPatches colorHistory
Definition WGConfig.cpp:213

References WGConfig::colorHistory, WGConfig::colorHistoryEnabled, WGConfig::commonColors, WGConfig::commonColorsEnabled, m_commonColors, m_history, m_mainWidgetLayout, m_shadeSelector, m_verticalElementsLayout, and WGConfig::minimalShadeSelectorEnabled.

Member Data Documentation

◆ m_actionManager

WGActionManager* WGColorSelectorDock::m_actionManager {0}
private

Definition at line 99 of file WGColorSelectorDock.h.

99{0};

◆ m_canvas

QPointer<KisCanvas2> WGColorSelectorDock::m_canvas
private

Definition at line 83 of file WGColorSelectorDock.h.

◆ m_colorChangeCompressor

KisSignalCompressor* WGColorSelectorDock::m_colorChangeCompressor
private

Definition at line 92 of file WGColorSelectorDock.h.

◆ m_colorHistoryFromDocument

bool WGColorSelectorDock::m_colorHistoryFromDocument {false}
private

Definition at line 96 of file WGColorSelectorDock.h.

96{false};

◆ m_colorModelBG

KisVisualColorModelSP WGColorSelectorDock::m_colorModelBG
private

Definition at line 108 of file WGColorSelectorDock.h.

◆ m_colorModelFG

KisVisualColorModelSP WGColorSelectorDock::m_colorModelFG
private

Definition at line 107 of file WGColorSelectorDock.h.

◆ m_colorTooltip

WGColorPreviewToolTip* WGColorSelectorDock::m_colorTooltip {0}
private

Definition at line 100 of file WGColorSelectorDock.h.

100{0};

◆ m_commonColors

WGColorPatches* WGColorSelectorDock::m_commonColors {0}
private

Definition at line 103 of file WGColorSelectorDock.h.

103{0};

◆ m_commonColorSet

WGCommonColorSet* WGColorSelectorDock::m_commonColorSet {0}
private

Definition at line 98 of file WGColorSelectorDock.h.

98{0};

◆ m_configButton

QToolButton* WGColorSelectorDock::m_configButton {0}
private

Definition at line 106 of file WGColorSelectorDock.h.

106{0};

◆ m_CSSource

ColorSpaceSource WGColorSelectorDock::m_CSSource {LayerColorSpace}
private

Definition at line 110 of file WGColorSelectorDock.h.

◆ m_customCS

const KoColorSpace* WGColorSelectorDock::m_customCS {0}
private

Definition at line 109 of file WGColorSelectorDock.h.

109{0};

◆ m_displayConfig

WGSelectorDisplayConfigSP WGColorSelectorDock::m_displayConfig
private

Definition at line 84 of file WGColorSelectorDock.h.

◆ m_documentColorHistoryModel

KisUniqueColorSet* WGColorSelectorDock::m_documentColorHistoryModel {0}
private

Definition at line 94 of file WGColorSelectorDock.h.

94{0};

◆ m_fallbackColorHistoryModel

std::unique_ptr<KisUniqueColorSet> WGColorSelectorDock::m_fallbackColorHistoryModel
private

Definition at line 95 of file WGColorSelectorDock.h.

◆ m_gamutToolbar

KisGamutMaskToolbar* WGColorSelectorDock::m_gamutToolbar
private

Definition at line 97 of file WGColorSelectorDock.h.

◆ m_globalColorHistoryModel

KisUniqueColorSet* WGColorSelectorDock::m_globalColorHistoryModel {0}
private

Definition at line 93 of file WGColorSelectorDock.h.

93{0};

◆ m_history

WGColorPatches* WGColorSelectorDock::m_history {0}
private

Definition at line 102 of file WGColorSelectorDock.h.

102{0};

◆ m_mainWidget

QWidget* WGColorSelectorDock::m_mainWidget
private

Definition at line 114 of file WGColorSelectorDock.h.

◆ m_mainWidgetLayout

QBoxLayout* WGColorSelectorDock::m_mainWidgetLayout {0}
private

Definition at line 86 of file WGColorSelectorDock.h.

86{0};

◆ m_pendingBgUpdate

bool WGColorSelectorDock::m_pendingBgUpdate {false}
private

Definition at line 112 of file WGColorSelectorDock.h.

112{false};

◆ m_pendingFgUpdate

bool WGColorSelectorDock::m_pendingFgUpdate {false}
private

Definition at line 111 of file WGColorSelectorDock.h.

111{false};

◆ m_quickSettingAction

QWidgetAction* WGColorSelectorDock::m_quickSettingAction {0}
private

Definition at line 104 of file WGColorSelectorDock.h.

104{0};

◆ m_quickSettings

WGQuickSettingsWidget* WGColorSelectorDock::m_quickSettings {0}
private

Definition at line 105 of file WGColorSelectorDock.h.

105{0};

◆ m_selector

KisVisualColorSelector* WGColorSelectorDock::m_selector {0}
private

Definition at line 90 of file WGColorSelectorDock.h.

90{0};

◆ m_selectorAreaLayout

QBoxLayout* WGColorSelectorDock::m_selectorAreaLayout {0}
private

Definition at line 87 of file WGColorSelectorDock.h.

87{0};

◆ m_shadeSelector

WGShadeSelector* WGColorSelectorDock::m_shadeSelector {0}
private

Definition at line 101 of file WGColorSelectorDock.h.

101{0};

◆ m_toggle

KisColorSourceToggle* WGColorSelectorDock::m_toggle {0}
private

Definition at line 91 of file WGColorSelectorDock.h.

91{0};

◆ m_verticalElementsLayout

QBoxLayout* WGColorSelectorDock::m_verticalElementsLayout {0}
private

Definition at line 88 of file WGColorSelectorDock.h.

88{0};

The documentation for this class was generated from the following files: