From: Debian Qt/KDE Maintainers Date: Sun, 7 Aug 2022 13:56:40 +0000 (+0100) Subject: fix QTextFormat::FullWidthSelection for right-to-left text layouts X-Git-Tag: archive/raspbian/5.15.4+dfsg-5+rpi1^2~22 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=149d5a93db62be83b3a9bc6dc2cc14ba12e3ef2b;p=qtbase-opensource-src.git fix QTextFormat::FullWidthSelection for right-to-left text layouts Origin: upstream, https://code.qt.io/cgit/qt/qtbase.git/commit/?id=a7894855f2f59028 Last-Update: 2021-08-15 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. Gbp-Pq: Name full_width_selection_rtl.diff --- diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 5ae41d945..a82d06152 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1173,10 +1173,17 @@ void QTextLayout::draw(QPainter *p, const QPointF &pos, const QVectorisRightToLeft(); + + 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)) {