mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-17 15:31:20 +00:00
[KStandardItemListWidget] Round to icon size before applying scaling
Otherwise for 22px icons on high dpi we will request either the wrong icons or scale them needlessly. Dolphin requests a pixmap of 22px, this is then multiplied by dpr resulting in 44 which isn't a valid icon size (only 32 or 48 are). Moreover, we will also hit the path where it will scale the pixmap to a proper icon size resulting in blurry icons (and a performance penalty). Differential Revision: https://phabricator.kde.org/D15260
This commit is contained in:
parent
5f252da8b5
commit
1e7e4fad49
|
@ -1462,14 +1462,8 @@ void KStandardItemListWidget::closeRoleEditor()
|
|||
QPixmap KStandardItemListWidget::pixmapForIcon(const QString& name, const QStringList& overlays, int size, QIcon::Mode mode)
|
||||
{
|
||||
static const QIcon fallbackIcon = QIcon::fromTheme(QStringLiteral("unknown"));
|
||||
size *= qApp->devicePixelRatio();
|
||||
const QString key = "KStandardItemListWidget:" % name % ":" % overlays.join(QStringLiteral(":")) % ":" % QString::number(size) % ":" % QString::number(mode);
|
||||
QPixmap pixmap;
|
||||
|
||||
if (!QPixmapCache::find(key, pixmap)) {
|
||||
const QIcon icon = QIcon::fromTheme(name, fallbackIcon);
|
||||
|
||||
int requestedSize;
|
||||
int requestedSize = size;
|
||||
if (size <= KIconLoader::SizeSmall) {
|
||||
requestedSize = KIconLoader::SizeSmall;
|
||||
} else if (size <= KIconLoader::SizeSmallMedium) {
|
||||
|
@ -1484,9 +1478,15 @@ QPixmap KStandardItemListWidget::pixmapForIcon(const QString& name, const QStrin
|
|||
requestedSize = KIconLoader::SizeEnormous;
|
||||
} else if (size <= KIconLoader::SizeEnormous * 2) {
|
||||
requestedSize = KIconLoader::SizeEnormous * 2;
|
||||
} else {
|
||||
requestedSize = size;
|
||||
}
|
||||
size *= qApp->devicePixelRatio();
|
||||
requestedSize *= qApp->devicePixelRatio();
|
||||
|
||||
const QString key = "KStandardItemListWidget:" % name % ":" % overlays.join(QStringLiteral(":")) % ":" % QString::number(size) % ":" % QString::number(mode);
|
||||
QPixmap pixmap;
|
||||
|
||||
if (!QPixmapCache::find(key, pixmap)) {
|
||||
const QIcon icon = QIcon::fromTheme(name, fallbackIcon);
|
||||
|
||||
pixmap = icon.pixmap(requestedSize / qApp->devicePixelRatio(), requestedSize / qApp->devicePixelRatio(), mode);
|
||||
if (requestedSize != size) {
|
||||
|
|
Loading…
Reference in a new issue