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