summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOliver Eftevaag <oliver.eftevaag@qt.io>2021-07-09 13:26:31 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-07-10 13:52:01 +0000
commit952635dabe24acf3d222acad3f959c9d33b760aa (patch)
tree261b6f6d9cdd4e2c87f521a3c9bac68668c56159 /src
parentc90d5e7420e02c6e9e4df6fb5c57f877efb73b61 (diff)
Fix QTextFormat::FullWidthSelection for right-to-left text layouts
Using the QTextFormat::FullWidthSelection property to select a line would previously not take into account right-to-left text layouts. With this patch, the whole line should now be drawn correctly for both left-to-right, and right-to-left layouts. Fixes: QTBUG-91125 Change-Id: Ide7b340cd7b4060e7c00e55e0011a86ffdfb5eb4 Done-with: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Dmitry Shachnev <mitya57@gmail.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit a7894855f2f59028bea9cd1aef07ec1e2c713c90) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/gui/text/qtextlayout.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index b633851626..35513741b9 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -1143,10 +1143,17 @@ void QTextLayout::draw(QPainter *p, const QPointF &pos, const QList<FormatRange>
QRectF fullLineRect(tl.rect());
fullLineRect.translate(position);
fullLineRect.setRight(QFIXED_MAX);
- if (!selectionEndInLine)
- region.addRect(clipIfValid(QRectF(lineRect.topRight(), fullLineRect.bottomRight()), clip));
- if (!selectionStartInLine)
- region.addRect(clipIfValid(QRectF(fullLineRect.topLeft(), lineRect.bottomLeft()), clip));
+
+ const bool rightToLeft = d->isRightToLeft();
+
+ if (!selectionEndInLine) {
+ region.addRect(clipIfValid(rightToLeft ? QRectF(fullLineRect.topLeft(), lineRect.bottomLeft())
+ : QRectF(lineRect.topRight(), fullLineRect.bottomRight()), clip));
+ }
+ if (!selectionStartInLine) {
+ region.addRect(clipIfValid(rightToLeft ? QRectF(lineRect.topRight(), fullLineRect.bottomRight())
+ : QRectF(fullLineRect.topLeft(), lineRect.bottomLeft()), clip));
+ }
} else if (!selectionEndInLine
&& isLastLineInBlock
&&!(d->option.flags() & QTextOption::ShowLineAndParagraphSeparators)) {