diff options
author | J-P Nurmi <[email protected]> | 2015-06-18 23:21:22 +0200 |
---|---|---|
committer | J-P Nurmi <[email protected]> | 2015-09-06 00:09:38 +0000 |
commit | 42f58e557034bb95005db465f078212cfc1b693a (patch) | |
tree | 75efc8ca2c9058b3c1bfe149e17d7c77fd3789ac /src/quick/items/qquicktextedit.cpp | |
parent | 7ee93972d0f907725ad47f9a08b65a14ca48e9c0 (diff) |
TextInput & TextEdit: allow controls to override the implicit size
Change-Id: I4b5eae46a9fef574249eee9061858bdf874c54be
Reviewed-by: Liang Qi <[email protected]>
Reviewed-by: Gabriel de Dietrich <[email protected]>
Diffstat (limited to 'src/quick/items/qquicktextedit.cpp')
-rw-r--r-- | src/quick/items/qquicktextedit.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp index dc4e301a36..0a26f0119f 100644 --- a/src/quick/items/qquicktextedit.cpp +++ b/src/quick/items/qquicktextedit.cpp @@ -2115,6 +2115,7 @@ QQuickTextEditPrivate::ExtraData::ExtraData() , explicitLeftPadding(false) , explicitRightPadding(false) , explicitBottomPadding(false) + , explicitImplicitSize(false) { } @@ -2345,7 +2346,8 @@ void QQuickTextEdit::updateSize() const bool wasInLayout = d->inLayout; d->inLayout = true; - setImplicitWidth(naturalWidth + leftPadding() + rightPadding()); + if (!d->extra.isAllocated() || !d->extra->explicitImplicitSize) + setImplicitWidth(naturalWidth + leftPadding() + rightPadding()); d->inLayout = wasInLayout; if (d->inLayout) // probably the result of a binding loop, but by letting it return; // get this far we'll get a warning to that effect. @@ -2364,11 +2366,13 @@ void QQuickTextEdit::updateSize() QFontMetricsF fm(d->font); qreal newHeight = d->document->isEmpty() ? qCeil(fm.height()) : d->document->size().height(); - // ### Setting the implicitWidth triggers another updateSize(), and unless there are bindings nothing has changed. - if (!widthValid() && !d->requireImplicitWidth) - setImplicitSize(newWidth + leftPadding() + rightPadding(), newHeight + topPadding() + bottomPadding()); - else - setImplicitHeight(newHeight + topPadding() + bottomPadding()); + if (!d->extra.isAllocated() || !d->extra->explicitImplicitSize) { + // ### Setting the implicitWidth triggers another updateSize(), and unless there are bindings nothing has changed. + if (!widthValid() && !d->requireImplicitWidth) + setImplicitSize(newWidth + leftPadding() + rightPadding(), newHeight + topPadding() + bottomPadding()); + else + setImplicitHeight(newHeight + topPadding() + bottomPadding()); + } d->xoff = leftPadding() + qMax(qreal(0), QQuickTextUtil::alignedX(d->document->size().width(), width() - leftPadding() - rightPadding(), effectiveHAlign())); d->yoff = topPadding() + QQuickTextUtil::alignedY(d->document->size().height(), height() - topPadding() - bottomPadding(), d->vAlign); |