Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Make color sampler preview style configurable
Carsten Hartenfelsb8b20b21f162
diff --git a/libs/global/kis_config_notifier.cpp b/libs/global/kis_config_notifier.cppindex a5fc9f3738..67b0eb5260 100644--- a/libs/global/kis_config_notifier.cpp+++ b/libs/global/kis_config_notifier.cpp@@ -60,6 +60,11 @@ void KisConfigNotifier::notifyTouchPaintingChanged()Q_EMIT touchPaintingChanged();}+void KisConfigNotifier::notifyColorSamplerPreviewStyleChanged()+{+ Q_EMIT sigColorSamplerPreviewStyleChanged();+}+void KisConfigNotifier::notifyColorThemeChanged(const QString &filename){Q_EMIT signalColorThemeChanged(filename);diff --git a/libs/global/kis_config_notifier.h b/libs/global/kis_config_notifier.hindex e4100274a9..39e5291c52 100644--- a/libs/global/kis_config_notifier.h+++ b/libs/global/kis_config_notifier.h@@ -37,6 +37,7 @@ public:void notifyPixelGridModeChanged();void notifyColorHistoryModeChanged();void notifyTouchPaintingChanged();+ void notifyColorSamplerPreviewStyleChanged();void notifyColorThemeChanged(const QString &filename);void notifyLongPressChanged(bool enabled);@@ -50,6 +51,7 @@ Q_SIGNALS:void pixelGridModeChanged();void colorHistoryModeChanged();void touchPaintingChanged();+ void sigColorSamplerPreviewStyleChanged();void signalColorThemeChanged(const QString &filename);void sigLongPressChanged(bool enabled);private:diff --git a/libs/ui/dialogs/kis_dlg_preferences.cc b/libs/ui/dialogs/kis_dlg_preferences.ccindex 1d9784e595..5b61ec2871 100644--- a/libs/ui/dialogs/kis_dlg_preferences.cc+++ b/libs/ui/dialogs/kis_dlg_preferences.cc@@ -268,6 +268,11 @@ GeneralTab::GeneralTab(QWidget *_parent, const char *_name)eraserCursorColor.fromQColor(cfg.getEraserCursorMainColor());eraserCursorColorButton->setColor(eraserCursorColor);+ // Color sampler++ setColorSamplerPreviewStyleItems(m_cmbColorSamplerPreviewStyle);+ setColorSamplerPreviewStyleIndexByValue(m_cmbColorSamplerPreviewStyle, cfg.colorSamplerPreviewStyle());+//// Window Tab//@@ -706,6 +711,7 @@ void GeneralTab::setDefault()m_chkSeparateEraserCursor->setChecked(cfg.readEntry<bool>("separateEraserCursor", false));m_cmbEraserCursorShape->setCurrentIndex(cfg.eraserCursorStyle(true));m_cmbEraserOutlineShape->setCurrentIndex(cfg.eraserOutlineStyle(true));+ setColorSamplerPreviewStyleIndexByValue(m_cmbColorSamplerPreviewStyle, cfg.colorSamplerPreviewStyle(true));chkShowRootLayer->setChecked(cfg.showRootLayer(true));m_autosaveCheckBox->setChecked(cfg.autoSaveInterval(true) > 0);@@ -833,6 +839,11 @@ OutlineStyle GeneralTab::eraserOutlineStyle()return (OutlineStyle)m_cmbEraserOutlineShape->currentIndex();}+KisConfig::ColorSamplerPreviewStyle GeneralTab::colorSamplerPreviewStyle() const+{+ return getColorSamplerPreviewStyleValue(m_cmbColorSamplerPreviewStyle);+}+KisConfig::SessionOnStartup GeneralTab::sessionOnStartup() const{return (KisConfig::SessionOnStartup)cmbStartupSession->currentIndex();@@ -974,6 +985,27 @@ int GeneralTab::forcedFontDpi()return chkForcedFontDPI->isChecked() ? intForcedFontDPI->value() : -1;}+void GeneralTab::setColorSamplerPreviewStyleItems(QComboBox *cmb)+{+ // Order is synchronized with KisConfig::ColorSamplerPreviewStyle.+ cmb->addItems({+ i18nc("Preview option for no color sampler", "None"),+ i18nc("Preview option for a circular/ring-shaped color sampler", "Circle"),+ i18nc("Preview option for a rectangular color sampler left of the cursor", "Rectangle Left"),+ i18nc("Preview option for a rectangular color sampler right of the cursor", "Rectangle Right"),+ });+}++void GeneralTab::setColorSamplerPreviewStyleIndexByValue(QComboBox *cmb, KisConfig::ColorSamplerPreviewStyle style)+{+ cmb->setCurrentIndex(int(style));+}++KisConfig::ColorSamplerPreviewStyle GeneralTab::getColorSamplerPreviewStyleValue(const QComboBox *cmb)+{+ return KisConfig::ColorSamplerPreviewStyle(cmb->currentIndex());+}+bool GeneralTab::renameMergedLayers(){return chkRenameMergedLayers->isChecked();@@ -2579,6 +2611,7 @@ bool KisDlgPreferences::editPreferences()cfg.setSeparateEraserCursor(m_general->m_chkSeparateEraserCursor->isChecked());cfg.setEraserCursorStyle(m_general->eraserCursorStyle());cfg.setEraserOutlineStyle(m_general->eraserOutlineStyle());+ cfg.setColorSamplerPreviewStyle(m_general->colorSamplerPreviewStyle());cfg.setShowRootLayer(m_general->showRootLayer());cfg.setShowOutlineWhilePainting(m_general->showOutlineWhilePainting());cfg.setForceAlwaysFullSizedOutline(!m_general->m_changeBrushOutline->isChecked());diff --git a/libs/ui/dialogs/kis_dlg_preferences.h b/libs/ui/dialogs/kis_dlg_preferences.hindex f5c2f921c9..585803aead 100644--- a/libs/ui/dialogs/kis_dlg_preferences.h+++ b/libs/ui/dialogs/kis_dlg_preferences.h@@ -54,7 +54,7 @@ public:}};-class GeneralTab : public WdgGeneralSettings+class KRITAUI_EXPORT GeneralTab : public WdgGeneralSettings{Q_OBJECT@@ -66,6 +66,7 @@ public:OutlineStyle outlineStyle();CursorStyle eraserCursorStyle();OutlineStyle eraserOutlineStyle();+ KisConfig::ColorSamplerPreviewStyle colorSamplerPreviewStyle() const;KisConfig::SessionOnStartup sessionOnStartup() const;bool saveSessionOnQuit() const;@@ -104,6 +105,10 @@ public:QString exportMimeType();int forcedFontDpi();+ static void setColorSamplerPreviewStyleItems(QComboBox *cmb);+ static void setColorSamplerPreviewStyleIndexByValue(QComboBox *cmb, KisConfig::ColorSamplerPreviewStyle style);+ static KisConfig::ColorSamplerPreviewStyle getColorSamplerPreviewStyleValue(const QComboBox *cmb);+private Q_SLOTS:void getBackgroundImage();void clearBackgroundImage();diff --git a/libs/ui/forms/wdggeneralsettings.ui b/libs/ui/forms/wdggeneralsettings.uiindex 7758b9412e..1305c0c248 100644--- a/libs/ui/forms/wdggeneralsettings.ui+++ b/libs/ui/forms/wdggeneralsettings.ui@@ -860,7 +860,7 @@</layout></widget></item>- <item row="4" column="0" colspan="2">+ <item row="6" column="0" colspan="2"><spacer name="verticalSpacer_3"><property name="orientation"><enum>Qt::Vertical</enum>@@ -893,6 +893,16 @@</property></widget></item>+ <item row="4" column="0">+ <widget class="QLabel" name="m_lblColorSamplerPreviewStyle">+ <property name="text">+ <string>Color Sampler Preview:</string>+ </property>+ </widget>+ </item>+ <item row="4" column="1">+ <widget class="QComboBox" name="m_cmbColorSamplerPreviewStyle"/>+ </item></layout></widget><widget class="QWidget" name="Tools">diff --git a/libs/ui/kis_config.cc b/libs/ui/kis_config.ccindex ea05e50492..20f92b7d96 100644--- a/libs/ui/kis_config.cc+++ b/libs/ui/kis_config.cc@@ -520,6 +520,23 @@ void KisConfig::setEraserOutlineStyle(OutlineStyle style)m_cfg.writeEntry("eraserOutlineStyle", (int)style);}+KisConfig::ColorSamplerPreviewStyle KisConfig::colorSamplerPreviewStyle(bool defaultValue) const+{+ if (!defaultValue) {+ int style = m_cfg.readEntry("colorSamplerPreviewStyle", int(ColorSamplerPreviewStyle::Circle));+ if (style >= 0 && style < int(ColorSamplerPreviewStyle::Count)) {+ return ColorSamplerPreviewStyle(style);+ }+ }+ return ColorSamplerPreviewStyle::Circle;+}++void KisConfig::setColorSamplerPreviewStyle(ColorSamplerPreviewStyle style)+{+ m_cfg.writeEntry("colorSamplerPreviewStyle", int(style));+ KisConfigNotifier::instance()->notifyColorSamplerPreviewStyleChanged();+}+bool KisConfig::useDirtyPresets(bool defaultValue) const{return (defaultValue ? false : m_cfg.readEntry("useDirtyPresets", true));diff --git a/libs/ui/kis_config.h b/libs/ui/kis_config.hindex fa74b459db..8cb31c3e95 100644--- a/libs/ui/kis_config.h+++ b/libs/ui/kis_config.h@@ -135,6 +135,17 @@ public:OutlineStyle eraserOutlineStyle(bool defaultValue = false) const;void setEraserOutlineStyle(OutlineStyle style);+ enum class ColorSamplerPreviewStyle {+ None,+ Circle,+ RectangleLeft,+ RectangleRight,+ Count,+ };++ ColorSamplerPreviewStyle colorSamplerPreviewStyle(bool defaultValue = false) const;+ void setColorSamplerPreviewStyle(ColorSamplerPreviewStyle style);+/*** Controls if the canvas should have a separate color managed surface.* Even though the surface can be created on any platform the properdiff --git a/libs/ui/tool/KisAsyncColorSamplerHelper.cpp b/libs/ui/tool/KisAsyncColorSamplerHelper.cppindex 341f6a9598..6b1538a3bc 100644--- a/libs/ui/tool/KisAsyncColorSamplerHelper.cpp+++ b/libs/ui/tool/KisAsyncColorSamplerHelper.cpp@@ -31,12 +31,20 @@namespace {-QRectF colorPreviewDocRectImpl(const QPointF &outlineDocPoint, const KoViewConverter *converter)+bool colorPreviewHasForegroundComparison(KisConfig::ColorSamplerPreviewStyle style){- constexpr qreal SIZE = 200.0;- const QRectF colorPreviewViewRect = QRectF(-SIZE / 2.0, -SIZE / 2.0, SIZE, SIZE);- const QRectF colorPreviewDocumentRect = converter->viewToDocument(colorPreviewViewRect);- return colorPreviewDocumentRect.translated(outlineDocPoint);+ // Not all styles show the foreground color when sampling is pending. It+ // would probably be cleaner if that were its own action instead of being+ // tied to the color sampler activation and show the comparison *on* the+ // cursor instead of it being off to the side, but it'd take some effort+ // to implement the separation of that.+ switch (style) {+ case KisConfig::ColorSamplerPreviewStyle::RectangleLeft:+ case KisConfig::ColorSamplerPreviewStyle::RectangleRight:+ return true;+ default:+ return false;+ }}QColor colorWithAlpha(QColor color, int alpha)@@ -48,6 +56,8 @@ QColor colorWithAlpha(QColor color, int alpha)struct KisAsyncColorSamplerHelper::Private{+ static constexpr qreal PREVIEW_RECT_SIZE = 48.0;+Private(KisCanvas2 *_canvas): canvas(_canvas){}@@ -60,7 +70,7 @@ struct KisAsyncColorSamplerHelper::Privatebool isActive {false};bool showPreview {false};- bool showComparison {false};+ bool haveSample {false};KisStrokeId strokeId;typedef KisSignalCompressorWithParam<QPointF> SamplingCompressor;@@ -68,6 +78,7 @@ struct KisAsyncColorSamplerHelper::PrivateQTimer activationDelayTimer;+ KisConfig::ColorSamplerPreviewStyle style = KisConfig::ColorSamplerPreviewStyle::Circle;QRectF previewDocRect;QColor currentColor;@@ -75,6 +86,7 @@ struct KisAsyncColorSamplerHelper::PrivateQPixmap cache;qreal cacheRotation = 0.0;+ bool cacheMirror = false;KisStrokesFacade *strokesFacade() const {return canvas->image().data();@@ -84,6 +96,60 @@ struct KisAsyncColorSamplerHelper::Privatereturn *canvas->imageView()->viewConverter();}+ QRectF colorPreviewRectForRectangle(bool left)+ {+ constexpr qreal OFFSET = 32.0;+ constexpr qreal SIZE = PREVIEW_RECT_SIZE;++ bool mirrored = canvas->xAxisMirrored();+ if (mirrored) {+ left = !left;+ }++ qreal width = haveSample ? SIZE * 2.0 : SIZE;+ qreal x = left ? -(OFFSET + width) : OFFSET;+ qreal y = canvas->yAxisMirrored() ? -(OFFSET + SIZE) : OFFSET;+ QRectF rect(x, y, width, SIZE);++ qreal canvasRotationAngle = canvas->rotationAngle();+ if (!qFuzzyIsNull(canvasRotationAngle)) {+ QTransform tf;+ tf.rotate(mirrored ? canvasRotationAngle : -canvasRotationAngle);+ rect = tf.mapRect(rect);+ }++ return rect;+ }++ QRectF colorPreviewRectForCircle()+ {+ constexpr qreal SIZE = 200.0;+ return QRectF(-SIZE / 2.0, -SIZE / 2.0, SIZE, SIZE);+ }++ QRectF colorPreviewDocRect(const QPointF &outlineDocPoint)+ {+ QRectF colorPreviewViewRect;+ switch (style) {+ case KisConfig::ColorSamplerPreviewStyle::None:+ return QRectF();+ case KisConfig::ColorSamplerPreviewStyle::RectangleLeft:+ colorPreviewViewRect = colorPreviewRectForRectangle(true);+ break;+ case KisConfig::ColorSamplerPreviewStyle::RectangleRight:+ colorPreviewViewRect = colorPreviewRectForRectangle(false);+ break;+ default:+ if (!haveSample) {+ return QRectF();+ }+ colorPreviewViewRect = colorPreviewRectForCircle();+ break;+ }++ const QRectF colorPreviewDocumentRect = converter().viewToDocument(colorPreviewViewRect);+ return colorPreviewDocumentRect.translated(outlineDocPoint);+ }};KisAsyncColorSamplerHelper::KisAsyncColorSamplerHelper(KisCanvas2 *canvas)@@ -121,9 +187,13 @@ void KisAsyncColorSamplerHelper::activate(bool sampleCurrentLayer, bool pickFgCoKoCanvasResource::BackgroundColor;m_d->sampleCurrentLayer = sampleCurrentLayer;- m_d->showComparison = false;+ m_d->haveSample = false;- m_d->activationDelayTimer.start();+ if (colorPreviewHasForegroundComparison(m_d->style)) {+ m_d->activationDelayTimer.start();+ } else {+ activatePreview();+ }}void KisAsyncColorSamplerHelper::activateDelayedPreview()@@ -132,6 +202,13 @@ void KisAsyncColorSamplerHelper::activateDelayedPreview()// picking if the user is quickif (!m_d->isActive) return;+ activatePreview();++ Q_EMIT sigRequestUpdateOutline();+}++void KisAsyncColorSamplerHelper::activatePreview()+{m_d->showPreview = true;const KoColor currentColor =@@ -143,8 +220,6 @@ void KisAsyncColorSamplerHelper::activateDelayedPreview()m_d->cache = QPixmap();updateCursor(m_d->sampleCurrentLayer, m_d->sampleResourceId == KoCanvasResource::ForegroundColor);-- Q_EMIT sigRequestUpdateOutline();}void KisAsyncColorSamplerHelper::updateCursor(bool sampleCurrentLayer, bool pickFgColor)@@ -192,7 +267,7 @@ void KisAsyncColorSamplerHelper::deactivate()m_d->activationDelayTimer.stop();m_d->showPreview = false;- m_d->showComparison = false;+ m_d->haveSample = false;m_d->previewDocRect = QRectF();m_d->currentColor = QColor();@@ -238,7 +313,9 @@ QRectF KisAsyncColorSamplerHelper::colorPreviewDocRect(const QPointF &docPoint){if (!m_d->showPreview) return QRectF();- m_d->previewDocRect = colorPreviewDocRectImpl(docPoint, &m_d->converter());+ KisConfig cfg(true);+ m_d->style = cfg.colorSamplerPreviewStyle();+ m_d->previewDocRect = m_d->colorPreviewDocRect(docPoint);return m_d->previewDocRect;}@@ -249,6 +326,25 @@ void KisAsyncColorSamplerHelper::paint(QPainter &gc, const KoViewConverter &conv}QRectF viewRectF = converter.documentToView(m_d->previewDocRect);+ QColor currentColor = colorWithAlpha(m_d->currentColor, OPACITY_OPAQUE_U8);+ QColor baseColor = m_d->haveSample ? colorWithAlpha(m_d->baseColor, OPACITY_OPAQUE_U8) : currentColor;++ switch (m_d->style) {+ case KisConfig::ColorSamplerPreviewStyle::RectangleLeft:+ case KisConfig::ColorSamplerPreviewStyle::RectangleRight:+ paintRectangle(gc, viewRectF, currentColor, baseColor);+ break;+ default:+ paintCircle(gc, viewRectF, currentColor, baseColor);+ break;+ }+}++void KisAsyncColorSamplerHelper::paintRectangle(QPainter &gc,+ const QRectF &viewRectF,+ const QColor ¤tColor,+ const QColor &baseColor)+{qreal dpr = gc.device()->devicePixelRatioF();QSizeF cacheSizeF = viewRectF.size() * dpr;QSize cacheSize(qCeil(cacheSizeF.width()), qCeil(cacheSizeF.height()));@@ -258,15 +354,66 @@ void KisAsyncColorSamplerHelper::paint(QPainter &gc, const KoViewConverter &convm_d->cache.fill(Qt::transparent);}- QColor currentColor = colorWithAlpha(m_d->currentColor, OPACITY_OPAQUE_U8);- QColor baseColor = m_d->showComparison ? colorWithAlpha(m_d->baseColor, OPACITY_OPAQUE_U8) : currentColor;- bool needsDualColor = currentColor != baseColor;+ qreal canvasRotationAngle = m_d->canvas->rotationAngle();+ bool canvasMirror = m_d->canvas->xAxisMirrored();+ if (needsNewCache || !qFuzzyCompare(canvasRotationAngle, m_d->cacheRotation) || canvasMirror != m_d->cacheMirror) {+ m_d->cacheRotation = canvasRotationAngle;+ m_d->cacheMirror = canvasMirror;++ QPainter cachePainter(&m_d->cache);+ cachePainter.setRenderHint(QPainter::Antialiasing);++ qreal size = Private::PREVIEW_RECT_SIZE * dpr;+ QRectF rect(0.0, 0.0, m_d->haveSample ? size * 2.0 : size, size);+ rect.moveTopLeft(-rect.center());++ QTransform tf;+ QPointF offset = QRectF(m_d->cache.rect()).center();+ tf.translate(offset.x(), offset.y());+ tf.rotate(canvasMirror ? canvasRotationAngle : -canvasRotationAngle);+ cachePainter.setTransform(tf);++ if (m_d->haveSample) {+ qreal centerX = rect.center().x();+ QRectF currentRect(rect.topLeft(), QPointF(centerX + 1.0, rect.bottom()));+ QRectF baseRect(QPointF(centerX, rect.top()), rect.bottomRight());+ if (m_d->canvas->xAxisMirrored()) {+ std::swap(currentRect, baseRect);+ }+ cachePainter.fillRect(currentRect, currentColor);+ cachePainter.fillRect(baseRect, baseColor);+ } else {+ cachePainter.fillRect(rect, currentColor);+ }+ }++ gc.drawPixmap(viewRectF.toRect(), m_d->cache);+}++void KisAsyncColorSamplerHelper::paintCircle(QPainter &gc,+ const QRectF &viewRectF,+ const QColor ¤tColor,+ const QColor &baseColor)+{+ if (!m_d->haveSample) {+ return;+ }++ qreal dpr = gc.device()->devicePixelRatioF();+ QSizeF cacheSizeF = viewRectF.size() * dpr;+ QSize cacheSize(qCeil(cacheSizeF.width()), qCeil(cacheSizeF.height()));+ bool needsNewCache = m_d->cache.isNull() || m_d->cache.size() != cacheSize;+ if (needsNewCache) {+ m_d->cache = QPixmap(cacheSize);+ m_d->cache.fill(Qt::transparent);+ }qreal canvasRotationAngle = m_d->canvas->rotationAngle();if (m_d->canvas->xAxisMirrored()) {canvasRotationAngle = -canvasRotationAngle;}+ bool needsDualColor = currentColor != baseColor;if (needsNewCache || (needsDualColor && !qFuzzyCompare(m_d->cacheRotation, canvasRotationAngle))) {m_d->cacheRotation = canvasRotationAngle;@@ -387,8 +534,8 @@ void KisAsyncColorSamplerHelper::slotColorSamplingFinished(const KoColor &rawColconst QColor previewColor = m_d->canvas->displayColorConverter()->toQColor(color);- if (!m_d->showComparison || m_d->currentColor != previewColor) {- m_d->showComparison = true;+ if (!m_d->haveSample || m_d->currentColor != previewColor) {+ m_d->haveSample = true;m_d->currentColor = previewColor;m_d->cache = QPixmap();}diff --git a/libs/ui/tool/KisAsyncColorSamplerHelper.h b/libs/ui/tool/KisAsyncColorSamplerHelper.hindex c17d040ff8..71e2a133cd 100644--- a/libs/ui/tool/KisAsyncColorSamplerHelper.h+++ b/libs/ui/tool/KisAsyncColorSamplerHelper.h@@ -75,6 +75,10 @@ private Q_SLOTS:void slotColorSamplingFinished(const KoColor &rawColor);private:+ void activatePreview();+ void paintRectangle(QPainter &gc, const QRectF &viewRectF, const QColor ¤tColor, const QColor &baseColor);+ void paintCircle(QPainter &gc, const QRectF &viewRectF, const QColor ¤tColor, const QColor &baseColor);+struct Private;QScopedPointer<Private> m_d;};diff --git a/plugins/tools/basictools/kis_tool_colorsampler.cc b/plugins/tools/basictools/kis_tool_colorsampler.ccindex ab6271f9d4..027d827f09 100644--- a/plugins/tools/basictools/kis_tool_colorsampler.cc+++ b/plugins/tools/basictools/kis_tool_colorsampler.cc@@ -21,6 +21,10 @@#include "kis_display_color_converter.h"#include "kis_tool_utils.h"+#include <kis_config.h>+#include <kis_config_notifier.h>+#include <dialogs/kis_dlg_preferences.h>+#include <QSignalBlocker>namespace{@@ -97,6 +101,24 @@ void KisToolColorSampler::slotColorPickerSelectionFinished(const KoColor &color)}}+void KisToolColorSampler::slotSetPreviewStyleComboBoxFromConfig()+{+ if (m_optionsWidget) {+ QSignalBlocker blocker(m_optionsWidget->cmbPreviewStyle);+ GeneralTab::setColorSamplerPreviewStyleIndexByValue(m_optionsWidget->cmbPreviewStyle,+ KisConfig(true).colorSamplerPreviewStyle());+ }+}++void KisToolColorSampler::slotSetPreviewStyleConfigFromComboBox()+{+ if (m_optionsWidget) {+ KisConfig::ColorSamplerPreviewStyle style =+ GeneralTab::getColorSamplerPreviewStyleValue(m_optionsWidget->cmbPreviewStyle);+ KisConfig(false).setColorSamplerPreviewStyle(style);+ }+}+void KisToolColorSampler::paint(QPainter &gc, const KoViewConverter &converter){m_helper.paint(gc, converter);@@ -277,6 +299,16 @@ QWidget* KisToolColorSampler::createOptionWidget()specialSpacer->setFixedSize(0, 0);m_optionsWidget->layout()->addWidget(specialSpacer);+ GeneralTab::setColorSamplerPreviewStyleItems(m_optionsWidget->cmbPreviewStyle);+ connect(KisConfigNotifier::instance(),+ &KisConfigNotifier::sigColorSamplerPreviewStyleChanged,+ this,+ &KisToolColorSampler::slotSetPreviewStyleComboBoxFromConfig);+ connect(m_optionsWidget->cmbPreviewStyle,+ QOverload<int>::of(&QComboBox::activated),+ this,+ &KisToolColorSampler::slotSetPreviewStyleConfigFromComboBox);+// Initialize blend KisSliderSpinBoxm_optionsWidget->blend->setRange(0,100);KisSpinBoxI18nHelper::setText(m_optionsWidget->blend,@@ -329,6 +361,8 @@ void KisToolColorSampler::updateOptionWidget()m_optionsWidget->cbPalette->setChecked(m_config->addColorToCurrentPalette);m_optionsWidget->radius->setValue(m_config->radius);m_optionsWidget->blend->setValue(m_config->blend);++ slotSetPreviewStyleComboBoxFromConfig();}void KisToolColorSampler::slotSetUpdateColor(bool state)diff --git a/plugins/tools/basictools/kis_tool_colorsampler.h b/plugins/tools/basictools/kis_tool_colorsampler.hindex 415da5ede4..371dbf544f 100644--- a/plugins/tools/basictools/kis_tool_colorsampler.h+++ b/plugins/tools/basictools/kis_tool_colorsampler.h@@ -93,6 +93,9 @@ private Q_SLOTS:void slotColorPickerSelectedColor(const KoColor &color);void slotColorPickerSelectionFinished(const KoColor &color);+ void slotSetPreviewStyleComboBoxFromConfig();+ void slotSetPreviewStyleConfigFromComboBox();+private:void displaySampledColor(const KoColor &color);void updateOptionWidget();diff --git a/plugins/tools/basictools/wdgcolorsampler.ui b/plugins/tools/basictools/wdgcolorsampler.uiindex 5c5d9c6659..75983a9b71 100644--- a/plugins/tools/basictools/wdgcolorsampler.ui+++ b/plugins/tools/basictools/wdgcolorsampler.ui@@ -18,7 +18,65 @@<string>Color Sampler</string></property><layout class="QGridLayout">- <item row="6" column="0">+ <item row="8" column="0">+ <widget class="Line" name="line2">+ <property name="frameShadow">+ <enum>QFrame::Sunken</enum>+ </property>+ <property name="lineWidth">+ <number>1</number>+ </property>+ <property name="orientation">+ <enum>Qt::Horizontal</enum>+ </property>+ </widget>+ </item>+ <item row="5" column="0">+ <widget class="Line" name="line1">+ <property name="frameShadow">+ <enum>QFrame::Sunken</enum>+ </property>+ <property name="lineWidth">+ <number>1</number>+ </property>+ <property name="orientation">+ <enum>Qt::Horizontal</enum>+ </property>+ </widget>+ </item>+ <item row="3" column="0">+ <layout class="QHBoxLayout" name="paletteLayout">+ <property name="spacing">+ <number>1</number>+ </property>+ <property name="leftMargin">+ <number>0</number>+ </property>+ <property name="topMargin">+ <number>0</number>+ </property>+ <property name="rightMargin">+ <number>0</number>+ </property>+ <property name="bottomMargin">+ <number>0</number>+ </property>+ <item>+ <widget class="QCheckBox" name="cbPalette">+ <property name="toolTip">+ <string><nobr>Checking this box will add a new color swatch</nobr> to a palette each time you sample a color.</string>+ </property>+ <property name="text">+ <string>Add to palette:</string>+ </property>+ </widget>+ </item>+ <item>+ <widget class="KisSqueezedComboBox" name="cmbPalette"/>+ </item>+ </layout>+ </item>+ <item row="7" column="0"><layout class="QHBoxLayout" name="blendLayout"><property name="spacing"><number>1</number>@@ -89,59 +147,7 @@</item></widget></item>- <item row="8" column="0">- <widget class="QCheckBox" name="cbNormaliseValues">- <property name="toolTip">- <string>Displays per-channel color information below as percentages instead of bytes.</string>- </property>- <property name="text">- <string>Show colors as percentages</string>- </property>- </widget>- </item>- <item row="9" column="0">- <widget class="QTreeWidget" name="listViewChannels">- <property name="sizePolicy">- <sizepolicy hsizetype="Expanding" vsizetype="Expanding">- <horstretch>0</horstretch>- <verstretch>1</verstretch>- </sizepolicy>- </property>- <property name="minimumSize">- <size>- <width>0</width>- <height>100</height>- </size>- </property>- <property name="columnCount">- <number>2</number>- </property>- <column>- <property name="text">- <string>Channel</string>- </property>- </column>- <column>- <property name="text">- <string comment="The value number each channel of sampled color listed in a table">Value</string>- </property>- </column>- </widget>- </item>- <item row="7" column="0">- <widget class="Line" name="line2">- <property name="frameShadow">- <enum>QFrame::Sunken</enum>- </property>- <property name="lineWidth">- <number>1</number>- </property>- <property name="orientation">- <enum>Qt::Horizontal</enum>- </property>- </widget>- </item>- <item row="5" column="0">+ <item row="6" column="0"><layout class="QHBoxLayout" name="radiusLayout"><property name="spacing"><number>1</number>@@ -195,65 +201,89 @@</item></layout></item>- <item row="3" column="0">- <layout class="QHBoxLayout" name="paletteLayout">- <property name="spacing">- <number>1</number>+ <item row="9" column="0">+ <widget class="QCheckBox" name="cbNormaliseValues">+ <property name="toolTip">+ <string>Displays per-channel color information below as percentages instead of bytes.</string></property>- <property name="leftMargin">- <number>0</number>+ <property name="text">+ <string>Show colors as percentages</string></property>- <property name="topMargin">- <number>0</number>+ </widget>+ </item>+ <item row="10" column="0">+ <widget class="QTreeWidget" name="listViewChannels">+ <property name="sizePolicy">+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">+ <horstretch>0</horstretch>+ <verstretch>1</verstretch>+ </sizepolicy></property>- <property name="rightMargin">- <number>0</number>+ <property name="minimumSize">+ <size>+ <width>0</width>+ <height>100</height>+ </size></property>- <property name="bottomMargin">- <number>0</number>+ <property name="columnCount">+ <number>2</number></property>+ <column>+ <property name="text">+ <string>Channel</string>+ </property>+ </column>+ <column>+ <property name="text">+ <string comment="The value number each channel of sampled color listed in a table">Value</string>+ </property>+ </column>+ </widget>+ </item>+ <item row="2" column="0">+ <layout class="QHBoxLayout" name="horizontalLayout"><item>- <widget class="QCheckBox" name="cbPalette">+ <widget class="QCheckBox" name="cbUpdateCurrentColor"><property name="toolTip">- <string><nobr>Checking this box will add a new color swatch</nobr> to a palette each time you sample a color.</string>+ <string><nobr>Controls whether the color sampler updates the</nobr> current foreground or not.</string></property><property name="text">- <string>Add to palette:</string>+ <string>Update color</string></property></widget></item>- <item>- <widget class="KisSqueezedComboBox" name="cmbPalette"/>- </item></layout></item>- <item row="2" column="0">- <layout class="QHBoxLayout" name="horizontalLayout">+ <item row="4" column="0">+ <layout class="QHBoxLayout" name="previewStyleLayout"><item>- <widget class="QCheckBox" name="cbUpdateCurrentColor">+ <widget class="QLabel" name="lblPreviewStyle"><property name="toolTip">- <string><nobr>Controls whether the color sampler updates the</nobr> current foreground or not.</string>+ <string>Style for the on-canvas popup to comparing sampled colors</string></property><property name="text">- <string>Update color</string>+ <string>Preview:</string>+ </property>+ <property name="buddy">+ <cstring>cmbPreviewStyle</cstring>+ </property>+ </widget>+ </item>+ <item>+ <widget class="QComboBox" name="cmbPreviewStyle">+ <property name="sizePolicy">+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">+ <horstretch>0</horstretch>+ <verstretch>0</verstretch>+ </sizepolicy>+ </property>+ <property name="toolTip">+ <string>Style for the on-canvas popup to comparing sampled colors</string></property></widget></item></layout></item>- <item row="4" column="0">- <widget class="Line" name="line1">- <property name="frameShadow">- <enum>QFrame::Sunken</enum>- </property>- <property name="lineWidth">- <number>1</number>- </property>- <property name="orientation">- <enum>Qt::Horizontal</enum>- </property>- </widget>- </item></layout></widget><customwidgets>