aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquicktextfield_p_p.h
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2018-05-02 14:04:53 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2018-05-02 13:43:20 +0000
commit6858d4e9873644c255b19d251e5522c7cf4b7160 (patch)
tree93d5c83e841f084aea0a67ddfab6897d4e9052ec /src/quicktemplates2/qquicktextfield_p_p.h
parent89495f409fcb04f5eeb1c1e06096fcb54065c969 (diff)
TextField: add support for background insets
Same as 5adce042 for QQuickControl. [ChangeLog][Controls][TextField] Added topInset, bottomInset, leftInset, and rightInset properties to control the geometry of the background similarly to how paddings control the geometry of the contentItem. Change-Id: Ic1e4c15fd4b06a58f229b5156668c9a986f7bc3f 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.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquicktextfield_p_p.h b/src/quicktemplates2/qquicktextfield_p_p.h
index c9ccc943..f4a8983d 100644
--- a/src/quicktemplates2/qquicktextfield_p_p.h
+++ b/src/quicktemplates2/qquicktextfield_p_p.h
@@ -76,6 +76,17 @@ public:
static QQuickTextFieldPrivate *get(QQuickTextField *item) {
return static_cast<QQuickTextFieldPrivate *>(QObjectPrivate::get(item)); }
+ inline QMarginsF getInset() const { return QMarginsF(getLeftInset(), getTopInset(), getRightInset(), getBottomInset()); }
+ inline qreal getTopInset() const { return extra.isAllocated() ? extra->topInset : 0; }
+ inline qreal getLeftInset() const { return extra.isAllocated() ? extra->leftInset : 0; }
+ inline qreal getRightInset() const { return extra.isAllocated() ? extra->rightInset : 0; }
+ inline qreal getBottomInset() const { return extra.isAllocated() ? extra->bottomInset : 0; }
+
+ void setTopInset(qreal value, bool reset = false);
+ void setLeftInset(qreal value, bool reset = false);
+ void setRightInset(qreal value, bool reset = false);
+ void setBottomInset(qreal value, bool reset = false);
+
void resizeBackground();
void resolveFont();
@@ -117,6 +128,7 @@ public:
void cancelBackground();
void executeBackground(bool complete = false);
+ void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) override;
void itemImplicitWidthChanged(QQuickItem *item) override;
void itemImplicitHeightChanged(QQuickItem *item) override;
void itemDestroyed(QQuickItem *item) override;
@@ -127,11 +139,22 @@ public:
#endif
struct ExtraData {
+ bool hasTopInset = false;
+ bool hasLeftInset = false;
+ bool hasRightInset = false;
+ bool hasBottomInset = false;
+ bool hasBackgroundWidth = false;
+ bool hasBackgroundHeight = false;
+ qreal topInset = 0;
+ qreal leftInset = 0;
+ qreal rightInset = 0;
+ qreal bottomInset = 0;
QFont requestedFont;
QPalette requestedPalette;
};
QLazilyAllocated<ExtraData> extra;
+ bool resizingBackground = false;
QPalette resolvedPalette;
QQuickDeferredPointer<QQuickItem> background;
QString placeholder;