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.
Origin: upstream, https://code.qt.io/cgit/qt/qtbase.git/commit/?id=a7894855f2f59028
Last-Update: 2021-08-15

Gbp-Pq: Name full_width_selection_rtl.diff
This commit is contained in:
Debian Qt/KDE Maintainers 2022-05-14 17:41:00 +08:00 committed by openKylinBot
parent 11abf4e0d0
commit 96f1345c14
1 changed files with 11 additions and 4 deletions

View File

@ -1173,10 +1173,17 @@ void QTextLayout::draw(QPainter *p, const QPointF &pos, const QVector<FormatRang
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)) {