]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Icons: when adding overlays pass in the output size
authorMéven Car <meven@kde.org>
Fri, 10 Jan 2025 09:05:32 +0000 (10:05 +0100)
committerMéven Car <meven@kde.org>
Sat, 11 Jan 2025 12:19:57 +0000 (13:19 +0100)
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

src/kitemviews/kfileitemmodelrolesupdater.cpp
src/panels/information/informationpanelcontent.cpp

index f5fae6f34fc1cc03bdae31af4eb194faff79f8f0..6bb566cc4d740dba2d8ce16bd8ce73aa3a2c2f10 100644 (file)
@@ -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);
index 428a46a5f1b4d14b3d06bab459a8dd60add76955..78900ab8acb8ed5b811133e57938ce073a6d6826 100644 (file)
@@ -362,9 +362,8 @@ void InformationPanelContent::showPreview(const KFileItem &item, const QPixmap &
 {
     m_outdatedPreviewTimer->stop();
 
-    const QSize logicalSize = pixmap.size() / pixmap.devicePixelRatioF();
-    QPixmap p = KIconUtils::addOverlays(pixmap, item.overlays()).pixmap(logicalSize, pixmap.devicePixelRatioF());
-    p.setDevicePixelRatio(pixmap.devicePixelRatioF());
+    QPixmap p = KIconUtils::addOverlays(pixmap, item.overlays()).pixmap(m_preview->size(), devicePixelRatioF());
+    p.setDevicePixelRatio(devicePixelRatioF());
 
     if (m_isVideo) {
         // adds a play arrow overlay