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
qqstylekitglobal_p.h
Go to the documentation of this file.
1// Copyright (C) 2025 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
5#ifndef QQSTYLEKITGLOBAL_P_H
6#define QQSTYLEKITGLOBAL_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtLabsStyleKit/qtlabsstylekitexports.h>
20#include <QtQml/QtQml>
21
23
24class Q_LABSSTYLEKIT_EXPORT QQSK: public QObject
25{
26 Q_OBJECT
27
28public:
29 enum class Delegate {
30 NoDelegate = 0x0000,
31 Control = 0x0001,
32 Background = 0x0002,
33 Handle = 0x0004,
34 HandleFirst = 0x0008,
35 HandleSecond = 0x0010,
36 Indicator = 0x0020,
37 IndicatorForeground = 0x0040,
38 IndicatorFirst = 0x0080,
39 IndicatorFirstForeground = 0x0100,
40 IndicatorSecond = 0x0200,
41 IndicatorSecondForeground = 0x0400,
42 // Note: for now, "control.text" is not treated as a separate delegate, but
43 // as an integrated part of "control". Hence, there is no "Text" value in this enum.
44 };
45 Q_DECLARE_FLAGS(Delegates, Delegate)
46 Q_FLAG(Delegate)
47
48 enum class PropertyGroup {
49 Control,
50 Background,
51 Foreground,
52 Border,
53 Handle,
54 Image,
55 Indicator,
56 Shadow,
57 Text,
58 PATH_ID_GROUP_COUNT,
59
60 /* Sub types, like states, are a part of a propertys storage ID, not its Path ID.
61 * They appear in the group path, but are handled differently. */
62 DelegateSubtype0,
63 DelegateSubtype1,
64 DelegateSubtype2,
65
66 /* Read options are not a part of either the Path ID nor the Storage ID. They
67 * just offer a convenient API for providing read options when reading a property.
68 * The Global flag is used to signal that a property should be read directly from
69 * the global style, circumventing the local StyleKitReader cache. */
70 GlobalFlag,
71
72 Unspecified
73 };
74 Q_ENUM(PropertyGroup)
75
76 enum class PropertyPathFlag : quint8 {
77 NoFlags = 0x0,
78 DelegateSubtype0 = 0x1,
79 DelegateSubtype1 = 0x2,
80 DelegateSubtype2 = 0x4,
81 Global = 0x8
82 };
83 Q_DECLARE_FLAGS(PropertyPathFlags, PropertyPathFlag)
84 Q_FLAG(PropertyPathFlag)
85
86 enum class Property {
87 NoProperty,
88 BottomLeftRadius,
89 BottomMargin,
90 BottomPadding,
91 BottomRightRadius,
92 Clip,
93 Color,
94 Data,
95 Delegate,
96 FillMode,
97 FillWidth,
98 FillHeight,
99 Gradient,
100 HOffset,
101 Image,
102 LeftMargin,
103 LeftPadding,
104 Margins,
105 MinimumWidth,
106 MinimumHeight,
107 Opacity,
108 Padding,
109 Radius,
110 RightMargin,
111 RightPadding,
112 Rotation,
113 Scale,
114 Source,
115 Spacing,
116 TopLeftRadius,
117 TopMargin,
118 TopPadding,
119 TopRightRadius,
120 Transition,
121 Variations,
122 Visible,
123 VOffset,
124 Width,
125 Height,
126 Blur,
127 Alignment,
128 Bold,
129 Italic,
130 PointSize,
131 COUNT
132 };
133 Q_ENUM(Property)
134
135 enum class StateFlag {
136 Unspecified = 0x000,
137 Normal = 0x001,
138 Pressed = 0x002,
139 Hovered = 0x004,
140 Highlighted = 0x008,
141 Focused = 0x010,
142 Checked = 0x020,
143 Vertical = 0x040,
144 Disabled = 0x080,
145 MAX_STATE = 0x100,
146 };
147 Q_DECLARE_FLAGS(State, StateFlag)
148 Q_FLAG(State)
149
150 enum class Subclass {
151 QQStyleKitState,
152 QQStyleKitReader,
153 };
154 Q_ENUM(Subclass)
155
156public:
157 template <typename T, typename Owner, typename... Args>
158 static inline T *lazyCreate(T *const &ptr, const Owner *self, Args&&... args)
159 {
160 if (!ptr) {
161 auto *mutableSelf = const_cast<Owner *>(self);
162 auto *&mutablePtr = const_cast<T *&>(ptr);
163 mutablePtr = new T(std::forward<Args>(args)..., mutableSelf);
164 }
165 return ptr;
166 }
167};
168
169Q_DECLARE_OPERATORS_FOR_FLAGS(QQSK::State)
170Q_DECLARE_OPERATORS_FOR_FLAGS(QQSK::Delegates)
171Q_DECLARE_OPERATORS_FOR_FLAGS(QQSK::PropertyPathFlags)
172
173QT_END_NAMESPACE
174
175#endif // QQSTYLEKITGLOBAL_P_H
QQStyleKitDelegateProperties * delegateStyle() const
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override
void setDelegateStyle(QQStyleKitDelegateProperties *delegateProperties)
bool setStyleProperty(QQSK::Property property, T value)
QQStyleKitPropertyGroupSpace m_groupSpace
T styleProperty(QQSK::Property property, QQSK::Property alternative=QQSK::Property::NoProperty) const
T * lazyCreateGroup(T *const &ptr, QQSK::PropertyGroup group) const
void forEachRelevantStyleReader(const QQStyleKitControl *control, const std::function< void(QQStyleKitReader *reader)> &f) const
void handleStylePropertyChanged(void(SUBCLASS::*changedSignal)())
virtual void forEachExistingNestedGroup(const std::function< void(QQStyleKitPropertyGroup *)> &f) const
void handleStylePropertiesChanged(CHANGED_SIGNALS... changedSignals)
bool isDefined(QQSK::Property property) const
QQStyleKitControlProperties * controlProperties() const
PropertyPathId pathId() const
static QString storageIdToPathString(PropertyStorageId storageId)
Combined button and popup list for selecting options.
constexpr PropertyPathId subtypeStorageSpaceSize
constexpr PropertyPathId stateStorageSpaceSize
constexpr PropertyPathId maxPropertyStorageSpaceSize
constexpr PropertyPathId nestedGroupCount
constexpr PropertyPathId maxStateCombinationCount
constexpr PropertyPathId nestedGroupsStartSize
constexpr PropertyPathId subtypeCount