| 1 | // Copyright (C) 2024 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 <QtQmlModels/private/qqmldelegatemodel_p.h> |
| 20 | #include <QtQuick/private/qquickitem_p.h> |
| 21 | #include <QtQuickTemplates2/private/qquicktextfield_p.h> |
| 22 | #include <QtQuickTemplates2/private/qquickcontainer_p.h> |
| 23 | |
| 24 | #include "qtquickdialogs2quickimplglobal_p.h" |
| 25 | |
| 26 | #include "qquickcolordialogutils_p.h" |
| 27 | |
| 28 | #include <QtCore/qpointer.h> |
| 29 | |
| 30 | QT_BEGIN_NAMESPACE |
| 31 | |
| 32 | class QQuickColorInputsPrivate; |
| 33 | |
| 34 | class Q_QUICKDIALOGS2QUICKIMPL_EXPORT QQuickColorInputs : public QQuickContainer |
| 35 | { |
| 36 | Q_OBJECT |
| 37 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged FINAL) |
| 38 | Q_PROPERTY(int red READ red NOTIFY colorChanged FINAL) |
| 39 | Q_PROPERTY(int green READ green NOTIFY colorChanged FINAL) |
| 40 | Q_PROPERTY(int blue READ blue NOTIFY colorChanged FINAL) |
| 41 | Q_PROPERTY(qreal hue READ hue NOTIFY colorChanged FINAL) |
| 42 | Q_PROPERTY(qreal hslSaturation READ hslSaturation NOTIFY colorChanged FINAL) |
| 43 | Q_PROPERTY(qreal hsvSaturation READ hsvSaturation NOTIFY colorChanged FINAL) |
| 44 | Q_PROPERTY(qreal value READ value NOTIFY colorChanged FINAL) |
| 45 | Q_PROPERTY(qreal lightness READ lightness NOTIFY colorChanged FINAL) |
| 46 | Q_PROPERTY(qreal alpha READ alpha NOTIFY colorChanged FINAL) |
| 47 | Q_PROPERTY(bool showAlpha READ showAlpha WRITE setShowAlpha NOTIFY showAlphaChanged FINAL) |
| 48 | Q_PROPERTY(Mode mode READ currentMode WRITE setCurrentMode NOTIFY currentModeChanged FINAL) |
| 49 | Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL) |
| 50 | QML_NAMED_ELEMENT(ColorInputsImpl) |
| 51 | QML_ADDED_IN_VERSION(6, 9) |
| 52 | |
| 53 | public: |
| 54 | explicit QQuickColorInputs(QQuickItem *parent = nullptr); |
| 55 | |
| 56 | enum Mode { |
| 57 | Hex = 0, |
| 58 | Rgb, |
| 59 | Hsv, |
| 60 | Hsl |
| 61 | }; |
| 62 | Q_ENUM(Mode); |
| 63 | |
| 64 | Mode currentMode() const; |
| 65 | void setCurrentMode(Mode mode); |
| 66 | |
| 67 | QQmlComponent *delegate() const; |
| 68 | void setDelegate(QQmlComponent *delegate); |
| 69 | |
| 70 | QColor color() const; |
| 71 | void setColor(const QColor &c); |
| 72 | int red() const; |
| 73 | int green() const; |
| 74 | int blue() const; |
| 75 | qreal alpha() const; |
| 76 | qreal hue() const; |
| 77 | qreal hslSaturation() const; |
| 78 | qreal hsvSaturation() const; |
| 79 | qreal value() const; |
| 80 | qreal lightness() const; |
| 81 | |
| 82 | bool showAlpha() const; |
| 83 | void setShowAlpha(bool showAlpha); |
| 84 | |
| 85 | Q_SIGNALS: |
| 86 | void colorChanged(const QColor &c); |
| 87 | void colorModified(const QColor &c); |
| 88 | void hslChanged(); |
| 89 | void showAlphaChanged(bool); |
| 90 | void currentModeChanged(); |
| 91 | void delegateChanged(); |
| 92 | |
| 93 | protected: |
| 94 | void componentComplete() override; |
| 95 | |
| 96 | private: |
| 97 | Q_DISABLE_COPY(QQuickColorInputs) |
| 98 | Q_DECLARE_PRIVATE(QQuickColorInputs) |
| 99 | }; |
| 100 | |
| 101 | QT_END_NAMESPACE |
| 102 | |
| 103 | #endif // QQUICKCOLORINPUTS_P_H |
| 104 |
