8#include "colordialog.h"
10#include "constpropagatingrawpointer.h"
11#include "genericcolor.h"
13#include "helperconversion.h"
14#include "helperqttypes.h"
15#include "languagechangeeventfilter.h"
16#include "perceptualsettings.h"
20#include <qbytearray.h>
26#include <qsharedpointer.h>
28#include <qstringliteral.h>
44#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
45#include <qtmetamacros.h>
47#include <qobjectdefs.h>
64class ColorDialogPrivate final :
public QObject
68 explicit ColorDialogPrivate(ColorDialog *backLink);
73 virtual ~ColorDialogPrivate() noexcept override = default;
76 static constexpr QListSizeType historyHSwatchCount = 10;
78 static constexpr QListSizeType historyVSwatchCount = 4;
80 static constexpr QListSizeType historySwatchCount =
81 historyHSwatchCount * historyVSwatchCount;
84 QPointer<GradientSlider> m_alphaGradientSlider;
88 QPointer<QLabel> m_alphaLabel;
95 QPointer<QDoubleSpinBox> m_alphaSpinBox;
100 QPointer<QDialogButtonBox> m_buttonBox;
102 QPointer<QPushButton> m_buttonCancel;
104 QPointer<QPushButton> m_buttonOK;
106 QPointer<ChromaHueDiagram> m_chromaHueDiagram;
108 QPointer<MultiSpinBox> m_ciehlcD50SpinBox;
110 QPointer<QAction> m_ciehlcD50SpinBoxGamutAction;
112 QPointer<QLabel> m_ciehlcD50SpinBoxLabel;
114 QPointer<ColorPatch> m_colorPatch;
129 QHash<
ColorModel, GenericColor> m_currentOpaqueColorAbs;
138 RgbColor m_currentOpaqueColorRgb;
140 bool everShown = false;
142 QPointer<MultiSpinBox> m_hslSpinBox;
144 QPointer<QLabel> m_hslSpinBoxLabel;
146 QPointer<MultiSpinBox> m_hsvSpinBox;
148 QPointer<QLabel> m_hsvSpinBoxLabel;
150 QPointer<MultiSpinBox> m_hwbSpinBox;
152 QPointer<QLabel> m_hwbSpinBoxLabel;
154 QPointer<QShortcut> m_hueFirstTabShortcut;
157 QPointer<QWidget> m_hueFirstWrapperWidget;
163 bool m_isColorChangeInProgress = false;
168 bool m_isDirtyRgbLineEdit = false;
170 LanguageChangeEventFilter m_languageChangeEventFilter;
173 PerceptualColor::ColorDialog::DialogLayoutDimensions m_layoutDimensions =
175 ColorDialog::DialogLayoutDimensions::Collapsed
186 PerceptualColor::ColorDialog::DialogLayoutDimensions m_layoutDimensionsEffective = m_layoutDimensions;
188 QPointer<QShortcut> m_lightnessFirstTabShortcut;
191 QPointer<QWidget> m_lightnessFirstWrapperWidget;
193 QPointer<GradientSlider> m_lchLightnessSelector;
201 QByteArray m_memberToBeDisconnected;
207 static inline const QString m_multispinboxSectionSeparator = QStringLiteral(u
" ");
209 QPointer<QShortcut> m_numericalTabShortcut;
212 QPointer<QWidget> m_numericalWidget;
214 QPointer<MultiSpinBox> m_oklchSpinBox;
216 QPointer<QAction> m_oklchSpinBoxGamutAction;
218 QPointer<QLabel> m_oklchSpinBoxLabel;
220 QPointer<PerceptualColor::SwatchBook> m_swatchBookBasicColors;
222 QPointer<QAction> m_swatchBookBasicColorsAction;
224 QPointer<PerceptualColor::SwatchBook> m_swatchBookHistory;
226 QPointer<QAction> m_swatchBookHistoryAction;
230 QPointer<QComboBox> m_swatchBookSelector;
234 QPointer<QStackedLayout> m_swatchBookStack;
236 QPointer<QShortcut> m_swatchBookTabShortcut;
239 QPointer<QWidget> m_swatchBookWrapperWidget;
245 QPointer<
QObject> m_receiverToBeDisconnected;
247 ColorDialog::ColorDialogOptions m_options;
249 QSharedPointer<RgbColorSpace> m_rgbColorSpace;
252 QPointer<QGroupBox> m_rgbGroupBox;
255 QPointer<QLineEdit> m_rgbLineEdit;
257 QPointer<QLabel> m_rgbLineEditLabel;
259 QPointer<MultiSpinBox> m_rgbSpinBox;
261 QPointer<QLabel> m_rgbSpinBoxLabel;
263 QColor m_selectedColor;
265 QPointer<QHBoxLayout> m_selectorLayout;
267 PerceptualSettings &m_settings = PerceptualSettings::instance();
270 QPointer<QToolButton> m_screenColorPickerButton;
276 const QString tableRow = QStringLiteral(u
"<tr><td>%1</td><td>%2</td></tr>");
281 QHash<QPointer<QWidget> *, QString> m_tabTable;
283 QPointer<QTabWidget> m_tabWidget;
296 QColor m_wcsBasicDefaultColor;
298 QPointer<WheelColorPicker> m_wheelColorPicker;
303 static constexpr quint8 decimals = 0;
308 static constexpr quint8 okdecimals = decimals + 2;
310 void applyLayoutDimensions();
311 [[nodiscard]] QColor defaultColor() const;
312 void initialize(const QSharedPointer<PerceptualColor::RgbColorSpace> &colorSpace);
313 [[nodiscard]] QWidget *initializeNumericPage();
314 void initializeScreenColorPicker();
315 void loadHistoryFromSettingsToSwatchBook();
316 [[nodiscard]] QString translateColorModel(cmsColorSpaceSignature model);
319 void readChromaHueDiagramValue();
320 void readColorPatchValue();
321 void readHlcNumericValues();
322 void readHslNumericValues();
323 void readHsvNumericValues();
324 void readHwbNumericValues();
325 void readLightnessValue();
326 void readOklchNumericValues();
327 void readRgbHexValues();
328 void readRgbNumericValues();
329 void readSwatchBookBasicColorsValue();
330 void readSwatchBookHistoryValue();
331 void readWheelColorPickerValues();
333 void retranslateUi();
334 void saveCurrentTab();
335 void setCurrentOpaqueColor(const QHash<PerceptualColor::
ColorModel, PerceptualColor::GenericColor> &abs, QWidget *const ignoreWidget);
336 void setCurrentOpaqueColor(const PerceptualColor::RgbColor &rgb, QWidget *const ignoreWidget);
337 void setCurrentOpaqueColor(const QHash<PerceptualColor::
ColorModel, PerceptualColor::GenericColor> &abs,
338 const PerceptualColor::RgbColor &rgb,
339 QWidget *const ignoreWidget);
340 void updateColorPatch();
341 void updateHlcButBlockSignals();
342 void updateOklchButBlockSignals();
343 void updateRgbHexButBlockSignals();
346 Q_DISABLE_COPY(ColorDialogPrivate)
350 ConstPropagatingRawPointer<ColorDialog> q_pointer;
A widget for selecting chroma and hue in LCH color space.
A slider who’s groove displays an LCH color gradient.
A spin box that can hold multiple sections (each with its own value) at the same time.
Complete wheel-based color picker widget.
The namespace of this library.
Array2D< QColor > Swatches
Swatches organized in a grid.
ColorSchemeType
Represents the appearance of a theme.
ColorModel
Identifiers for color models.