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>
This commit is contained in:
parent
c90d5e7420
commit
952635dabe
@ -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)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user