diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2018-03-14 13:04:30 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2018-03-15 07:50:30 +0000 |
commit | 63773fd5363e8954e298e775bba7478d612134ef (patch) | |
tree | 6b85eecb285a010f6ba488cc631cd8107c6cdb76 /src/quicktemplates2/qquicktheme.cpp | |
parent | 24750ce0624e8b6ec66d07d7d00877c4a928dfc3 (diff) |
QQuickTheme: add missing fonts and palettes
SpinBox, Switch, and Tumbler were previously not available in
QPlatformTheme, but now we have our own enums so we can add them.
Task-number: QTBUG-67062
Change-Id: Ie99a49b464fbbd25051181b75d721f537b8e3a68
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquicktheme.cpp')
-rw-r--r-- | src/quicktemplates2/qquicktheme.cpp | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/quicktemplates2/qquicktheme.cpp b/src/quicktemplates2/qquicktheme.cpp index 02389ed0..777480b2 100644 --- a/src/quicktemplates2/qquicktheme.cpp +++ b/src/quicktemplates2/qquicktheme.cpp @@ -44,6 +44,34 @@ QT_BEGIN_NAMESPACE QScopedPointer<QQuickTheme> QQuickThemePrivate::current; +static QPlatformTheme::Font platformFont(QQuickTheme::Font type) +{ + 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); + } +} + +static QPlatformTheme::Palette platformPalette(QQuickTheme::Palette type) +{ + 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); + } +} + QQuickTheme::QQuickTheme() : d_ptr(new QQuickThemePrivate) { @@ -69,7 +97,7 @@ QFont QQuickTheme::themeFont(Font type) if (QQuickTheme *theme = current()) font = theme->font(type); else if (QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) - font = theme->font(static_cast<QPlatformTheme::Font>(type)); + font = theme->font(platformFont(type)); if (font) { QFont f = *font; @@ -87,7 +115,7 @@ QPalette QQuickTheme::themePalette(Palette type) if (QQuickTheme *theme = current()) palette = theme->palette(type); else if (QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) - palette = theme->palette(static_cast<QPlatformTheme::Palette>(type)); + palette = theme->palette(platformPalette(type)); if (palette) { QPalette f = *palette; |