From 7662b27929fa76eae8bea9d975c7956b229c7a8b Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Sat, 23 May 2015 11:04:06 +0200 Subject: QQuickControlPrivate::resizeBackground() Change-Id: Id686a132fc9e7933c86e5314056f28fc50f6c61f Reviewed-by: J-P Nurmi --- src/controls/qquickcontrol.cpp | 30 +++++++++++++++++++----------- src/controls/qquickcontrol_p_p.h | 2 ++ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/controls/qquickcontrol.cpp b/src/controls/qquickcontrol.cpp index 166201d6..44da18c6 100644 --- a/src/controls/qquickcontrol.cpp +++ b/src/controls/qquickcontrol.cpp @@ -124,6 +124,22 @@ void QQuickControlPrivate::setBottomPadding(qreal value, bool reset) } } +void QQuickControlPrivate::resizeBackground() +{ + Q_Q(QQuickControl); + if (background) { + QQuickItemPrivate *p = QQuickItemPrivate::get(background); + if (!p->widthValid) { + background->setWidth(q->width()); + p->widthValid = false; + } + if (!p->heightValid) { + background->setHeight(q->height()); + p->heightValid = false; + } + } +} + QQuickControl::QQuickControl(QQuickItem *parent) : QQuickItem(*(new QQuickControlPrivate), parent) { @@ -336,6 +352,8 @@ void QQuickControl::setBackground(QQuickItem *background) background->setParentItem(this); if (qFuzzyIsNull(background->z())) background->setZ(-1); + if (isComponentComplete()) + d->resizeBackground(); } emit backgroundChanged(); } @@ -345,17 +363,7 @@ void QQuickControl::geometryChanged(const QRectF &newGeometry, const QRectF &old { Q_D(QQuickControl); QQuickItem::geometryChanged(newGeometry, oldGeometry); - if (d->background) { - QQuickItemPrivate *p = QQuickItemPrivate::get(d->background); - if (!p->widthValid) { - d->background->setWidth(newGeometry.width()); - p->widthValid = false; - } - if (!p->heightValid) { - d->background->setHeight(newGeometry.height()); - p->heightValid = false; - } - } + d->resizeBackground(); emit contentWidthChanged(); emit contentHeightChanged(); } diff --git a/src/controls/qquickcontrol_p_p.h b/src/controls/qquickcontrol_p_p.h index 353f38f2..3a2154f1 100644 --- a/src/controls/qquickcontrol_p_p.h +++ b/src/controls/qquickcontrol_p_p.h @@ -69,6 +69,8 @@ public: void setRightPadding(qreal value, bool reset = false); void setBottomPadding(qreal value, bool reset = false); + void resizeBackground(); + bool hasTopPadding; bool hasLeftPadding; bool hasRightPadding; -- cgit v1.2.3