Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickuniversalstyle_p.h
Go to the documentation of this file.
1// Copyright (C) 2017 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 QQUICKUNIVERSALSTYLE_P_H
5#define QQUICKUNIVERSALSTYLE_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 <QtQml/qqml.h>
20#include <QtQuickControls2/qquickattachedpropertypropagator.h>
21#include <QtQuickControls2Universal/qtquickcontrols2universalexports.h>
22
24
25class QQuickUniversalStylePrivate;
26
27class Q_QUICKCONTROLS2UNIVERSAL_EXPORT QQuickUniversalStyle : public QQuickAttachedPropertyPropagator
28{
30 Q_PROPERTY(Theme theme READ theme WRITE setTheme RESET resetTheme NOTIFY themeChanged FINAL)
31 Q_PROPERTY(QVariant accent READ accent WRITE setAccent RESET resetAccent NOTIFY accentChanged FINAL)
32 Q_PROPERTY(QVariant foreground READ foreground WRITE setForeground RESET resetForeground NOTIFY foregroundChanged FINAL)
33 Q_PROPERTY(QVariant background READ background WRITE setBackground RESET resetBackground NOTIFY backgroundChanged FINAL)
34
35 Q_PROPERTY(QColor altHighColor READ altHighColor NOTIFY paletteChanged FINAL)
36 Q_PROPERTY(QColor altLowColor READ altLowColor NOTIFY paletteChanged FINAL)
37 Q_PROPERTY(QColor altMediumColor READ altMediumColor NOTIFY paletteChanged FINAL)
38 Q_PROPERTY(QColor altMediumHighColor READ altMediumHighColor NOTIFY paletteChanged FINAL)
39 Q_PROPERTY(QColor altMediumLowColor READ altMediumLowColor NOTIFY paletteChanged FINAL)
40 Q_PROPERTY(QColor baseHighColor READ baseHighColor NOTIFY paletteChanged FINAL)
41 Q_PROPERTY(QColor baseLowColor READ baseLowColor NOTIFY paletteChanged FINAL)
42 Q_PROPERTY(QColor baseMediumColor READ baseMediumColor NOTIFY paletteChanged FINAL)
43 Q_PROPERTY(QColor baseMediumHighColor READ baseMediumHighColor NOTIFY paletteChanged FINAL)
44 Q_PROPERTY(QColor baseMediumLowColor READ baseMediumLowColor NOTIFY paletteChanged FINAL)
45 Q_PROPERTY(QColor chromeAltLowColor READ chromeAltLowColor NOTIFY paletteChanged FINAL)
46 Q_PROPERTY(QColor chromeBlackHighColor READ chromeBlackHighColor NOTIFY paletteChanged FINAL)
47 Q_PROPERTY(QColor chromeBlackLowColor READ chromeBlackLowColor NOTIFY paletteChanged FINAL)
48 Q_PROPERTY(QColor chromeBlackMediumLowColor READ chromeBlackMediumLowColor NOTIFY paletteChanged FINAL)
49 Q_PROPERTY(QColor chromeBlackMediumColor READ chromeBlackMediumColor NOTIFY paletteChanged FINAL)
50 Q_PROPERTY(QColor chromeDisabledHighColor READ chromeDisabledHighColor NOTIFY paletteChanged FINAL)
51 Q_PROPERTY(QColor chromeDisabledLowColor READ chromeDisabledLowColor NOTIFY paletteChanged FINAL)
52 Q_PROPERTY(QColor chromeHighColor READ chromeHighColor NOTIFY paletteChanged FINAL)
53 Q_PROPERTY(QColor chromeLowColor READ chromeLowColor NOTIFY paletteChanged FINAL)
54 Q_PROPERTY(QColor chromeMediumColor READ chromeMediumColor NOTIFY paletteChanged FINAL)
55 Q_PROPERTY(QColor chromeMediumLowColor READ chromeMediumLowColor NOTIFY paletteChanged FINAL)
56 Q_PROPERTY(QColor chromeWhiteColor READ chromeWhiteColor NOTIFY paletteChanged FINAL)
57 Q_PROPERTY(QColor listLowColor READ listLowColor NOTIFY paletteChanged FINAL)
58 Q_PROPERTY(QColor listMediumColor READ listMediumColor NOTIFY paletteChanged FINAL)
59
60 QML_NAMED_ELEMENT(Universal)
64
65public:
66 explicit QQuickUniversalStyle(QObject *parent = nullptr);
67
68 static QQuickUniversalStyle *qmlAttachedProperties(QObject *object);
69
70 enum Theme { Light, Dark, System };
71 Q_ENUM(Theme)
72
73 Theme theme() const;
74 void setTheme(Theme theme);
75 void inheritTheme(Theme theme);
76 void propagateTheme();
77 void resetTheme();
78
101 Q_ENUM(Color)
102
103 QVariant accent() const;
104 void setAccent(const QVariant &accent);
105 void inheritAccent(QRgb accent);
106 void propagateAccent();
107 void resetAccent();
108
109 QVariant foreground() const;
110 void setForeground(const QVariant &foreground);
111 void inheritForeground(QRgb foreground, bool has);
112 void propagateForeground();
113 void resetForeground();
114
115 QVariant background() const;
116 void setBackground(const QVariant &background);
117 void inheritBackground(QRgb background, bool has);
118 void propagateBackground();
119 void resetBackground();
120
121 Q_INVOKABLE QColor color(Color color) const;
122
123 QColor altHighColor() const;
124 QColor altLowColor() const;
125 QColor altMediumColor() const;
126 QColor altMediumHighColor() const;
127 QColor altMediumLowColor() const;
128 QColor baseHighColor() const;
129 QColor baseLowColor() const;
130 QColor baseMediumColor() const;
131 QColor baseMediumHighColor() const;
132 QColor baseMediumLowColor() const;
133 QColor chromeAltLowColor() const;
134 QColor chromeBlackHighColor() const;
135 QColor chromeBlackLowColor() const;
136 QColor chromeBlackMediumLowColor() const;
137 QColor chromeBlackMediumColor() const;
138 QColor chromeDisabledHighColor() const;
139 QColor chromeDisabledLowColor() const;
140 QColor chromeHighColor() const;
141 QColor chromeLowColor() const;
142 QColor chromeMediumColor() const;
143 QColor chromeMediumLowColor() const;
144 QColor chromeWhiteColor() const;
145 QColor listLowColor() const;
146 QColor listMediumColor() const;
147
174
175 QColor systemColor(SystemColor role) const;
176
177 static void initGlobals();
178
185
186protected:
187 void attachedParentChange(QQuickAttachedPropertyPropagator *newParent, QQuickAttachedPropertyPropagator *oldParent) override;
188
189private:
190 bool variantToRgba(const QVariant &var, const char *name, QRgb *rgba) const;
191
192 // These reflect whether a color value was explicitly set on the specific
193 // item that this attached style object represents.
194 bool m_explicitTheme = false;
195 bool m_explicitAccent = false;
196 bool m_explicitForeground = false;
197 bool m_explicitBackground = false;
198 // These will be true when this item has an explicit or inherited foreground/background
199 // color, or these colors were declared globally via settings (e.g. conf or env vars).
200 // Some color properties of the style will return different values depending on whether
201 // or not these are set.
202 bool m_hasForeground = false;
203 bool m_hasBackground = false;
204 // The actual values for this item, whether explicit, inherited or globally set.
205 Theme m_theme = Light;
206 QRgb m_accent = Qt::blue;
207 QRgb m_foreground = Qt::black;
208 QRgb m_background = Qt::white;
209};
210
212
213#endif // QQUICKUNIVERSALSTYLE_P_H
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\inmodule QtCore
Definition qobject.h:103
The QQuickAttachedPropertyPropagator class provides a way to propagate attached properties.
\inmodule QtCore
Definition qvariant.h:65
Combined button and popup list for selecting options.
@ white
Definition qnamespace.h:31
@ blue
Definition qnamespace.h:37
@ black
Definition qnamespace.h:30
GLuint color
[2]
GLuint name
#define QML_UNCREATABLE(REASON)
#define QML_NAMED_ELEMENT(NAME)
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
#define QML_ATTACHED(ATTACHED_TYPE)
decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentRoleName foregroundChanged
decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentRoleName setForeground
QT_BEGIN_NAMESPACE typedef unsigned int QRgb
Definition qrgb.h:13
#define Q_ENUM(x)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_INVOKABLE
#define Q_SIGNALS
#define explicit