| 1 | // Copyright (C) 2020 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 | #ifndef QQUICKCOLORGROUP_H |
| 4 | #define QQUICKCOLORGROUP_H |
| 5 | |
| 6 | // |
| 7 | // W A R N I N G |
| 8 | // ------------- |
| 9 | // |
| 10 | // This file is not part of the Qt API. It exists for the convenience |
| 11 | // of QQuickColorGroup. This header file may change from version to |
| 12 | // version without notice, or even be removed. |
| 13 | // |
| 14 | // We mean it. |
| 15 | // |
| 16 | |
| 17 | #include <QtGui/qpalette.h> |
| 18 | |
| 19 | #include <QtCore/private/qobject_p.h> |
| 20 | |
| 21 | #include <QtQuick/private/qtquickglobal_p.h> |
| 22 | |
| 23 | #include <QtQml/qqml.h> |
| 24 | |
| 25 | #include <QtCore/qpointer.h> |
| 26 | |
| 27 | QT_BEGIN_NAMESPACE |
| 28 | |
| 29 | class QQuickPalette; |
| 30 | class QQuickPaletteColorProvider; |
| 31 | |
| 32 | class Q_QUICK_EXPORT QQuickColorGroup : public QObject |
| 33 | { |
| 34 | Q_OBJECT |
| 35 | |
| 36 | Q_PROPERTY(QColor alternateBase READ alternateBase WRITE setAlternateBase RESET resetAlternateBase NOTIFY alternateBaseChanged FINAL) |
| 37 | Q_PROPERTY(QColor base READ base WRITE setBase RESET resetBase NOTIFY baseChanged FINAL) |
| 38 | Q_PROPERTY(QColor brightText READ brightText WRITE setBrightText RESET resetBrightText NOTIFY brightTextChanged FINAL) |
| 39 | Q_PROPERTY(QColor button READ button WRITE setButton RESET resetButton NOTIFY buttonChanged FINAL) |
| 40 | Q_PROPERTY(QColor buttonText READ buttonText WRITE setButtonText RESET resetButtonText NOTIFY buttonTextChanged FINAL) |
| 41 | Q_PROPERTY(QColor dark READ dark WRITE setDark RESET resetDark NOTIFY darkChanged FINAL) |
| 42 | Q_PROPERTY(QColor highlight READ highlight WRITE setHighlight RESET resetHighlight NOTIFY highlightChanged FINAL) |
| 43 | Q_PROPERTY(QColor highlightedText READ highlightedText WRITE setHighlightedText RESET resetHighlightedText NOTIFY highlightedTextChanged FINAL) |
| 44 | Q_PROPERTY(QColor light READ light WRITE setLight RESET resetLight NOTIFY lightChanged FINAL) |
| 45 | Q_PROPERTY(QColor link READ link WRITE setLink RESET resetLink NOTIFY linkChanged FINAL) |
| 46 | Q_PROPERTY(QColor linkVisited READ linkVisited WRITE setLinkVisited RESET resetLinkVisited NOTIFY linkVisitedChanged FINAL) |
| 47 | Q_PROPERTY(QColor mid READ mid WRITE setMid RESET resetMid NOTIFY midChanged FINAL) |
| 48 | Q_PROPERTY(QColor midlight READ midlight WRITE setMidlight RESET resetMidlight NOTIFY midlightChanged FINAL) |
| 49 | Q_PROPERTY(QColor shadow READ shadow WRITE setShadow RESET resetShadow NOTIFY shadowChanged FINAL) |
| 50 | Q_PROPERTY(QColor text READ text WRITE setText RESET resetText NOTIFY textChanged FINAL) |
| 51 | Q_PROPERTY(QColor toolTipBase READ toolTipBase WRITE setToolTipBase RESET resetToolTipBase NOTIFY toolTipBaseChanged FINAL) |
| 52 | Q_PROPERTY(QColor toolTipText READ toolTipText WRITE setToolTipText RESET resetToolTipText NOTIFY toolTipTextChanged FINAL) |
| 53 | Q_PROPERTY(QColor window READ window WRITE setWindow RESET resetWindow NOTIFY windowChanged FINAL) |
| 54 | Q_PROPERTY(QColor windowText READ windowText WRITE setWindowText RESET resetWindowText NOTIFY windowTextChanged FINAL) |
| 55 | Q_PROPERTY(QColor placeholderText READ placeholderText WRITE setPlaceholderText |
| 56 | RESET resetPlaceholderText NOTIFY placeholderTextChanged REVISION(6, 2) FINAL) |
| 57 | Q_PROPERTY(QColor accent READ accent WRITE setAccent RESET resetAccent NOTIFY accentChanged REVISION(6, 6) FINAL) |
| 58 | |
| 59 | QML_NAMED_ELEMENT(ColorGroup) |
| 60 | QML_ADDED_IN_VERSION(6, 0) |
| 61 | |
| 62 | public: // Types |
| 63 | using GroupPtr = QPointer<QQuickColorGroup>; |
| 64 | |
| 65 | public: |
| 66 | Q_DISABLE_COPY_MOVE(QQuickColorGroup) |
| 67 | |
| 68 | explicit QQuickColorGroup(QObject *parent = nullptr); |
| 69 | |
| 70 | QColor alternateBase() const; |
| 71 | void setAlternateBase(const QColor &color); |
| 72 | void resetAlternateBase(); |
| 73 | |
| 74 | QColor base() const; |
| 75 | void setBase(const QColor &color); |
| 76 | void resetBase(); |
| 77 | |
| 78 | QColor brightText() const; |
| 79 | void setBrightText(const QColor &color); |
| 80 | void resetBrightText(); |
| 81 | |
| 82 | QColor button() const; |
| 83 | void setButton(const QColor &color); |
| 84 | void resetButton(); |
| 85 | |
| 86 | QColor buttonText() const; |
| 87 | void setButtonText(const QColor &color); |
| 88 | void resetButtonText(); |
| 89 | |
| 90 | QColor dark() const; |
| 91 | void setDark(const QColor &color); |
| 92 | void resetDark(); |
| 93 | |
| 94 | QColor highlight() const; |
| 95 | void setHighlight(const QColor &color); |
| 96 | void resetHighlight(); |
| 97 | |
| 98 | QColor highlightedText() const; |
| 99 | void setHighlightedText(const QColor &color); |
| 100 | void resetHighlightedText(); |
| 101 | |
| 102 | QColor light() const; |
| 103 | void setLight(const QColor &color); |
| 104 | void resetLight(); |
| 105 | |
| 106 | QColor link() const; |
| 107 | void setLink(const QColor &color); |
| 108 | void resetLink(); |
| 109 | |
| 110 | QColor linkVisited() const; |
| 111 | void setLinkVisited(const QColor &color); |
| 112 | void resetLinkVisited(); |
| 113 | |
| 114 | QColor mid() const; |
| 115 | void setMid(const QColor &color); |
| 116 | void resetMid(); |
| 117 | |
| 118 | QColor midlight() const; |
| 119 | void setMidlight(const QColor &color); |
| 120 | void resetMidlight(); |
| 121 | |
| 122 | QColor shadow() const; |
| 123 | void setShadow(const QColor &color); |
| 124 | void resetShadow(); |
| 125 | |
| 126 | QColor text() const; |
| 127 | void setText(const QColor &color); |
| 128 | void resetText(); |
| 129 | |
| 130 | QColor toolTipBase() const; |
| 131 | void setToolTipBase(const QColor &color); |
| 132 | void resetToolTipBase(); |
| 133 | |
| 134 | QColor toolTipText() const; |
| 135 | void setToolTipText(const QColor &color); |
| 136 | void resetToolTipText(); |
| 137 | |
| 138 | QColor window() const; |
| 139 | void setWindow(const QColor &color); |
| 140 | void resetWindow(); |
| 141 | |
| 142 | QColor windowText() const; |
| 143 | void setWindowText(const QColor &color); |
| 144 | void resetWindowText(); |
| 145 | |
| 146 | QColor placeholderText() const; |
| 147 | void setPlaceholderText(const QColor &color); |
| 148 | void resetPlaceholderText(); |
| 149 | |
| 150 | QColor accent() const; |
| 151 | void setAccent(const QColor &color); |
| 152 | void resetAccent(); |
| 153 | |
| 154 | QPalette::ColorGroup groupTag() const; |
| 155 | void setGroupTag(QPalette::ColorGroup tag); |
| 156 | |
| 157 | const QQuickPaletteColorProvider &colorProvider() const; |
| 158 | QQuickPaletteColorProvider &colorProvider(); |
| 159 | |
| 160 | static QQuickColorGroup* createWithParent(QQuickPalette &parent); |
| 161 | |
| 162 | Q_SIGNALS: |
| 163 | void alternateBaseChanged(); |
| 164 | void baseChanged(); |
| 165 | void brightTextChanged(); |
| 166 | void buttonChanged(); |
| 167 | void buttonTextChanged(); |
| 168 | void darkChanged(); |
| 169 | void highlightChanged(); |
| 170 | void highlightedTextChanged(); |
| 171 | void lightChanged(); |
| 172 | void linkChanged(); |
| 173 | void linkVisitedChanged(); |
| 174 | void midChanged(); |
| 175 | void midlightChanged(); |
| 176 | void shadowChanged(); |
| 177 | void textChanged(); |
| 178 | void toolTipBaseChanged(); |
| 179 | void toolTipTextChanged(); |
| 180 | void windowChanged(); |
| 181 | void windowTextChanged(); |
| 182 | Q_REVISION(6, 2) void placeholderTextChanged(); |
| 183 | Q_REVISION(6, 6) void accentChanged(); |
| 184 | |
| 185 | void changed(); |
| 186 | |
| 187 | protected: |
| 188 | explicit QQuickColorGroup(QQuickPalette &parent); |
| 189 | |
| 190 | static constexpr QPalette::ColorGroup defaultGroupTag() { return QPalette::All; } |
| 191 | |
| 192 | virtual QPalette::ColorGroup currentColorGroup() const; |
| 193 | |
| 194 | private: |
| 195 | using Notifier = void (QQuickColorGroup::* )(); |
| 196 | |
| 197 | QColor color(QPalette::ColorRole role) const; |
| 198 | void setColor(QPalette::ColorRole role, QColor color, Notifier notifier); |
| 199 | void resetColor(QPalette::ColorRole role, Notifier notifier); |
| 200 | |
| 201 | private: |
| 202 | QPalette::ColorGroup m_groupTag; |
| 203 | std::shared_ptr<QQuickPaletteColorProvider> m_colorProvider; |
| 204 | }; |
| 205 | |
| 206 | QT_END_NAMESPACE |
| 207 | |
| 208 | #endif // QQUICKCOLORGROUP_H |
| 209 | |