From ed9720ffc6b462889e2f501824e9656a6ffde313 Mon Sep 17 00:00:00 2001 From: Nikita Krupenko Date: Thu, 14 Apr 2016 01:08:16 +0300 Subject: Use font from theme for list delegates Change-Id: I48208fb6b5f7df6e1e824d36a256d9b1643cd16d Reviewed-by: J-P Nurmi --- src/imports/controls/material/qquickmaterialtheme.cpp | 5 +++++ src/imports/controls/material/qquickmaterialtheme_p.h | 1 + src/quicktemplates2/qquickcheckdelegate.cpp | 5 +++++ src/quicktemplates2/qquickcheckdelegate_p.h | 2 ++ src/quicktemplates2/qquickradiodelegate.cpp | 5 +++++ src/quicktemplates2/qquickradiodelegate_p.h | 2 ++ src/quicktemplates2/qquickswipedelegate.cpp | 2 +- src/quicktemplates2/qquickswitchdelegate.cpp | 5 +++++ src/quicktemplates2/qquickswitchdelegate_p.h | 1 + 9 files changed, 27 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/imports/controls/material/qquickmaterialtheme.cpp b/src/imports/controls/material/qquickmaterialtheme.cpp index 66febc28..1f3bba49 100644 --- a/src/imports/controls/material/qquickmaterialtheme.cpp +++ b/src/imports/controls/material/qquickmaterialtheme.cpp @@ -53,6 +53,7 @@ QQuickMaterialTheme::QQuickMaterialTheme(QPlatformTheme *theme) systemFont.setFamily(family); buttonFont.setFamily(family); itemViewFont.setFamily(family); + listViewFont.setFamily(family); menuItemFont.setFamily(family); editorFont.setFamily(family); } @@ -66,6 +67,8 @@ QQuickMaterialTheme::QQuickMaterialTheme(QPlatformTheme *theme) itemViewFont.setPixelSize(14); itemViewFont.setWeight(QFont::Medium); + listViewFont.setPixelSize(16); + menuItemFont.setPixelSize(16); editorFont.setPixelSize(16); @@ -80,6 +83,8 @@ const QFont *QQuickMaterialTheme::font(QPlatformTheme::Font type) const return &buttonFont; case QPlatformTheme::ItemViewFont: return &itemViewFont; + case QPlatformTheme::ListViewFont: + return &listViewFont; case QPlatformTheme::MenuItemFont: case QPlatformTheme::ComboMenuItemFont: return &menuItemFont; diff --git a/src/imports/controls/material/qquickmaterialtheme_p.h b/src/imports/controls/material/qquickmaterialtheme_p.h index 92842675..8739a756 100644 --- a/src/imports/controls/material/qquickmaterialtheme_p.h +++ b/src/imports/controls/material/qquickmaterialtheme_p.h @@ -64,6 +64,7 @@ private: QFont systemFont; QFont buttonFont; QFont itemViewFont; + QFont listViewFont; QFont menuItemFont; QFont editorFont; }; diff --git a/src/quicktemplates2/qquickcheckdelegate.cpp b/src/quicktemplates2/qquickcheckdelegate.cpp index 8dafbd7e..2a08e702 100644 --- a/src/quicktemplates2/qquickcheckdelegate.cpp +++ b/src/quicktemplates2/qquickcheckdelegate.cpp @@ -157,6 +157,11 @@ void QQuickCheckDelegate::setCheckState(Qt::CheckState state) emit checkedChanged(); } +QFont QQuickCheckDelegate::defaultFont() const +{ + return QQuickControlPrivate::themeFont(QPlatformTheme::ListViewFont); +} + void QQuickCheckDelegate::checkStateSet() { setCheckState(isChecked() ? Qt::Checked : Qt::Unchecked); diff --git a/src/quicktemplates2/qquickcheckdelegate_p.h b/src/quicktemplates2/qquickcheckdelegate_p.h index 45d5b15f..10b10488 100644 --- a/src/quicktemplates2/qquickcheckdelegate_p.h +++ b/src/quicktemplates2/qquickcheckdelegate_p.h @@ -74,6 +74,8 @@ Q_SIGNALS: void checkStateChanged(); protected: + QFont defaultFont() const override; + void checkStateSet() override; void nextCheckState() override; diff --git a/src/quicktemplates2/qquickradiodelegate.cpp b/src/quicktemplates2/qquickradiodelegate.cpp index 81eb20ae..aff57491 100644 --- a/src/quicktemplates2/qquickradiodelegate.cpp +++ b/src/quicktemplates2/qquickradiodelegate.cpp @@ -85,6 +85,11 @@ QQuickRadioDelegate::QQuickRadioDelegate(QQuickItem *parent) : setAutoExclusive(true); } +QFont QQuickRadioDelegate::defaultFont() const +{ + return QQuickControlPrivate::themeFont(QPlatformTheme::ListViewFont); +} + #ifndef QT_NO_ACCESSIBILITY QAccessible::Role QQuickRadioDelegate::accessibleRole() const { diff --git a/src/quicktemplates2/qquickradiodelegate_p.h b/src/quicktemplates2/qquickradiodelegate_p.h index b77969a8..b5de6aa6 100644 --- a/src/quicktemplates2/qquickradiodelegate_p.h +++ b/src/quicktemplates2/qquickradiodelegate_p.h @@ -62,6 +62,8 @@ public: explicit QQuickRadioDelegate(QQuickItem *parent = nullptr); protected: + QFont defaultFont() const override; + #ifndef QT_NO_ACCESSIBILITY QAccessible::Role accessibleRole() const override; #endif diff --git a/src/quicktemplates2/qquickswipedelegate.cpp b/src/quicktemplates2/qquickswipedelegate.cpp index 82030646..aa54237c 100644 --- a/src/quicktemplates2/qquickswipedelegate.cpp +++ b/src/quicktemplates2/qquickswipedelegate.cpp @@ -842,7 +842,7 @@ void QQuickSwipeDelegate::mouseReleaseEvent(QMouseEvent *event) QFont QQuickSwipeDelegate::defaultFont() const { - return QQuickControlPrivate::themeFont(QPlatformTheme::ItemViewFont); + return QQuickControlPrivate::themeFont(QPlatformTheme::ListViewFont); } #ifndef QT_NO_ACCESSIBILITY diff --git a/src/quicktemplates2/qquickswitchdelegate.cpp b/src/quicktemplates2/qquickswitchdelegate.cpp index aefe2e6d..286d253b 100644 --- a/src/quicktemplates2/qquickswitchdelegate.cpp +++ b/src/quicktemplates2/qquickswitchdelegate.cpp @@ -148,6 +148,11 @@ qreal QQuickSwitchDelegate::visualPosition() const return d->position; } +QFont QQuickSwitchDelegate::defaultFont() const +{ + return QQuickControlPrivate::themeFont(QPlatformTheme::ListViewFont); +} + void QQuickSwitchDelegate::mirrorChange() { QQuickItemDelegate::mirrorChange(); diff --git a/src/quicktemplates2/qquickswitchdelegate_p.h b/src/quicktemplates2/qquickswitchdelegate_p.h index 95b96d31..af931863 100644 --- a/src/quicktemplates2/qquickswitchdelegate_p.h +++ b/src/quicktemplates2/qquickswitchdelegate_p.h @@ -73,6 +73,7 @@ Q_SIGNALS: void visualPositionChanged(); protected: + QFont defaultFont() const override; void mirrorChange() override; private: -- cgit v1.2.3