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
qqstylekitstyle_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 QQSTYLEKITSTYLE_P_H
6#define QQSTYLEKITSTYLE_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
24#include <QtLabsStyleKit/qtlabsstylekitexports.h>
25
26#include <QtQml/QtQml>
27#include <QtQuickTemplates2/private/qquickdeferredpointer_p_p.h>
28
30
31class QQStyleKitTheme;
33
34class Q_LABSSTYLEKIT_EXPORT QQStyleKitStyle : public QQStyleKitStyleAndThemeBase
35{
36 Q_OBJECT
37 Q_PROPERTY(QQuickPalette *palette READ palette NOTIFY paletteChanged FINAL)
38 Q_PROPERTY(QQStyleKitStyle *fallbackStyle READ fallbackStyle WRITE setFallbackStyle NOTIFY fallbackStyleChanged FINAL)
39 Q_PROPERTY(QQmlComponent *light READ light WRITE setLight NOTIFY lightChanged FINAL)
40 Q_PROPERTY(QQmlComponent *dark READ dark WRITE setDark NOTIFY darkChanged FINAL)
41 Q_PROPERTY(QString themeName READ themeName WRITE setThemeName NOTIFY themeNameChanged FINAL)
42 Q_PROPERTY(QStringList themeNames READ themeNames NOTIFY themeNamesChanged FINAL)
43 Q_PROPERTY(QStringList customThemeNames READ customThemeNames NOTIFY customThemeNamesChanged FINAL)
44 Q_PROPERTY(QQStyleKitTheme *theme READ theme NOTIFY themeChanged FINAL)
45
46 Q_CLASSINFO("DeferredPropertyNames", "fallbackStyle")
47 QML_NAMED_ELEMENT(BaseStyle)
48
49public:
50 enum Constants {
51 Stretch = -1, // Use all available space
52 };
53 Q_ENUM(Constants)
54
55 QQStyleKitStyle(QObject *parent = nullptr);
56 ~QQStyleKitStyle();
57
58 QQuickPalette *palette() const;
59
60 QQStyleKitStyle *fallbackStyle() const;
61 void setFallbackStyle(QQStyleKitStyle *fallbackStyle);
62
63 QQmlComponent *light() const;
64 void setLight(QQmlComponent *lightTheme);
65
66 QQmlComponent *dark() const;
67 void setDark(QQmlComponent *darkTheme);
68
69 QList<QQStyleKitCustomTheme *> customThemes() const;
70 QStringList themeNames() const;
71 QStringList customThemeNames() const;
72
73 void setThemeName(const QString &themeName);
74 QString themeName() const;
75 QQStyleKitTheme *theme() const;
76 void recreateTheme();
77
78 bool loaded() const;
79
80 static QQStyleKitStyle *current();
81
82 QPalette paletteForControlType(QQStyleKitExtendableControlType type) const;
83 QFont fontForControlType(QQStyleKitExtendableControlType type) const;
84
85 // For now, used by qqcontrolstowidgetstyle
86 Q_INVOKABLE QList<QObject *> customThemesAsList();
87
88signals:
89 void paletteChanged();
90 void fallbackStyleChanged();
91 void lightChanged();
92 void darkChanged();
93 void themeChanged();
94 void themeNameChanged();
95 void themeNamesChanged();
96 void customThemeNamesChanged();
97
98protected:
99 void componentComplete() override;
100
101private:
102 void parseThemes();
103 void executeFallbackStyle(bool complete = false);
104 void syncFromQPalette(const QPalette &palette);
105 QPalette effectivePalette() const;
106
107 Q_DISABLE_COPY(QQStyleKitStyle)
108
109 bool m_completed = false;
110 bool m_isUpdatingPalette = false;
111
112 QQuickDeferredPointer<QQStyleKitStyle> m_fallbackStyle;
113 QPointer<QQmlComponent> m_light;
114 QPointer<QQmlComponent> m_dark;
115 QPointer<QQStyleKitTheme> m_theme;
116 QPointer<QQmlComponent> m_currentThemeComponent;
117 QQuickPalette *m_paletteProxy = nullptr;
118 QPalette m_effectivePalette;
119 QPointer<QQuickPalette> m_palette;
120 QString m_themeName;
121 QString m_effectiveThemeName;
122 QStringList m_themeNames;
123 QStringList m_customThemeNames;
124
125 friend class QQStyleKitAttached;
126 friend class QQStyleKitPropertyGroup;
127 friend class QQStyleKitPropertyResolver;
128 friend class QQStyleKitDebug;
129};
130
131QT_END_NAMESPACE
132
133#endif // QQSTYLEKITSTYLE_P_H
Q_INVOKABLE bool styleLoaded() const
void setStyleUrl(const QString &styleUrl)
QQStyleKitStyle * style() const
void transitionsEnabledChanged()
void setStyle(QQStyleKitStyle *style)
void setTransitionsEnabled(bool enabled)
QQStyleKitDebug * debug() const
bool transitionsEnabled() const
QString styleUrl() const
void filterChanged()
QString filter() const
void setFilter(const QString &filter)
void setControl(QQuickItem *item)
static Q_INVOKABLE bool insideControl(const QObject *child)
static QQStyleKitAttached * qmlAttachedProperties(QObject *obj=nullptr)
Combined button and popup list for selecting options.