]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fix rating pixmap alignment on high-dpi screens
authorKai Uwe Broulik <kde@privat.broulik.de>
Wed, 23 Feb 2022 19:44:22 +0000 (20:44 +0100)
committerKai Uwe Broulik <kde@privat.broulik.de>
Wed, 23 Feb 2022 19:44:22 +0000 (20:44 +0100)
When calculating layout geometry based on the pixmap size,
one needs to divide by `devicePixelRatio`

src/kitemviews/kstandarditemlistwidget.cpp

index 9c527fa171deb2e4b74672b9cf6ca40c8e642e67..62beb6e5358eea5cc4b20251235ff6556b95b7e8 100644 (file)
@@ -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();