aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2018-03-14 13:04:30 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2018-03-15 07:50:30 +0000
commit63773fd5363e8954e298e775bba7478d612134ef (patch)
tree6b85eecb285a010f6ba488cc631cd8107c6cdb76 /src/quicktemplates2
parent24750ce0624e8b6ec66d07d7d00877c4a928dfc3 (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')
-rw-r--r--src/quicktemplates2/qquickspinbox.cpp4
-rw-r--r--src/quicktemplates2/qquickswitch.cpp8
-rw-r--r--src/quicktemplates2/qquickswitch_p.h1
-rw-r--r--src/quicktemplates2/qquicktheme.cpp32
-rw-r--r--src/quicktemplates2/qquicktheme_p.h6
-rw-r--r--src/quicktemplates2/qquicktumbler.cpp4
6 files changed, 47 insertions, 8 deletions
diff --git a/src/quicktemplates2/qquickspinbox.cpp b/src/quicktemplates2/qquickspinbox.cpp
index 8aa8ed5f..93cb3261 100644
--- a/src/quicktemplates2/qquickspinbox.cpp
+++ b/src/quicktemplates2/qquickspinbox.cpp
@@ -1024,12 +1024,12 @@ void QQuickSpinBox::localeChange(const QLocale &newLocale, const QLocale &oldLoc
QFont QQuickSpinBox::defaultFont() const
{
- return QQuickTheme::themeFont(QQuickTheme::EditorFont);
+ return QQuickTheme::themeFont(QQuickTheme::SpinBoxFont);
}
QPalette QQuickSpinBox::defaultPalette() const
{
- return QQuickTheme::themePalette(QQuickTheme::TextLineEditPalette);
+ return QQuickTheme::themePalette(QQuickTheme::SpinBoxPalette);
}
#if QT_CONFIG(accessibility)
diff --git a/src/quicktemplates2/qquickswitch.cpp b/src/quicktemplates2/qquickswitch.cpp
index db71e423..5e3ccbc9 100644
--- a/src/quicktemplates2/qquickswitch.cpp
+++ b/src/quicktemplates2/qquickswitch.cpp
@@ -231,10 +231,14 @@ void QQuickSwitch::buttonChange(ButtonChange change)
QQuickAbstractButton::buttonChange(change);
}
+QFont QQuickSwitch::defaultFont() const
+{
+ return QQuickTheme::themeFont(QQuickTheme::SwitchFont);
+}
+
QPalette QQuickSwitch::defaultPalette() const
{
- // ### TODO: add QPlatformTheme::SwitchPalette
- return QQuickTheme::themePalette(QQuickTheme::CheckBoxPalette);
+ return QQuickTheme::themePalette(QQuickTheme::SwitchPalette);
}
QT_END_NAMESPACE
diff --git a/src/quicktemplates2/qquickswitch_p.h b/src/quicktemplates2/qquickswitch_p.h
index 0faaf114..ddc32395 100644
--- a/src/quicktemplates2/qquickswitch_p.h
+++ b/src/quicktemplates2/qquickswitch_p.h
@@ -83,6 +83,7 @@ protected:
void nextCheckState() override;
void buttonChange(ButtonChange change) override;
+ QFont defaultFont() const override;
QPalette defaultPalette() const override;
private:
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;
diff --git a/src/quicktemplates2/qquicktheme_p.h b/src/quicktemplates2/qquicktheme_p.h
index f4efd359..6d37039e 100644
--- a/src/quicktemplates2/qquicktheme_p.h
+++ b/src/quicktemplates2/qquicktheme_p.h
@@ -94,6 +94,9 @@ public:
GroupBoxTitleFont,
TabButtonFont,
EditorFont,
+ SwitchFont,
+ SpinBoxFont,
+ TumblerFont,
NFonts
};
@@ -116,6 +119,9 @@ public:
MenuBarPalette,
TextEditPalette,
TextLineEditPalette,
+ SpinBoxPalette,
+ SwitchPalette,
+ TumblerPalette,
NPalettes
};
diff --git a/src/quicktemplates2/qquicktumbler.cpp b/src/quicktemplates2/qquicktumbler.cpp
index fa3a5ce4..f2797c29 100644
--- a/src/quicktemplates2/qquicktumbler.cpp
+++ b/src/quicktemplates2/qquicktumbler.cpp
@@ -830,12 +830,12 @@ void QQuickTumbler::updatePolish()
QFont QQuickTumbler::defaultFont() const
{
- return QQuickTheme::themeFont(QQuickTheme::ItemViewFont);
+ return QQuickTheme::themeFont(QQuickTheme::TumblerFont);
}
QPalette QQuickTumbler::defaultPalette() const
{
- return QQuickTheme::themePalette(QQuickTheme::ItemViewPalette);
+ return QQuickTheme::themePalette(QQuickTheme::TumblerPalette);
}
QQuickTumblerAttachedPrivate::QQuickTumblerAttachedPrivate()