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 QQStyleKitStyle(QObject *parent = nullptr);
51 ~QQStyleKitStyle();
52
53 QQuickPalette *palette() const;
54
55 QQStyleKitStyle *fallbackStyle() const;
56 void setFallbackStyle(QQStyleKitStyle *fallbackStyle);
57
58 QQmlComponent *light() const;
59 void setLight(QQmlComponent *lightTheme);
60
61 QQmlComponent *dark() const;
62 void setDark(QQmlComponent *darkTheme);
63
64 QList<QQStyleKitCustomTheme *> customThemes() const;
65 QStringList themeNames() const;
66 QStringList customThemeNames() const;
67
68 void setThemeName(const QString &themeName);
69 QString themeName() const;
70 QQStyleKitTheme *theme() const;
71 void recreateTheme();
72
73 bool loaded() const;
74
75 static QQStyleKitStyle *current();
76
77 QPalette paletteForControlType(QQStyleKitExtendableControlType type) const;
78 QFont fontForControlType(QQStyleKitExtendableControlType type) const;
79
80 // For now, used by qqcontrolstowidgetstyle
81 Q_INVOKABLE QList<QObject *> customThemesAsList();
82
83signals:
84 void paletteChanged();
85 void fallbackStyleChanged();
86 void lightChanged();
87 void darkChanged();
88 void themeChanged();
89 void themeNameChanged();
90 void themeNamesChanged();
91 void customThemeNamesChanged();
92
93protected:
94 void componentComplete() override;
95
96private:
97 void parseThemes();
98 void reapplyStyle();
99 void executeFallbackStyle(bool complete = false);
100 void syncFromQPalette(const QPalette &palette);
101 QPalette effectivePalette() const;
102
103 Q_DISABLE_COPY(QQStyleKitStyle)
104
105 bool m_completed = false;
106 bool m_isUpdatingPalette = false;
107 bool m_hasVariations = false;
108
109 QQuickDeferredPointer<QQStyleKitStyle> m_fallbackStyle;
110 QPointer<QQmlComponent> m_light;
111 QPointer<QQmlComponent> m_dark;
112 QPointer<QQStyleKitTheme> m_theme;
113 QPointer<QQmlComponent> m_currentThemeComponent;
114 QQuickPalette *m_paletteProxy = nullptr;
115 QPalette m_effectivePalette;
116 QPointer<QQuickPalette> m_palette;
117 QString m_themeName;
118 QString m_effectiveThemeName;
119 QStringList m_themeNames;
120 QStringList m_customThemeNames;
121
122 friend class QQStyleKitAttached;
123 friend class QQStyleKitPropertyGroup;
124 friend class QQStyleKitPropertyResolver;
125 friend class QQStyleKitDebug;
126 friend class QQStyleKitVariation;
127};
128
129QT_END_NAMESPACE
130
131#endif // QQSTYLEKITSTYLE_P_H
Q_INVOKABLE bool styleLoaded() const
QQStyleKitStyle * style() const
QUrl styleUrl() const
void transitionsEnabledChanged()
void setStyle(QQStyleKitStyle *style)
void setTransitionsEnabled(bool enabled)
QQStyleKitDebug * debug() const
bool transitionsEnabled() const
void setStyleUrl(const QUrl &styleUrl)
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.