Fix rating pixmap alignment on high-dpi screens

When calculating layout geometry based on the pixmap size,
one needs to divide by `devicePixelRatio`
This commit is contained in:
Kai Uwe Broulik 2022-02-23 20:44:22 +01:00
parent c0f86d3a58
commit d031696a92

View 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();