diff options
author | Oliver Eftevaag <oliver.eftevaag@qt.io> | 2021-07-09 13:26:31 +0200 |
---|---|---|
committer | Oliver Eftevaag <oliver.eftevaag@qt.io> | 2021-07-10 13:27:46 +0200 |
commit | a7894855f2f59028bea9cd1aef07ec1e2c713c90 (patch) | |
tree | 26b1608db354db989a90dd41063afb4952d3bfe4 /src/gui | |
parent | 408656c6f9de326cf91376443597a2f791eb0f8d (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.
Pick-to: 6.2 6.1 5.15
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>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/text/qtextlayout.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 1ce35c2ff2..70e6043231 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1129,10 +1129,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)) { |