4#include <QtQuickTemplates2/private/qquicktheme_p.h>
5#include <QtQuick/private/qquickpalette_p.h>
6#include <QtGui/private/qguiapplication_p.h>
7#include <QtGui/qpa/qplatformtheme.h>
17 case QQStyleKitReader::ControlType::AbstractButton:
18 case QQStyleKitReader::ControlType::Button:
19 case QQStyleKitReader::ControlType::FlatButton:
20 return QQuickTheme::Button;
21 case QQStyleKitReader::ControlType::CheckBox:
22 return QQuickTheme::CheckBox;
23 case QQStyleKitReader::ControlType::ComboBox:
24 return QQuickTheme::ComboBox;
25 case QQStyleKitReader::ControlType::GroupBox:
26 return QQuickTheme::GroupBox;
27 case QQStyleKitReader::ControlType::ItemDelegate:
28 return QQuickTheme::ItemView;
29 case QQStyleKitReader::ControlType::Label:
30 return QQuickTheme::Label;
31 case QQStyleKitReader::ControlType::RadioButton:
32 return QQuickTheme::RadioButton;
33 case QQStyleKitReader::ControlType::SpinBox:
34 return QQuickTheme::SpinBox;
35 case QQStyleKitReader::ControlType::SwitchControl:
36 return QQuickTheme::Switch;
37 case QQStyleKitReader::ControlType::TabBar:
38 case QQStyleKitReader::ControlType::TabButton:
39 return QQuickTheme::TabBar;
40 case QQStyleKitReader::ControlType::TextArea:
41 return QQuickTheme::TextArea;
42 case QQStyleKitReader::ControlType::TextInput:
43 case QQStyleKitReader::ControlType::TextField:
44 return QQuickTheme::TextField;
45 case QQStyleKitReader::ControlType::ToolBar:
46 case QQStyleKitReader::ControlType::ToolButton:
47 case QQStyleKitReader::ControlType::ToolSeparator:
48 return QQuickTheme::ToolBar;
50 return QQuickTheme::System;
62 QObject *parentObj = parent();
71 const QQuickTheme::Scope scope = scopeForType(type);
72 return effectivePaletteForScope(scope);
77 const QQuickTheme::Scope scope = scopeForType(type);
78 if (scope < QQuickTheme::System || scope >= NScopes) {
79 qWarning() << Q_FUNC_INFO <<
"Invalid scope" <<
int(scope);
82 return m_effectiveFonts[
int(scope)];
85QPalette
QQStyleKitTheme::effectivePaletteForScope(QQuickTheme::Scope scope)
const
87 if (scope < QQuickTheme::System || scope >= NScopes) {
88 qWarning() << Q_FUNC_INFO <<
"Invalid scope" <<
int(scope);
92 return m_effectivePalettes[
int(scope)];
97 const QQStyleKitPalette *pals =
palettes();
102 QVector<
const QQStyleKitPalette *> fbChain;
103 for (
auto *fb = pals; fb; fb = fb->fallbackPalette())
106 auto resolveFromPaletteChain = [&](QQuickTheme::Scope scope,
107 QQuickPalette* (QQStyleKitPalette::*getter)()
const) -> QPalette
112 for (
int i = fbChain.size() - 1; i >= 0; --i) {
113 const QQStyleKitPalette *fb = fbChain[i];
114 if (fb->isSet(scope)) {
115 if (
auto *p = (fb->*getter)())
116 result = p->toQPalette().resolve(result);
118 if (scope != QQuickTheme::System && fb->isSet(QQuickTheme::System)) {
119 if (
auto *sys = fb->system())
120 result = sys->toQPalette().resolve(result);
127 auto setResolved = [&](QQuickPalette* (QQStyleKitPalette::*getter)()
const,
128 QQuickTheme::Scope scope)
130 m_effectivePalettes[
int(scope)] = resolveFromPaletteChain(scope, getter);
133 setResolved(&QQStyleKitPalette::system, QQuickTheme::System);
134 setResolved(&QQStyleKitPalette::button, QQuickTheme::Button);
135 setResolved(&QQStyleKitPalette::checkBox, QQuickTheme::CheckBox);
136 setResolved(&QQStyleKitPalette::comboBox, QQuickTheme::ComboBox);
137 setResolved(&QQStyleKitPalette::groupBox, QQuickTheme::GroupBox);
138 setResolved(&QQStyleKitPalette::itemView, QQuickTheme::ItemView);
139 setResolved(&QQStyleKitPalette::label, QQuickTheme::Label);
140 setResolved(&QQStyleKitPalette::listView, QQuickTheme::ListView);
141 setResolved(&QQStyleKitPalette::menu, QQuickTheme::Menu);
142 setResolved(&QQStyleKitPalette::menuBar, QQuickTheme::MenuBar);
143 setResolved(&QQStyleKitPalette::radioButton, QQuickTheme::RadioButton);
144 setResolved(&QQStyleKitPalette::spinBox, QQuickTheme::SpinBox);
145 setResolved(&QQStyleKitPalette::switchControl, QQuickTheme::Switch);
146 setResolved(&QQStyleKitPalette::tabBar, QQuickTheme::TabBar);
147 setResolved(&QQStyleKitPalette::textArea, QQuickTheme::TextArea);
148 setResolved(&QQStyleKitPalette::textField, QQuickTheme::TextField);
149 setResolved(&QQStyleKitPalette::toolBar, QQuickTheme::ToolBar);
150 setResolved(&QQStyleKitPalette::toolTip, QQuickTheme::ToolTip);
151 setResolved(&QQStyleKitPalette::tumbler, QQuickTheme::Tumbler);
156 const QQStyleKitFont *fonts =
this->fonts();
161 QVector<
const QQStyleKitFont *> fbChain;
162 for (
auto *fb = fonts; fb; fb = fb->fallbackFont())
165 auto resolveFromFontChain = [&](QQuickTheme::Scope scope) -> QFont
170 for (
int i = fbChain.size() - 1; i >= 0; --i) {
171 const QQStyleKitFont *fb = fbChain[i];
172 if (fb->isSet(scope)) {
173 result = fb->fontForScope(scope).resolve(result);
175 if (scope != QQuickTheme::System && fb->isSet(QQuickTheme::System)) {
176 result = fb->fontForScope(QQuickTheme::System).resolve(result);
183 for (
int i = 0; i < NScopes; ++i) {
184 const QQuickTheme::Scope scope =
static_cast<QQuickTheme::Scope>(i);
185 m_effectiveFonts[i] = resolveFromFontChain(scope);
197#include "moc_qqstylekittheme_p.cpp"
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
QQStyleKitPalette * palettes()
QQStyleKitStyle * style() const
QFont fontForControlType(QQStyleKitExtendableControlType type) const
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
QPalette paletteForControlType(QQStyleKitExtendableControlType type) const
Combined button and popup list for selecting options.
static QT_BEGIN_NAMESPACE QQuickTheme::Scope scopeForType(QQStyleKitExtendableControlType type)