diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-06-16 14:35:20 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-06-16 12:36:11 +0000 |
commit | 52423683d2549d7615e3ffa5a7bf8872e69b826b (patch) | |
tree | 57f5fa246a27ce975c79c8a73ee2defe7f3d04c0 /src/controls | |
parent | cdec6d9db487399d960e8f0ae0b8b64bc70ae477 (diff) |
TextArea: sync background resizing with Control
Change-Id: Iedb86604b9dc545a09f22c713f70970cc11ca6f9
Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'src/controls')
-rw-r--r-- | src/controls/qquicktextarea.cpp | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/src/controls/qquicktextarea.cpp b/src/controls/qquicktextarea.cpp index 92c2d268..f5fba1d2 100644 --- a/src/controls/qquicktextarea.cpp +++ b/src/controls/qquicktextarea.cpp @@ -49,11 +49,29 @@ class QQuickTextAreaPrivate public: QQuickTextAreaPrivate() : background(Q_NULLPTR), placeholder(Q_NULLPTR) { } + void resizeBackground(); + QQuickItem *background; QQuickText *placeholder; QQuickTextArea *q_ptr; }; +void QQuickTextAreaPrivate::resizeBackground() +{ + Q_Q(QQuickTextArea); + if (background) { + QQuickItemPrivate *p = QQuickItemPrivate::get(background); + if (!p->widthValid && qFuzzyIsNull(background->x())) { + background->setWidth(q->width()); + p->widthValid = false; + } + if (!p->heightValid && qFuzzyIsNull(background->y())) { + background->setHeight(q->height()); + p->heightValid = false; + } + } +} + QQuickTextArea::QQuickTextArea(QQuickItem *parent) : QQuickTextEdit(parent), d_ptr(new QQuickTextAreaPrivate) { @@ -81,6 +99,8 @@ void QQuickTextArea::setBackground(QQuickItem *background) background->setParentItem(this); if (qFuzzyIsNull(background->z())) background->setZ(-1); + if (isComponentComplete()) + d->resizeBackground(); } emit backgroundChanged(); } @@ -108,17 +128,7 @@ void QQuickTextArea::geometryChanged(const QRectF &newGeometry, const QRectF &ol { Q_D(QQuickTextArea); QQuickTextEdit::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(); } QSGNode *QQuickTextArea::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) |