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/qquicktextfield_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/qquicktextfield_p_p.h')
-rw-r--r-- | src/quicktemplates2/qquicktextfield_p_p.h | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/quicktemplates2/qquicktextfield_p_p.h b/src/quicktemplates2/qquicktextfield_p_p.h index e8dc625b..6f36dda4 100644 --- a/src/quicktemplates2/qquicktextfield_p_p.h +++ b/src/quicktemplates2/qquicktextfield_p_p.h @@ -48,6 +48,7 @@ // We mean it. // +#include <QtQml/private/qlazilyallocated_p.h> #include <QtQuick/private/qquicktextinput_p_p.h> #include <QtQuickTemplates2/private/qquickpresshandler_p_p.h> @@ -76,8 +77,15 @@ public: return static_cast<QQuickTextFieldPrivate *>(QObjectPrivate::get(item)); } void resizeBackground(); + 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); + } #if QT_CONFIG(quicktemplates2_hover) void updateHoverEnabled(bool h, bool e); @@ -101,7 +109,12 @@ public: bool hovered; bool explicitHoverEnabled; #endif - QFont font; + + struct ExtraData { + QFont requestedFont; + }; + QLazilyAllocated<ExtraData> extra; + QQuickItem *background; QString placeholder; Qt::FocusReason focusReason; |