Changeset View
Changeset View
Standalone View
Standalone View
libs/widgets/KisDlgInternalColorSelector.cpp
- This file was moved from libs/ui/dialogs/kis_dlg_internal_color_selector.cpp.
Context not available. | |||||
23 | #include <QPointer> | 23 | #include <QPointer> | ||
---|---|---|---|---|---|
24 | #include <QCompleter> | 24 | #include <QCompleter> | ||
25 | 25 | | |||
26 | #include <functional> | ||||
27 | | ||||
28 | #include <KConfigGroup> | ||||
29 | | ||||
26 | #include "KoColorSpaceRegistry.h" | 30 | #include "KoColorSpaceRegistry.h" | ||
27 | #include <KoColorSet.h> | 31 | #include <KoColorSet.h> | ||
28 | #include <KisPaletteModel.h> | 32 | #include <KisPaletteModel.h> | ||
Context not available. | |||||
32 | #include <KoResourceServer.h> | 36 | #include <KoResourceServer.h> | ||
33 | 37 | | |||
34 | #include "kis_signal_compressor.h" | 38 | #include "kis_signal_compressor.h" | ||
35 | #include "KisViewManager.h" | | |||
36 | #include "KoColorDisplayRendererInterface.h" | 39 | #include "KoColorDisplayRendererInterface.h" | ||
37 | 40 | | |||
38 | #include "kis_spinbox_color_selector.h" | 41 | #include "kis_spinbox_color_selector.h" | ||
39 | 42 | | |||
40 | #include "kis_dlg_internal_color_selector.h" | 43 | #include "KisDlgInternalColorSelector.h" | ||
41 | #include "ui_wdgdlginternalcolorselector.h" | 44 | #include "ui_WdgDlgInternalColorSelector.h" | ||
42 | #include "kis_config.h" | | |||
43 | #include "kis_config_notifier.h" | 45 | #include "kis_config_notifier.h" | ||
44 | #include "kis_color_input.h" | 46 | #include "kis_color_input.h" | ||
45 | #include "kis_icon_utils.h" | 47 | #include "kis_icon_utils.h" | ||
46 | #include "squeezedcombobox.h" | 48 | #include "squeezedcombobox.h" | ||
47 | 49 | | |||
50 | std::function<KisScreenColorPickerBase *(QWidget *)> KisDlgInternalColorSelector::s_screenColorPickerFactory = 0; | ||||
51 | | ||||
48 | struct KisDlgInternalColorSelector::Private | 52 | struct KisDlgInternalColorSelector::Private | ||
49 | { | 53 | { | ||
50 | bool allowUpdates = true; | 54 | bool allowUpdates = true; | ||
Context not available. | |||||
59 | KisHexColorInput *hexColorInput = 0; | 63 | KisHexColorInput *hexColorInput = 0; | ||
60 | KisPaletteModel *paletteModel = 0; | 64 | KisPaletteModel *paletteModel = 0; | ||
61 | KisColorsetChooser *colorSetChooser = 0; | 65 | KisColorsetChooser *colorSetChooser = 0; | ||
66 | KisScreenColorPickerBase *screenColorPicker = 0; | ||||
62 | }; | 67 | }; | ||
63 | 68 | | |||
64 | KisDlgInternalColorSelector::KisDlgInternalColorSelector(QWidget *parent, KoColor color, Config config, const QString &caption, const KoColorDisplayRendererInterface *displayRenderer) | 69 | KisDlgInternalColorSelector::KisDlgInternalColorSelector(QWidget *parent, KoColor color, Config config, const QString &caption, const KoColorDisplayRendererInterface *displayRenderer) | ||
Context not available. | |||||
88 | } else { | 93 | } else { | ||
89 | m_ui->visualSelector->hide(); | 94 | m_ui->visualSelector->hide(); | ||
90 | } | 95 | } | ||
91 | if (config.screenColorPicker) { | | |||
92 | connect(m_ui->screenColorPicker, SIGNAL(sigNewColorPicked(KoColor)),this, SLOT(slotColorUpdated(KoColor))); | | |||
93 | } else { | | |||
94 | m_ui->screenColorPicker->hide(); | | |||
95 | } | | |||
96 | 96 | | |||
97 | if (!m_d->paletteModel) { | 97 | if (!m_d->paletteModel) { | ||
98 | m_d->paletteModel = new KisPaletteModel(this); | 98 | m_d->paletteModel = new KisPaletteModel(this); | ||
99 | m_ui->paletteBox->setPaletteModel(m_d->paletteModel); | 99 | m_ui->paletteBox->setPaletteModel(m_d->paletteModel); | ||
100 | } | 100 | } | ||
101 | m_ui->paletteList->setIcon(KisIconUtils::loadIcon("hi16-palette_library")); | 101 | m_ui->bnColorsetChooser->setIcon(KisIconUtils::loadIcon("hi16-palette_library")); | ||
102 | // For some bizare reason, the modal dialog doesn't like having the colorset set, so let's not. | 102 | // For some bizare reason, the modal dialog doesn't like having the colorset set, so let's not. | ||
103 | if (config.paletteBox) { | 103 | if (config.paletteBox) { | ||
104 | //TODO: Add disable signal as well. Might be not necessary...? | 104 | //TODO: Add disable signal as well. Might be not necessary...? | ||
105 | KisConfig cfg; | 105 | KConfigGroup cfg(KSharedConfig::openConfig()->group("")); | ||
106 | QString paletteName = cfg.readEntry("internal_selector_active_color_set", QString()); | 106 | QString paletteName = cfg.readEntry("internal_selector_active_color_set", QString()); | ||
107 | KoResourceServer<KoColorSet>* rServer = KoResourceServerProvider::instance()->paletteServer(); | 107 | KoResourceServer<KoColorSet>* rServer = KoResourceServerProvider::instance()->paletteServer(); | ||
108 | KoColorSet *savedPal = rServer->resourceByName(paletteName); | 108 | KoColorSet *savedPal = rServer->resourceByName(paletteName); | ||
Context not available. | |||||
124 | m_d->colorSetChooser = new KisColorsetChooser(this); | 124 | m_d->colorSetChooser = new KisColorsetChooser(this); | ||
125 | connect(m_d->colorSetChooser, SIGNAL(paletteSelected(KoColorSet*)), this, SLOT(slotChangePalette(KoColorSet*))); | 125 | connect(m_d->colorSetChooser, SIGNAL(paletteSelected(KoColorSet*)), this, SLOT(slotChangePalette(KoColorSet*))); | ||
126 | 126 | | |||
127 | m_ui->paletteList->setPopupWidget(m_d->colorSetChooser); | 127 | m_ui->bnColorsetChooser->setPopupWidget(m_d->colorSetChooser); | ||
128 | 128 | | |||
129 | } else { | 129 | } else { | ||
130 | m_ui->paletteBox->setEnabled(false); | 130 | m_ui->paletteBox->setEnabled(false); | ||
131 | m_ui->cmbNameList->setEnabled(false); | 131 | m_ui->cmbNameList->setEnabled(false); | ||
132 | m_ui->paletteList->setEnabled(false); | 132 | m_ui->bnColorsetChooser->setEnabled(false); | ||
133 | } | 133 | } | ||
134 | 134 | | |||
135 | if (config.prevNextButtons) { | 135 | if (config.prevNextButtons) { | ||
Context not available. | |||||
152 | m_d->hexColorInput->setToolTip(i18n("This is a hexcode input, for webcolors. It can only get colors in the sRGB space.")); | 152 | m_d->hexColorInput->setToolTip(i18n("This is a hexcode input, for webcolors. It can only get colors in the sRGB space.")); | ||
153 | } | 153 | } | ||
154 | 154 | | |||
155 | // screen color picker is in kritaui, so a dependency inversion is used to get it | ||||
156 | m_ui->screenColorPickerWidget->setLayout(new QHBoxLayout(m_ui->screenColorPickerWidget)); | ||||
157 | if (s_screenColorPickerFactory) { | ||||
158 | m_d->screenColorPicker = s_screenColorPickerFactory(m_ui->screenColorPickerWidget); | ||||
159 | m_ui->screenColorPickerWidget->layout()->addWidget(m_d->screenColorPicker); | ||||
160 | if (config.screenColorPicker) { | ||||
161 | connect(m_d->screenColorPicker, SIGNAL(sigNewColorPicked(KoColor)),this, SLOT(slotColorUpdated(KoColor))); | ||||
162 | } else { | ||||
163 | m_d->screenColorPicker->hide(); | ||||
164 | } | ||||
165 | } | ||||
166 | | ||||
155 | connect(this, SIGNAL(signalForegroundColorChosen(KoColor)), this, SLOT(slotLockSelector())); | 167 | connect(this, SIGNAL(signalForegroundColorChosen(KoColor)), this, SLOT(slotLockSelector())); | ||
156 | m_d->compressColorChanges = new KisSignalCompressor(100 /* ms */, KisSignalCompressor::POSTPONE, this); | 168 | m_d->compressColorChanges = new KisSignalCompressor(100 /* ms */, KisSignalCompressor::POSTPONE, this); | ||
157 | connect(m_d->compressColorChanges, SIGNAL(timeout()), this, SLOT(endUpdateWithNewColor())); | 169 | connect(m_d->compressColorChanges, SIGNAL(timeout()), this, SLOT(endUpdateWithNewColor())); | ||
Context not available. | |||||
282 | m_d->compressColorChanges->start(); | 294 | m_d->compressColorChanges->start(); | ||
283 | } | 295 | } | ||
284 | 296 | | |||
285 | m_ui->screenColorPicker->updateIcons(); | 297 | if (m_d->screenColorPicker) { | ||
298 | m_d->screenColorPicker->updateIcons(); | ||||
299 | } | ||||
286 | } | 300 | } | ||
287 | 301 | | |||
288 | 302 | | |||
Context not available. | |||||
299 | void KisDlgInternalColorSelector::slotFinishUp() | 313 | void KisDlgInternalColorSelector::slotFinishUp() | ||
300 | { | 314 | { | ||
301 | setPreviousColor(m_d->currentColor); | 315 | setPreviousColor(m_d->currentColor); | ||
302 | KisConfig cfg; | 316 | KConfigGroup cfg(KSharedConfig::openConfig()->group("")); | ||
303 | if (m_d->paletteModel) { | 317 | if (m_d->paletteModel) { | ||
304 | if (m_d->paletteModel->colorSet()) { | 318 | if (m_d->paletteModel->colorSet()) { | ||
305 | cfg.writeEntry("internal_selector_active_color_set", m_d->paletteModel->colorSet()->name()); | 319 | cfg.writeEntry("internal_selector_active_color_set", m_d->paletteModel->colorSet()->name()); | ||
Context not available. |