Qt 6.x
The Qt SDK
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
23
24class QQuickUniversalStylePrivate;
25
27{
29 Q_PROPERTY(Theme theme READ theme WRITE setTheme RESET resetTheme NOTIFY themeChanged FINAL)
33
58
59 QML_NAMED_ELEMENT(Universal)
63
64public:
65 explicit QQuickUniversalStyle(QObject *parent = nullptr);
66
68
69 enum Theme { Light, Dark, System };
71
72 Theme theme() const;
73 void setTheme(Theme theme);
75 void propagateTheme();
76 void resetTheme();
77
78 enum Color {
98 Taupe
99 };
101
102 QVariant accent() const;
103 void setAccent(const QVariant &accent);
105 void propagateAccent();
106 void resetAccent();
107
108 QVariant foreground() const;
109 void setForeground(const QVariant &foreground);
110 void inheritForeground(QRgb foreground, bool has);
111 void propagateForeground();
112 void resetForeground();
113
114 QVariant background() const;
115 void setBackground(const QVariant &background);
116 void inheritBackground(QRgb background, bool has);
117 void propagateBackground();
118 void resetBackground();
119
121
122 QColor altHighColor() const;
123 QColor altLowColor() const;
124 QColor altMediumColor() const;
127 QColor baseHighColor() const;
128 QColor baseLowColor() const;
129 QColor baseMediumColor() const;
139 QColor chromeHighColor() const;
140 QColor chromeLowColor() const;
143 QColor chromeWhiteColor() const;
144 QColor listLowColor() const;
145 QColor listMediumColor() const;
146
172 };
173
174 QColor systemColor(SystemColor role) const;
175
176 static void initGlobals();
177
184
185protected:
187
188private:
189 bool variantToRgba(const QVariant &var, const char *name, QRgb *rgba) const;
190
191 // These reflect whether a color value was explicitly set on the specific
192 // item that this attached style object represents.
193 bool m_explicitTheme = false;
194 bool m_explicitAccent = false;
195 bool m_explicitForeground = false;
196 bool m_explicitBackground = false;
197 // These will be true when this item has an explicit or inherited foreground/background
198 // color, or these colors were declared globally via settings (e.g. conf or env vars).
199 // Some color properties of the style will return different values depending on whether
200 // or not these are set.
201 bool m_hasForeground = false;
202 bool m_hasBackground = false;
203 // The actual values for this item, whether explicit, inherited or globally set.
204 Theme m_theme = Light;
205 QRgb m_accent = Qt::blue;
206 QRgb m_foreground = Qt::black;
207 QRgb m_background = Qt::white;
208};
209
211
212#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:90
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:311
The QQuickAttachedPropertyPropagator class provides a way to propagate attached properties.
void inheritBackground(QRgb background, bool has)
void setAccent(const QVariant &accent)
void inheritForeground(QRgb foreground, bool has)
QColor systemColor(SystemColor role) const
void inheritAccent(QRgb accent)
static QQuickUniversalStyle * qmlAttachedProperties(QObject *object)
void attachedParentChange(QQuickAttachedPropertyPropagator *newParent, QQuickAttachedPropertyPropagator *oldParent) override
This function is called whenever the attached parent of this QQuickAttachedPropertyPropagator changes...
void setBackground(const QVariant &background)
\inmodule QtCore
Definition qvariant.h:64
Combined button and popup list for selecting options.
@ white
Definition qnamespace.h:30
@ blue
Definition qnamespace.h:36
@ black
Definition qnamespace.h:29
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 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