┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/kfileitemmodelrolesupdater.cpp
diff options
context:
space:
mode:
authorMéven Car <[email protected]>2025-01-10 10:05:32 +0100
committerMéven Car <[email protected]>2025-01-11 13:19:57 +0100
commitfe56127d9e90c2b364189d38ea43c64ee2019874 (patch)
tree0a979afeb5f148a3e6f852f849ca1ef9b9927fd1 /src/kitemviews/kfileitemmodelrolesupdater.cpp
parent9109b6a25177a61d8b314dac4b6715a1e226804f (diff)
Icons: when adding overlays pass in the output size
Instead of the pixmap size that won't be accurate. It allow KGuiAddons::addOverlays to draw larger images to add overlays. Consequently the emblems are not longer dependant scaled based on the pixmap aspect ratio. BUG: 498211
Diffstat (limited to 'src/kitemviews/kfileitemmodelrolesupdater.cpp')
-rw-r--r--src/kitemviews/kfileitemmodelrolesupdater.cpp15
1 files changed, 3 insertions, 12 deletions
diff --git a/src/kitemviews/kfileitemmodelrolesupdater.cpp b/src/kitemviews/kfileitemmodelrolesupdater.cpp
index f5fae6f34..6bb566cc4 100644
--- a/src/kitemviews/kfileitemmodelrolesupdater.cpp
+++ b/src/kitemviews/kfileitemmodelrolesupdater.cpp
@@ -556,18 +556,9 @@ void KFileItemModelRolesUpdater::slotGotPreview(const KFileItem &item, const QPi
QHash<QByteArray, QVariant> data = rolesData(item, index);
const QStringList overlays = data["iconOverlays"].toStringList();
- // Strangely KFileItem::overlays() returns empty string-values, so
- // we need to check first whether an overlay must be drawn at all.
- if (!scaledPixmap.isNull()) {
- for (const QString &overlay : overlays) {
- if (!overlay.isEmpty()) {
- // There is at least one overlay, draw all overlays above m_pixmap
- // and cancel the check
- const QSize logicalSize = scaledPixmap.size() / scaledPixmap.devicePixelRatioF();
- scaledPixmap = KIconUtils::addOverlays(scaledPixmap, overlays).pixmap(logicalSize, scaledPixmap.devicePixelRatioF());
- break;
- }
- }
+ if (!pixmap.isNull() && !overlays.isEmpty()) {
+ const QSize cacheSize = (m_iconSize.width() > 128) || (m_iconSize.height() > 128) ? QSize(256, 256) : QSize(128, 128);
+ scaledPixmap = KIconUtils::addOverlays(scaledPixmap, overlays).pixmap(cacheSize, m_devicePixelRatio);
}
data.insert("iconPixmap", scaledPixmap);