diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-02-20 01:01:00 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2019-02-20 09:51:12 +0100 |
commit | 035f934d7a798e97bf0213a5d42a3d511132f03d (patch) | |
tree | 89aa6efdc86864ce479cddca6b9c4ba523c2754a /src/widgets/widgets/qfontcombobox.cpp | |
parent | f4cc23cffbe3005f0a522cac938695e87ecd6407 (diff) | |
parent | da4ab444ffac37514435364d4d3f0ad59d4f9bc3 (diff) |
Merge remote-tracking branch 'origin/5.13' into dev
Conflicts:
tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
Added tests/auto/testlib/selftests/expected_crashes_5.txt to work
round the output of the crashes test (which exercises UB, see
QTBUG-73903) being truncated on one test platform.
Change-Id: I9cd3f2639b4e50c3c4513e14629a40bdca8f8273
Diffstat (limited to 'src/widgets/widgets/qfontcombobox.cpp')
-rw-r--r-- | src/widgets/widgets/qfontcombobox.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/widgets/widgets/qfontcombobox.cpp b/src/widgets/widgets/qfontcombobox.cpp index 957a464b71..4a99b0f962 100644 --- a/src/widgets/widgets/qfontcombobox.cpp +++ b/src/widgets/widgets/qfontcombobox.cpp @@ -236,9 +236,10 @@ void QFontFamilyDelegate::paint(QPainter *painter, if (QFontDatabase().isSmoothlyScalable(text)) { icon = &truetype; } - QSize actualSize = icon->actualSize(r.size()); - - icon->paint(painter, r, Qt::AlignLeft|Qt::AlignVCenter); + const QSize actualSize = icon->actualSize(r.size()); + const QRect iconRect = QStyle::alignedRect(option.direction, option.displayAlignment, + actualSize, r); + icon->paint(painter, iconRect, Qt::AlignLeft|Qt::AlignVCenter); if (option.direction == Qt::RightToLeft) r.setRight(r.right() - actualSize.width() - 4); else @@ -247,6 +248,7 @@ void QFontFamilyDelegate::paint(QPainter *painter, QFont old = painter->font(); painter->setFont(font); + const Qt::Alignment textAlign = QStyle::visualAlignment(option.direction, option.displayAlignment); // If the ascent of the font is larger than the height of the rect, // we will clip the text, so it's better to align the tight bounding rect in this case // This is specifically for fonts where the ascent is very large compared to @@ -254,9 +256,11 @@ void QFontFamilyDelegate::paint(QPainter *painter, QFontMetricsF fontMetrics(font); if (fontMetrics.ascent() > r.height()) { QRectF tbr = fontMetrics.tightBoundingRect(text); - painter->drawText(r.x(), r.y() + (r.height() + tbr.height()) / 2.0, text); + QRect textRect(r); + textRect.setHeight(textRect.height() + (r.height() - tbr.height())); + painter->drawText(textRect, Qt::AlignBottom|Qt::TextSingleLine|textAlign, text); } else { - painter->drawText(r, Qt::AlignVCenter|Qt::AlignLeading|Qt::TextSingleLine, text); + painter->drawText(r, Qt::AlignVCenter|Qt::TextSingleLine|textAlign, text); } if (writingSystem != QFontDatabase::Any) @@ -270,7 +274,7 @@ void QFontFamilyDelegate::paint(QPainter *painter, r.setRight(r.right() - w); else r.setLeft(r.left() + w); - painter->drawText(r, Qt::AlignVCenter|Qt::AlignLeading|Qt::TextSingleLine, sample); + painter->drawText(r, Qt::AlignVCenter|Qt::TextSingleLine|textAlign, sample); } painter->setFont(old); |