aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick/items/qquicktext.cpp')
-rw-r--r--src/quick/items/qquicktext.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp
index c1794697a5..456ec25edd 100644
--- a/src/quick/items/qquicktext.cpp
+++ b/src/quick/items/qquicktext.cpp
@@ -749,6 +749,7 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const baseline)
: largeFont;
int scaledFontSize = largeFont;
+ bool widthChanged = false;
widthExceeded = q->width() <= 0 && (singlelineElide || canWrap || horizontalFit);
heightExceeded = q->height() <= 0 && (multilineElide || verticalFit);
@@ -945,6 +946,7 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const baseline)
if ((lineWidth < qMin(oldWidth, naturalWidth) || (widthExceeded && lineWidth > oldWidth))
&& (singlelineElide || multilineElide || canWrap || horizontalFit
|| q->effectiveHAlign() != QQuickText::AlignLeft)) {
+ widthChanged = true;
widthExceeded = false;
heightExceeded = false;
continue;
@@ -966,6 +968,39 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const baseline)
heightExceeded = false;
continue;
}
+ } else if (widthChanged) {
+ widthChanged = false;
+ if (line.isValid()) {
+ for (int lineCount = layout.lineCount(); lineCount < maxLineCount; ++lineCount) {
+ line = layout.createLine();
+ if (!line.isValid())
+ break;
+ setLineGeometry(line, lineWidth, naturalHeight);
+ }
+ }
+ layout.endLayout();
+
+ bool wasInLayout = internalWidthUpdate;
+ internalWidthUpdate = true;
+ q->setImplicitHeight(naturalHeight);
+ internalWidthUpdate = wasInLayout;
+
+ multilineElide = elideMode == QQuickText::ElideRight
+ && q->widthValid()
+ && (q->heightValid() || maximumLineCountValid);
+ verticalFit = fontSizeMode() & QQuickText::VerticalFit
+ && (q->heightValid() || (maximumLineCountValid && canWrap));
+
+ const qreal oldHeight = maxHeight;
+ maxHeight = q->heightValid() ? q->height() : FLT_MAX;
+ // If the height of the item has changed and it's possible the result of eliding,
+ // line count truncation or scaling has changed, do another layout.
+ if ((maxHeight < qMin(oldHeight, naturalHeight) || (heightExceeded && maxHeight > oldHeight))
+ && (multilineElide || (canWrap && maximumLineCountValid))) {
+ widthExceeded = false;
+ heightExceeded = false;
+ continue;
+ }
} else {
layout.endLayout();
}