aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquicktheme.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2018-03-14 14:56:00 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2018-03-15 13:00:53 +0000
commit87d3e84c75839b736d45f2773fc5fb4ecce14296 (patch)
treed580764ae48ed0226763b9ad56a12c566acd8a75 /src/quicktemplates2/qquicktheme.cpp
parent6d879ab06a95d6b49e5ca4ad0af12024d5d2a988 (diff)
Add QQuickTheme::Scope
Replace the old enums that were originally copied from QPlatformTheme, including irrelevant entries for DockWidget, MdiSubWindow, MessageBox, with a unified enum that will be matched to cover everything needed for theming fonts and palettes for Qt Quick Controls 2. Task-number: QTBUG-67062 Change-Id: Ia99d092f28c00210c0c7f24d4241eb5a5d9ceb5b Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquicktheme.cpp')
-rw-r--r--src/quicktemplates2/qquicktheme.cpp94
1 files changed, 58 insertions, 36 deletions
diff --git a/src/quicktemplates2/qquicktheme.cpp b/src/quicktemplates2/qquicktheme.cpp
index 41d15014..30185fe2 100644
--- a/src/quicktemplates2/qquicktheme.cpp
+++ b/src/quicktemplates2/qquicktheme.cpp
@@ -44,35 +44,57 @@ QT_BEGIN_NAMESPACE
QScopedPointer<QQuickTheme> QQuickThemePrivate::current;
-static QPlatformTheme::Font platformFont(QQuickTheme::Font type)
+static QPlatformTheme::Font platformFont(QQuickTheme::Scope scope)
{
- switch (type) {
- case QQuickTheme::SpinBoxFont:
- return QPlatformTheme::EditorFont;
- case QQuickTheme::SwitchFont:
- return QPlatformTheme::CheckBoxFont;
- case QQuickTheme::TumblerFont:
- return QPlatformTheme::ItemViewFont;
- default:
- return static_cast<QPlatformTheme::Font>(type);
+ switch (scope) {
+ case QQuickTheme::Button: return QPlatformTheme::PushButtonFont;
+ case QQuickTheme::CheckBox: return QPlatformTheme::CheckBoxFont;
+ case QQuickTheme::ComboBox: return QPlatformTheme::ComboMenuItemFont;
+ case QQuickTheme::GroupBox: return QPlatformTheme::GroupBoxTitleFont;
+ case QQuickTheme::ItemView: return QPlatformTheme::ItemViewFont;
+ case QQuickTheme::Label: return QPlatformTheme::LabelFont;
+ case QQuickTheme::ListView: return QPlatformTheme::ListViewFont;
+ case QQuickTheme::Menu: return QPlatformTheme::MenuFont;
+ case QQuickTheme::MenuBar: return QPlatformTheme::MenuBarFont;
+ case QQuickTheme::RadioButton: return QPlatformTheme::RadioButtonFont;
+ case QQuickTheme::SpinBox: return QPlatformTheme::EditorFont;
+ case QQuickTheme::Switch: return QPlatformTheme::CheckBoxFont;
+ case QQuickTheme::TabBar: return QPlatformTheme::TabButtonFont;
+ case QQuickTheme::TextArea: return QPlatformTheme::EditorFont;
+ case QQuickTheme::TextField: return QPlatformTheme::EditorFont;
+ case QQuickTheme::ToolBar: return QPlatformTheme::ToolButtonFont;
+ case QQuickTheme::ToolTip: return QPlatformTheme::TipLabelFont;
+ case QQuickTheme::Tumbler: return QPlatformTheme::ItemViewFont;
+ default: return QPlatformTheme::SystemFont;
}
}
-static QPlatformTheme::Palette platformPalette(QQuickTheme::Palette type)
+static QPlatformTheme::Palette platformPalette(QQuickTheme::Scope scope)
{
- switch (type) {
- case QQuickTheme::SpinBoxPalette:
- return QPlatformTheme::TextLineEditPalette;
- case QQuickTheme::SwitchPalette:
- return QPlatformTheme::CheckBoxPalette;
- case QQuickTheme::TumblerPalette:
- return QPlatformTheme::ItemViewPalette;
- default:
- return static_cast<QPlatformTheme::Palette>(type);
+ switch (scope) {
+ case QQuickTheme::Button: return QPlatformTheme::ButtonPalette;
+ case QQuickTheme::CheckBox: return QPlatformTheme::CheckBoxPalette;
+ case QQuickTheme::ComboBox: return QPlatformTheme::ComboBoxPalette;
+ case QQuickTheme::GroupBox: return QPlatformTheme::GroupBoxPalette;
+ case QQuickTheme::ItemView: return QPlatformTheme::ItemViewPalette;
+ case QQuickTheme::Label: return QPlatformTheme::LabelPalette;
+ case QQuickTheme::ListView: return QPlatformTheme::ItemViewPalette;
+ case QQuickTheme::Menu: return QPlatformTheme::MenuPalette;
+ case QQuickTheme::MenuBar: return QPlatformTheme::MenuBarPalette;
+ case QQuickTheme::RadioButton: return QPlatformTheme::RadioButtonPalette;
+ case QQuickTheme::SpinBox: return QPlatformTheme::TextLineEditPalette;
+ case QQuickTheme::Switch: return QPlatformTheme::CheckBoxPalette;
+ case QQuickTheme::TabBar: return QPlatformTheme::TabBarPalette;
+ case QQuickTheme::TextArea: return QPlatformTheme::TextEditPalette;
+ case QQuickTheme::TextField: return QPlatformTheme::TextLineEditPalette;
+ case QQuickTheme::ToolBar: return QPlatformTheme::ToolButtonPalette;
+ case QQuickTheme::ToolTip: return QPlatformTheme::ToolTipPalette;
+ case QQuickTheme::Tumbler: return QPlatformTheme::ItemViewPalette;
+ default: return QPlatformTheme::SystemPalette;
}
}
-const QFont *QQuickThemePrivate::resolveThemeFont(QQuickTheme::Font type)
+const QFont *QQuickThemePrivate::resolveThemeFont(QQuickTheme::Scope scope)
{
Q_Q(QQuickTheme);
if (!hasResolvedFonts) {
@@ -80,10 +102,10 @@ const QFont *QQuickThemePrivate::resolveThemeFont(QQuickTheme::Font type)
hasResolvedFonts = true;
defaultFont.reset();
}
- return q->font(type);
+ return q->font(scope);
}
-const QPalette *QQuickThemePrivate::resolveThemePalette(QQuickTheme::Palette type)
+const QPalette *QQuickThemePrivate::resolveThemePalette(QQuickTheme::Scope scope)
{
Q_Q(QQuickTheme);
if (!hasResolvedPalettes) {
@@ -91,7 +113,7 @@ const QPalette *QQuickThemePrivate::resolveThemePalette(QQuickTheme::Palette typ
hasResolvedPalettes = true;
defaultPalette.reset();
}
- return q->palette(type);
+ return q->palette(scope);
}
QQuickTheme::QQuickTheme()
@@ -114,17 +136,17 @@ void QQuickTheme::setCurrent(QQuickTheme *theme)
QQuickThemePrivate::current.reset(theme);
}
-QFont QQuickTheme::themeFont(Font type)
+QFont QQuickTheme::themeFont(Scope scope)
{
const QFont *font = nullptr;
if (QQuickTheme *theme = current())
- font = QQuickThemePrivate::get(theme)->resolveThemeFont(type);
+ font = QQuickThemePrivate::get(theme)->resolveThemeFont(scope);
else if (QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme())
- font = theme->font(platformFont(type));
+ font = theme->font(platformFont(scope));
if (font) {
QFont f = *font;
- if (type == SystemFont)
+ if (scope == System)
f.resolve(0);
return f;
}
@@ -132,17 +154,17 @@ QFont QQuickTheme::themeFont(Font type)
return QFont();
}
-QPalette QQuickTheme::themePalette(Palette type)
+QPalette QQuickTheme::themePalette(Scope scope)
{
const QPalette *palette = nullptr;
if (QQuickTheme *theme = current())
- palette = QQuickThemePrivate::get(theme)->resolveThemePalette(type);
+ palette = QQuickThemePrivate::get(theme)->resolveThemePalette(scope);
else if (QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme())
- palette = theme->palette(platformPalette(type));
+ palette = theme->palette(platformPalette(scope));
if (palette) {
QPalette f = *palette;
- if (type == SystemPalette)
+ if (scope == System)
f.resolve(0);
return f;
}
@@ -150,17 +172,17 @@ QPalette QQuickTheme::themePalette(Palette type)
return QPalette();
}
-const QFont *QQuickTheme::font(Font type) const
+const QFont *QQuickTheme::font(Scope scope) const
{
Q_D(const QQuickTheme);
- Q_UNUSED(type)
+ Q_UNUSED(scope)
return d->defaultFont.data();
}
-const QPalette *QQuickTheme::palette(Palette type) const
+const QPalette *QQuickTheme::palette(Scope scope) const
{
Q_D(const QQuickTheme);
- Q_UNUSED(type)
+ Q_UNUSED(scope)
return d->defaultPalette.data();
}