From 224226727f07e8940e0d3131fe7587b11cc4a6ca Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Tue, 19 Apr 2011 14:40:19 +0200 Subject: Take leading space width into account for painting and selection When painting horizontally centered RTL text and selection with trailing spaces, we need to take that space width into account because line.textAdvance doesn't include it. Task-number: QTBUG-18612 Reviewed-by: Eskil --- src/gui/text/qtextengine.cpp | 4 +++- src/gui/text/qtextlayout.cpp | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index dab4bb7..ce012a8 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -2777,12 +2777,14 @@ QFixed QTextEngine::alignLine(const QScriptLine &line) // if width is QFIXED_MAX that means we used setNumColumns() and that implicitly makes this line left aligned. if (!line.justified && line.width != QFIXED_MAX) { int align = option.alignment(); + if (align & Qt::AlignLeft) + x -= leadingSpaceWidth(line); if (align & Qt::AlignJustify && isRightToLeft()) align = Qt::AlignRight; if (align & Qt::AlignRight) x = line.width - (line.textAdvance + leadingSpaceWidth(line)); else if (align & Qt::AlignHCenter) - x = (line.width - line.textAdvance)/2; + x = (line.width - (line.textAdvance + leadingSpaceWidth(line)))/2; } return x; } diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index bd224c6..122382f 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1060,6 +1060,7 @@ void QTextLayout::draw(QPainter *p, const QPointF &pos, const QVectorleadingSpaceWidth(sl).toReal(), 0); bool isLastLineInBlock = (line == d->lines.size()-1); int sl_length = sl.length + (isLastLineInBlock? 1 : 0); // the infamous newline -- cgit v0.12 From 1124f41253edd0e03704db72b0e1b6b4b518bd0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 26 Apr 2011 17:20:11 +0200 Subject: Removed warning from QPixmap::handle(). With the new fromX11Pixmap function there are valid use-cases where checking the handle() is useful also with the raster graphicssystem. Reviewed-by: Thiago Macieira --- src/gui/image/qpixmap.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 34804e5..c34f6ac 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -1224,12 +1224,8 @@ Qt::HANDLE QPixmap::handle() const { #if defined(Q_WS_X11) const QPixmapData *pd = pixmapData(); - if (pd) { - if (pd->classId() == QPixmapData::X11Class) - return static_cast(pd)->handle(); - else - qWarning("QPixmap::handle(): Pixmap is not an X11 class pixmap"); - } + if (pd && pd->classId() == QPixmapData::X11Class) + return static_cast(pd)->handle(); #endif return 0; } -- cgit v0.12 From dcdb62c3d1a76d951c4b65bc1b1bd930e2ad14ec Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Wed, 27 Apr 2011 08:47:46 +0200 Subject: Make sure layoutData exist before checking for string direction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise accessing that through QTextEngine::alignLine may cause crash. Reviewed-by: Samuel Rødal --- src/gui/text/qtextengine.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index ce012a8..cc150c5 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1598,6 +1598,8 @@ bool QTextEngine::isRightToLeft() const default: break; } + if (!layoutData) + itemize(); // this places the cursor in the right position depending on the keyboard layout if (layoutData->string.isEmpty()) return QApplication::keyboardInputDirection() == Qt::RightToLeft; -- cgit v0.12