diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-05-09 22:49:01 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-05-10 08:43:53 +0000 |
commit | 3b7e13510b355333c4215d04a731240201401a9d (patch) | |
tree | a17c42fedd0c62274c16b606a2bcd2e753a87d77 /src/quicktemplates2/qquicklabel_p_p.h | |
parent | 87c1b763147f0dd15e7724fd2a41244dd856613c (diff) |
Cleanup and unify font handling
First of all, move the remaining user requested fonts to ExtraData.
This was done for QQuickControl, but not for the controls that do not
inherit QQuickControl: QQuickLabel, QQuickTextField & QQuickTextArea.
The ExtraData starts really paying off later when introducing palettes
that propagate similarly to fonts.
Furthermore, give a more explicit name ('font' vs. 'requestedFont')
for the user requested fonts. This lets us use 'font' (instead of just
'f') as an argument name in those various font-helper methods in the
private classes. Furthermore, sync QQuickLabel|TextField|TextArea's
font handling with QQuickControl. It would be best to share the code
somehow, but it's quite tricky due to different base classes, font
members ('resolvedFont' vs. 'sourceFont'), and notifier signals.
Change-Id: I50cc1af160bb033ae604b4239e438c083d83f15d
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquicklabel_p_p.h')
-rw-r--r-- | src/quicktemplates2/qquicklabel_p_p.h | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/quicktemplates2/qquicklabel_p_p.h b/src/quicktemplates2/qquicklabel_p_p.h index c24c855b..dadd63df 100644 --- a/src/quicktemplates2/qquicklabel_p_p.h +++ b/src/quicktemplates2/qquicklabel_p_p.h @@ -48,6 +48,7 @@ // We mean it. // +#include <QtQml/private/qlazilyallocated_p.h> #include <QtQuick/private/qquicktext_p_p.h> #if QT_CONFIG(accessibility) @@ -75,7 +76,13 @@ public: } void resolveFont(); - void inheritFont(const QFont &f); + void inheritFont(const QFont &font); + void updateFont(const QFont &font); + inline void setFont_helper(const QFont &font) { + if (sourceFont.resolve() == font.resolve() && sourceFont == font) + return; + updateFont(font); + } void textChanged(const QString &text); @@ -84,7 +91,11 @@ public: QAccessible::Role accessibleRole() const override; #endif - QFont font; + struct ExtraData { + QFont requestedFont; + }; + QLazilyAllocated<ExtraData> extra; + QQuickItem *background; QQuickAccessibleAttached *accessibleAttached; }; |