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

source code of qtdeclarative/src/quick/items/qquickcolorgroup_p.h