diff --git a/src/kiconengine.cpp b/src/kiconengine.cpp --- a/src/kiconengine.cpp +++ b/src/kiconengine.cpp @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -94,10 +95,8 @@ return pm; } - const QSize scaledSize = size / scale; - const int kstate = qIconModeToKIconState(mode); - const int iconSize = qMin(scaledSize.width(), scaledSize.height()); + const int iconSize = qMin(size.width(), size.height()); QPixmap pix = mIconLoader.data()->loadScaledIcon(mIconName, KIconLoader::Desktop, scale, iconSize, kstate, mOverlays); if (pix.size() == size) { diff --git a/src/kiconloader.cpp b/src/kiconloader.cpp --- a/src/kiconloader.cpp +++ b/src/kiconloader.cpp @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -954,7 +955,11 @@ } if (size != 0) { - reader.setScaledSize(QSize(size * scale, size * scale)); + if (QCoreApplication::instance()->testAttribute(Qt::AA_UseHighDpiPixmaps)) { + reader.setScaledSize(QSize(size, size)); + } else { + reader.setScaledSize(QSize(size * scale, size * scale)); + } } return reader.read(); diff --git a/src/kicontheme.cpp b/src/kicontheme.cpp --- a/src/kicontheme.cpp +++ b/src/kicontheme.cpp @@ -191,27 +191,28 @@ // - Prefer directories that allow a downscaling even if the difference to // the requested size is bigger than a directory where an upscaling is required. for (KIconThemeDir *dir : dirs) { + const int scaledDirSize = dir->size() * dir->scale(); if (dir->scale() != integerScale) { continue; } if (match == KIconLoader::MatchExact) { - if ((dir->type() == KIconLoader::Fixed) && (dir->size() != size)) { + if ((dir->type() == KIconLoader::Fixed) && (scaledDirSize != size)) { continue; } if ((dir->type() == KIconLoader::Scalable) && - ((size < dir->minSize()) || (size > dir->maxSize()))) { + ((size < dir->minSize() * scale) || (size > dir->maxSize() * scale))) { continue; } if ((dir->type() == KIconLoader::Threshold) && - (abs(dir->size() - size) > dir->threshold())) { + (abs(scaledDirSize - size) > dir->threshold())) { continue; } } else { // dw < 0 means need to scale up to get an icon of the requested size. // Upscaling should only be done if no larger icon is available. if (dir->type() == KIconLoader::Fixed) { - dw = dir->size() - size; + dw = scaledDirSize - size; } else if (dir->type() == KIconLoader::Scalable) { if (size < dir->minSize()) { dw = dir->minSize() - size; @@ -221,10 +222,10 @@ dw = 0; } } else if (dir->type() == KIconLoader::Threshold) { - if (size < dir->size() - dir->threshold()) { - dw = dir->size() - dir->threshold() - size; - } else if (size > dir->size() + dir->threshold()) { - dw = dir->size() + dir->threshold() - size; + if (size < scaledDirSize - dir->threshold()) { + dw = scaledDirSize - dir->threshold() - size; + } else if (size > scaledDirSize + dir->threshold()) { + dw = scaledDirSize + dir->threshold() - size; } else { dw = 0; }