diff options
| author | Kai Uwe Broulik <[email protected]> | 2022-02-23 20:44:22 +0100 |
|---|---|---|
| committer | Kai Uwe Broulik <[email protected]> | 2022-02-23 20:44:22 +0100 |
| commit | d031696a922e03cb43adf013b8d9b1b052ddf735 (patch) | |
| tree | 3590426f876713937ad79d0a3ce26a9517a3b61e /src | |
| parent | c0f86d3a58123218d334defcd046b9ff381c8310 (diff) | |
Fix rating pixmap alignment on high-dpi screens
When calculating layout geometry based on the pixmap size,
one needs to divide by `devicePixelRatio`
Diffstat (limited to 'src')
| -rw-r--r-- | src/kitemviews/kstandarditemlistwidget.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/kitemviews/kstandarditemlistwidget.cpp b/src/kitemviews/kstandarditemlistwidget.cpp index 9c527fa17..62beb6e53 100644 --- a/src/kitemviews/kstandarditemlistwidget.cpp +++ b/src/kitemviews/kstandarditemlistwidget.cpp @@ -403,7 +403,7 @@ void KStandardItemListWidget::paint(QPainter* painter, const QStyleOptionGraphic QPointF pos = ratingTextInfo->pos; const Qt::Alignment align = ratingTextInfo->staticText.textOption().alignment(); if (align & Qt::AlignHCenter) { - pos.rx() += (size().width() - m_rating.width()) / 2 - 2; + pos.rx() += (size().width() - m_rating.width() / m_rating.devicePixelRatioF()) / 2 - 2; } painter->drawPixmap(pos, m_rating); } @@ -1277,7 +1277,7 @@ void KStandardItemListWidget::updateIconsLayoutTextCache() requiredWidth = m_customizedFontMetrics.horizontalAdvance(elidedText); } else if (role == "rating") { // Use the width of the rating pixmap, because the rating text is empty. - requiredWidth = m_rating.width(); + requiredWidth = m_rating.width() / m_rating.devicePixelRatioF(); } } layout.endLayout(); |
