From 98ad498a46471d43a745cc61fd53e08e8a6b56dc Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 30 Mar 2018 11:39:18 +0200 Subject: [PATCH] QSplashScreen: honor alignment when message contains html When the message contained html, the alignment was not honored and the text was drawn topLeft instead. Use a similar algorithm like it is done in qt_format_text to move the text to the correct aligned position. Task-number: QTBUG-43081 Change-Id: I570efd0f3f339b26b102ac52983887197d7d63e2 Reviewed-by: Richard Moe Gustavsen --- src/widgets/widgets/qsplashscreen.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/widgets/widgets/qsplashscreen.cpp b/src/widgets/widgets/qsplashscreen.cpp index 468fc272b5..3dc396395f 100644 --- a/src/widgets/widgets/qsplashscreen.cpp +++ b/src/widgets/widgets/qsplashscreen.cpp @@ -327,7 +327,13 @@ void QSplashScreen::drawContents(QPainter *painter) cursor.select(QTextCursor::Document); QTextBlockFormat fmt; fmt.setAlignment(Qt::Alignment(d->currAlign)); + fmt.setLayoutDirection(layoutDirection()); cursor.mergeBlockFormat(fmt); + const QSizeF txtSize = doc.size(); + if (d->currAlign & Qt::AlignBottom) + r.setTop(r.height() - txtSize.height()); + else if (d->currAlign & Qt::AlignVCenter) + r.setTop(r.height() / 2 - txtSize.height() / 2); painter->save(); painter->translate(r.topLeft()); doc.drawContents(painter);