1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQUICKCOLORINPUTS_P_H
5#define QQUICKCOLORINPUTS_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtGui/qcolor.h>
19#include <QtQuick/private/qquickitem_p.h>
20#include <QtQuickTemplates2/private/qquicktextfield_p.h>
21
22#include "qtquickdialogs2quickimplglobal_p.h"
23
24#include "qquickcolordialogutils_p.h"
25
26QT_BEGIN_NAMESPACE
27
28class Q_QUICKDIALOGS2QUICKIMPL_PRIVATE_EXPORT QQuickColorInputs : public QQuickItem
29{
30 Q_OBJECT
31 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
32 Q_PROPERTY(int red READ red NOTIFY colorChanged)
33 Q_PROPERTY(int green READ green NOTIFY colorChanged)
34 Q_PROPERTY(int blue READ blue NOTIFY colorChanged)
35 Q_PROPERTY(qreal hue READ hue NOTIFY colorChanged)
36 Q_PROPERTY(qreal hslSaturation READ hslSaturation NOTIFY colorChanged)
37 Q_PROPERTY(qreal hsvSaturation READ hsvSaturation NOTIFY colorChanged)
38 Q_PROPERTY(qreal value READ value NOTIFY colorChanged)
39 Q_PROPERTY(qreal lightness READ lightness NOTIFY colorChanged)
40 Q_PROPERTY(qreal alpha READ alpha NOTIFY colorChanged)
41 Q_PROPERTY(bool showAlpha READ showAlpha WRITE setShowAlpha NOTIFY showAlphaChanged)
42 Q_PROPERTY(QQuickTextInput *hexInput READ hexInput WRITE setHexInput NOTIFY hexInputChanged)
43 Q_PROPERTY(QQuickTextInput *redInput READ redInput WRITE setRedInput NOTIFY redInputChanged)
44 Q_PROPERTY(QQuickTextInput *greenInput READ greenInput WRITE setGreenInput NOTIFY greenInputChanged)
45 Q_PROPERTY(QQuickTextInput *blueInput READ blueInput WRITE setBlueInput NOTIFY blueInputChanged)
46 Q_PROPERTY(QQuickTextInput *hsvHueInput READ hsvHueInput WRITE setHsvHueInput NOTIFY hsvHueInputChanged)
47 Q_PROPERTY(QQuickTextInput *hslHueInput READ hslHueInput WRITE setHslHueInput NOTIFY hslHueInputChanged)
48 Q_PROPERTY(QQuickTextInput *hsvSaturationInput READ hsvSaturationInput WRITE setHsvSaturationInput NOTIFY hsvSaturationInputChanged)
49 Q_PROPERTY(QQuickTextInput *hslSaturationInput READ hslSaturationInput WRITE setHslSaturationInput NOTIFY hslSaturationInputChanged)
50 Q_PROPERTY(QQuickTextInput *valueInput READ valueInput WRITE setValueInput NOTIFY valueInputChanged)
51 Q_PROPERTY(QQuickTextInput *lightnessInput READ lightnessInput WRITE setLightnessInput NOTIFY lightnessInputChanged)
52 Q_PROPERTY(QQuickTextInput *rgbAlphaInput READ rgbAlphaInput WRITE setRgbAlphaInput NOTIFY rgbAlphaInputChanged)
53 Q_PROPERTY(QQuickTextInput *hsvAlphaInput READ hsvAlphaInput WRITE setHsvAlphaInput NOTIFY hsvAlphaInputChanged)
54 Q_PROPERTY(QQuickTextInput *hslAlphaInput READ hslAlphaInput WRITE setHslAlphaInput NOTIFY hslAlphaInputChanged)
55 QML_NAMED_ELEMENT(ColorInputsImpl)
56
57public:
58 explicit QQuickColorInputs();
59
60 QColor color() const;
61 void setColor(const QColor &c);
62 int red() const;
63 int green() const;
64 int blue() const;
65 qreal alpha() const;
66 qreal hue() const;
67 qreal hslSaturation() const;
68 qreal hsvSaturation() const;
69 qreal value() const;
70 qreal lightness() const;
71
72 bool showAlpha() const;
73 void setShowAlpha(bool showAlpha);
74
75 QQuickTextInput *hexInput() const;
76 void setHexInput(QQuickTextInput *hexInput);
77
78 QQuickTextInput *redInput() const;
79 void setRedInput(QQuickTextInput *redInput);
80
81 QQuickTextInput *greenInput() const;
82 void setGreenInput(QQuickTextInput *greenInput);
83
84 QQuickTextInput *blueInput() const;
85 void setBlueInput(QQuickTextInput *blueInput);
86
87 QQuickTextInput *hsvHueInput() const;
88 void setHsvHueInput(QQuickTextInput *hsvHueInput);
89
90 QQuickTextInput *hslHueInput() const;
91 void setHslHueInput(QQuickTextInput *hslHueInput);
92
93 QQuickTextInput *hsvSaturationInput() const;
94 void setHsvSaturationInput(QQuickTextInput *hsvSaturationInput);
95
96 QQuickTextInput *hslSaturationInput() const;
97 void setHslSaturationInput(QQuickTextInput *hslSaturationInput);
98
99 QQuickTextInput *valueInput() const;
100 void setValueInput(QQuickTextInput *valueInput);
101
102 QQuickTextInput *lightnessInput() const;
103 void setLightnessInput(QQuickTextInput *lightnessInput);
104
105 QQuickTextInput *rgbAlphaInput() const;
106 void setRgbAlphaInput(QQuickTextInput *alphaInput);
107
108 QQuickTextInput *hsvAlphaInput() const;
109 void setHsvAlphaInput(QQuickTextInput *alphaInput);
110
111 QQuickTextInput *hslAlphaInput() const;
112 void setHslAlphaInput(QQuickTextInput *alphaInput);
113
114Q_SIGNALS:
115 void colorChanged(const QColor &c);
116 void colorModified(const QColor &c);
117 void hslChanged();
118 void showAlphaChanged(bool);
119 void hexInputChanged();
120 void redInputChanged();
121 void greenInputChanged();
122 void blueInputChanged();
123 void hsvHueInputChanged();
124 void hslHueInputChanged();
125 void hsvSaturationInputChanged();
126 void hslSaturationInputChanged();
127 void valueInputChanged();
128 void lightnessInputChanged();
129 void rgbAlphaInputChanged();
130 void hsvAlphaInputChanged();
131 void hslAlphaInputChanged();
132
133private:
134 void handleHexChanged();
135 void handleRedChanged();
136 void handleGreenChanged();
137 void handleBlueChanged();
138 void handleHsvHueChanged();
139 void handleHslHueChanged();
140 void handleHueChanged(const QString &input);
141 void handleHsvSaturationChanged();
142 void handleHslSaturationChanged();
143 void handleSaturationChanged(const QString &input);
144 void handleValueChanged();
145 void handleLightnessChanged();
146 void handleRgbAlphaChanged();
147 void handleHsvAlphaChanged();
148 void handleHslAlphaChanged();
149 void handleAlphaChanged(const QString &input);
150
151 QPointer<QQuickTextInput> m_hexInput;
152 QPointer<QQuickTextInput> m_redInput;
153 QPointer<QQuickTextInput> m_greenInput;
154 QPointer<QQuickTextInput> m_blueInput;
155 QPointer<QQuickTextInput> m_hsvHueInput;
156 QPointer<QQuickTextInput> m_hslHueInput;
157 QPointer<QQuickTextInput> m_hsvSaturationInput;
158 QPointer<QQuickTextInput> m_hslSaturationInput;
159 QPointer<QQuickTextInput> m_valueInput;
160 QPointer<QQuickTextInput> m_lightnessInput;
161 QPointer<QQuickTextInput> m_rgbAlphaInput;
162 QPointer<QQuickTextInput> m_hsvAlphaInput;
163 QPointer<QQuickTextInput> m_hslAlphaInput;
164 HSVA m_hsva;
165 bool m_showAlpha = false;
166};
167
168QT_END_NAMESPACE
169
170#endif // QQUICKCOLORINPUTS_P_H
171

source code of qtdeclarative/src/quickdialogs/quickdialogsquickimpl/qquickcolorinputs_p.h