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>bb10
parent
408656c6f9
commit
a7894855f2
|
|
@ -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)) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue