Blame SOURCES/return-application-icons-properly.patch

92cace
From 613c951a1157df0d8a907a155a5eaa706816d5f9 Mon Sep 17 00:00:00 2001
92cace
From: Aaron Seigo <aseigo@kde.org>
92cace
Date: Thu, 21 Feb 2013 17:58:11 +0100
92cace
Subject: return application icons properly
92cace
92cace
BUG:315578
92cace
---
92cace
 kdeui/icons/kiconloader.cpp | 31 ++++++++++++++++++++++++++++++-
92cace
 1 file changed, 30 insertions(+), 1 deletion(-)
92cace
92cace
diff --git a/kdeui/icons/kiconloader.cpp b/kdeui/icons/kiconloader.cpp
92cace
index f65e941..6fed667 100644
92cace
--- a/kdeui/icons/kiconloader.cpp
92cace
+++ b/kdeui/icons/kiconloader.cpp
92cace
@@ -909,7 +909,36 @@ K3Icon KIconLoaderPrivate::findMatchingIcon(const QString& name, int size) const
92cace
     const char * const ext[4] = { ".png", ".svgz", ".svg", ".xpm" };
92cace
     bool genericFallback = name.endsWith(QLatin1String("-x-generic"));
92cace
 
92cace
-    foreach(KIconThemeNode *themeNode, links)
92cace
+    // Do two passes through themeNodes.
92cace
+    //
92cace
+    // The first pass looks for an exact match in each themeNode one after the other.
92cace
+    // If one is found and it is an app icon then return that icon.
92cace
+    //
92cace
+    // In the next pass (assuming the first pass failed), it looks for exact matches
92cace
+    // and then generic fallbacks in each themeNode one after the other
92cace
+    //
92cace
+    // The reasoning is that application icons should always match exactly, all other
92cace
+    // icons may fallback. Since we do not know what the context is here when we start
92cace
+    // looking for it, we can only go by the path found.
92cace
+    foreach (KIconThemeNode *themeNode, links) {
92cace
+        for (int i = 0 ; i < 4 ; i++) {
92cace
+            icon = themeNode->theme->iconPath(name + ext[i], size, KIconLoader::MatchExact);
92cace
+            if (icon.isValid()) {
92cace
+                break;
92cace
+            }
92cace
+
92cace
+            icon = themeNode->theme->iconPath(name + ext[i], size, KIconLoader::MatchBest);
92cace
+            if (icon.isValid()) {
92cace
+                break;
92cace
+            }
92cace
+        }
92cace
+
92cace
+        if (icon.isValid() && icon.path.contains("/apps/")) {
92cace
+            return icon;
92cace
+        }
92cace
+    }
92cace
+
92cace
+    foreach (KIconThemeNode *themeNode, links)
92cace
     {
92cace
         QString currentName = name;
92cace
 
92cace
-- 
92cace
1.8.1.4
92cace