| 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 |  | 
| 26 | #include <QtCore/qpointer.h> | 
| 27 |  | 
| 28 | QT_BEGIN_NAMESPACE | 
| 29 |  | 
| 30 | class Q_QUICKDIALOGS2QUICKIMPL_EXPORT QQuickColorInputs : public QQuickItem | 
| 31 | { | 
| 32 |     Q_OBJECT | 
| 33 |     Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) | 
| 34 |     Q_PROPERTY(int red READ red NOTIFY colorChanged) | 
| 35 |     Q_PROPERTY(int green READ green NOTIFY colorChanged) | 
| 36 |     Q_PROPERTY(int blue READ blue NOTIFY colorChanged) | 
| 37 |     Q_PROPERTY(qreal hue READ hue NOTIFY colorChanged) | 
| 38 |     Q_PROPERTY(qreal hslSaturation READ hslSaturation NOTIFY colorChanged) | 
| 39 |     Q_PROPERTY(qreal hsvSaturation READ hsvSaturation NOTIFY colorChanged) | 
| 40 |     Q_PROPERTY(qreal value READ value NOTIFY colorChanged) | 
| 41 |     Q_PROPERTY(qreal lightness READ lightness NOTIFY colorChanged) | 
| 42 |     Q_PROPERTY(qreal alpha READ alpha NOTIFY colorChanged) | 
| 43 |     Q_PROPERTY(bool showAlpha READ showAlpha WRITE setShowAlpha NOTIFY showAlphaChanged) | 
| 44 |     Q_PROPERTY(QQuickTextInput *hexInput READ hexInput WRITE setHexInput NOTIFY hexInputChanged) | 
| 45 |     Q_PROPERTY(QQuickTextInput *redInput READ redInput WRITE setRedInput NOTIFY redInputChanged) | 
| 46 |     Q_PROPERTY(QQuickTextInput *greenInput READ greenInput WRITE setGreenInput NOTIFY greenInputChanged) | 
| 47 |     Q_PROPERTY(QQuickTextInput *blueInput READ blueInput WRITE setBlueInput NOTIFY blueInputChanged) | 
| 48 |     Q_PROPERTY(QQuickTextInput *hsvHueInput READ hsvHueInput WRITE setHsvHueInput NOTIFY hsvHueInputChanged) | 
| 49 |     Q_PROPERTY(QQuickTextInput *hslHueInput READ hslHueInput WRITE setHslHueInput NOTIFY hslHueInputChanged) | 
| 50 |     Q_PROPERTY(QQuickTextInput *hsvSaturationInput READ hsvSaturationInput WRITE setHsvSaturationInput NOTIFY hsvSaturationInputChanged) | 
| 51 |     Q_PROPERTY(QQuickTextInput *hslSaturationInput READ hslSaturationInput WRITE setHslSaturationInput NOTIFY hslSaturationInputChanged) | 
| 52 |     Q_PROPERTY(QQuickTextInput *valueInput READ valueInput WRITE setValueInput NOTIFY valueInputChanged) | 
| 53 |     Q_PROPERTY(QQuickTextInput *lightnessInput READ lightnessInput WRITE setLightnessInput NOTIFY lightnessInputChanged) | 
| 54 |     Q_PROPERTY(QQuickTextInput *rgbAlphaInput READ rgbAlphaInput WRITE setRgbAlphaInput NOTIFY rgbAlphaInputChanged) | 
| 55 |     Q_PROPERTY(QQuickTextInput *hsvAlphaInput READ hsvAlphaInput WRITE setHsvAlphaInput NOTIFY hsvAlphaInputChanged) | 
| 56 |     Q_PROPERTY(QQuickTextInput *hslAlphaInput READ hslAlphaInput WRITE setHslAlphaInput NOTIFY hslAlphaInputChanged) | 
| 57 |     QML_NAMED_ELEMENT(ColorInputsImpl) | 
| 58 |  | 
| 59 | public: | 
| 60 |     explicit QQuickColorInputs(); | 
| 61 |  | 
| 62 |     QColor color() const; | 
| 63 |     void setColor(const QColor &c); | 
| 64 |     int red() const; | 
| 65 |     int green() const; | 
| 66 |     int blue() const; | 
| 67 |     qreal alpha() const; | 
| 68 |     qreal hue() const; | 
| 69 |     qreal hslSaturation() const; | 
| 70 |     qreal hsvSaturation() const; | 
| 71 |     qreal value() const; | 
| 72 |     qreal lightness() const; | 
| 73 |  | 
| 74 |     bool showAlpha() const; | 
| 75 |     void setShowAlpha(bool showAlpha); | 
| 76 |  | 
| 77 |     QQuickTextInput *hexInput() const; | 
| 78 |     void setHexInput(QQuickTextInput *hexInput); | 
| 79 |  | 
| 80 |     QQuickTextInput *redInput() const; | 
| 81 |     void setRedInput(QQuickTextInput *redInput); | 
| 82 |  | 
| 83 |     QQuickTextInput *greenInput() const; | 
| 84 |     void setGreenInput(QQuickTextInput *greenInput); | 
| 85 |  | 
| 86 |     QQuickTextInput *blueInput() const; | 
| 87 |     void setBlueInput(QQuickTextInput *blueInput); | 
| 88 |  | 
| 89 |     QQuickTextInput *hsvHueInput() const; | 
| 90 |     void setHsvHueInput(QQuickTextInput *hsvHueInput); | 
| 91 |  | 
| 92 |     QQuickTextInput *hslHueInput() const; | 
| 93 |     void setHslHueInput(QQuickTextInput *hslHueInput); | 
| 94 |  | 
| 95 |     QQuickTextInput *hsvSaturationInput() const; | 
| 96 |     void setHsvSaturationInput(QQuickTextInput *hsvSaturationInput); | 
| 97 |  | 
| 98 |     QQuickTextInput *hslSaturationInput() const; | 
| 99 |     void setHslSaturationInput(QQuickTextInput *hslSaturationInput); | 
| 100 |  | 
| 101 |     QQuickTextInput *valueInput() const; | 
| 102 |     void setValueInput(QQuickTextInput *valueInput); | 
| 103 |  | 
| 104 |     QQuickTextInput *lightnessInput() const; | 
| 105 |     void setLightnessInput(QQuickTextInput *lightnessInput); | 
| 106 |  | 
| 107 |     QQuickTextInput *rgbAlphaInput() const; | 
| 108 |     void setRgbAlphaInput(QQuickTextInput *alphaInput); | 
| 109 |  | 
| 110 |     QQuickTextInput *hsvAlphaInput() const; | 
| 111 |     void setHsvAlphaInput(QQuickTextInput *alphaInput); | 
| 112 |  | 
| 113 |     QQuickTextInput *hslAlphaInput() const; | 
| 114 |     void setHslAlphaInput(QQuickTextInput *alphaInput); | 
| 115 |  | 
| 116 | Q_SIGNALS: | 
| 117 |     void colorChanged(const QColor &c); | 
| 118 |     void colorModified(const QColor &c); | 
| 119 |     void hslChanged(); | 
| 120 |     void showAlphaChanged(bool); | 
| 121 |     void hexInputChanged(); | 
| 122 |     void redInputChanged(); | 
| 123 |     void greenInputChanged(); | 
| 124 |     void blueInputChanged(); | 
| 125 |     void hsvHueInputChanged(); | 
| 126 |     void hslHueInputChanged(); | 
| 127 |     void hsvSaturationInputChanged(); | 
| 128 |     void hslSaturationInputChanged(); | 
| 129 |     void valueInputChanged(); | 
| 130 |     void lightnessInputChanged(); | 
| 131 |     void rgbAlphaInputChanged(); | 
| 132 |     void hsvAlphaInputChanged(); | 
| 133 |     void hslAlphaInputChanged(); | 
| 134 |  | 
| 135 | private: | 
| 136 |     void handleHexChanged(); | 
| 137 |     void handleRedChanged(); | 
| 138 |     void handleGreenChanged(); | 
| 139 |     void handleBlueChanged(); | 
| 140 |     void handleHsvHueChanged(); | 
| 141 |     void handleHslHueChanged(); | 
| 142 |     void handleHueChanged(const QString &input); | 
| 143 |     void handleHsvSaturationChanged(); | 
| 144 |     void handleHslSaturationChanged(); | 
| 145 |     void handleSaturationChanged(const QString &input); | 
| 146 |     void handleValueChanged(); | 
| 147 |     void handleLightnessChanged(); | 
| 148 |     void handleRgbAlphaChanged(); | 
| 149 |     void handleHsvAlphaChanged(); | 
| 150 |     void handleHslAlphaChanged(); | 
| 151 |     void handleAlphaChanged(const QString &input); | 
| 152 |  | 
| 153 |     QPointer<QQuickTextInput> m_hexInput; | 
| 154 |     QPointer<QQuickTextInput> m_redInput; | 
| 155 |     QPointer<QQuickTextInput> m_greenInput; | 
| 156 |     QPointer<QQuickTextInput> m_blueInput; | 
| 157 |     QPointer<QQuickTextInput> m_hsvHueInput; | 
| 158 |     QPointer<QQuickTextInput> m_hslHueInput; | 
| 159 |     QPointer<QQuickTextInput> m_hsvSaturationInput; | 
| 160 |     QPointer<QQuickTextInput> m_hslSaturationInput; | 
| 161 |     QPointer<QQuickTextInput> m_valueInput; | 
| 162 |     QPointer<QQuickTextInput> m_lightnessInput; | 
| 163 |     QPointer<QQuickTextInput> m_rgbAlphaInput; | 
| 164 |     QPointer<QQuickTextInput> m_hsvAlphaInput; | 
| 165 |     QPointer<QQuickTextInput> m_hslAlphaInput; | 
| 166 |     HSVA m_hsva; | 
| 167 |     bool m_showAlpha = false; | 
| 168 | }; | 
| 169 |  | 
| 170 | QT_END_NAMESPACE | 
| 171 |  | 
| 172 | #endif // QQUICKCOLORINPUTS_P_H | 
| 173 |  |