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

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