aboutsummaryrefslogtreecommitdiffstats
path: root/src/controls
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2015-05-23 11:04:06 +0200
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2015-05-23 09:20:07 +0000
commit7662b27929fa76eae8bea9d975c7956b229c7a8b (patch)
tree5d714b72db8a122f4eb572e4ffd87263abe956c1 /src/controls
parentab71cd2439dba00c751becd91dcf111b8ec38ba9 (diff)
QQuickControlPrivate::resizeBackground()
Change-Id: Id686a132fc9e7933c86e5314056f28fc50f6c61f Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'src/controls')
-rw-r--r--src/controls/qquickcontrol.cpp30
-rw-r--r--src/controls/qquickcontrol_p_p.h2
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;