aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktextedit.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2015-06-18 23:21:22 +0200
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2015-09-06 00:09:38 +0000
commit42f58e557034bb95005db465f078212cfc1b693a (patch)
tree75efc8ca2c9058b3c1bfe149e17d7c77fd3789ac /src/quick/items/qquicktextedit.cpp
parent7ee93972d0f907725ad47f9a08b65a14ca48e9c0 (diff)
TextInput & TextEdit: allow controls to override the implicit size
Change-Id: I4b5eae46a9fef574249eee9061858bdf874c54be Reviewed-by: Liang Qi <liang.qi@theqtcompany.com> Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>
Diffstat (limited to 'src/quick/items/qquicktextedit.cpp')
-rw-r--r--src/quick/items/qquicktextedit.cpp16
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);