summaryrefslogtreecommitdiffstats
path: root/patches/source/kdelibs/patch/kdelibs/return-application-icons-properly.patch
blob: 2bdb53adf16972ddd73e26c8e9e884aa2fb429e3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
From 613c951a1157df0d8a907a155a5eaa706816d5f9 Mon Sep 17 00:00:00 2001
From: Aaron Seigo <aseigo@kde.org>
Date: Thu, 21 Feb 2013 17:58:11 +0100
Subject: return application icons properly

BUG:315578
---
 kdeui/icons/kiconloader.cpp | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/kdeui/icons/kiconloader.cpp b/kdeui/icons/kiconloader.cpp
index f65e941..6fed667 100644
--- a/kdeui/icons/kiconloader.cpp
+++ b/kdeui/icons/kiconloader.cpp
@@ -909,7 +909,36 @@ K3Icon KIconLoaderPrivate::findMatchingIcon(const QString& name, int size) const
     const char * const ext[4] = { ".png", ".svgz", ".svg", ".xpm" };
     bool genericFallback = name.endsWith(QLatin1String("-x-generic"));
 
-    foreach(KIconThemeNode *themeNode, links)
+    // Do two passes through themeNodes.
+    //
+    // The first pass looks for an exact match in each themeNode one after the other.
+    // If one is found and it is an app icon then return that icon.
+    //
+    // In the next pass (assuming the first pass failed), it looks for exact matches
+    // and then generic fallbacks in each themeNode one after the other
+    //
+    // The reasoning is that application icons should always match exactly, all other
+    // icons may fallback. Since we do not know what the context is here when we start
+    // looking for it, we can only go by the path found.
+    foreach (KIconThemeNode *themeNode, links) {
+        for (int i = 0 ; i < 4 ; i++) {
+            icon = themeNode->theme->iconPath(name + ext[i], size, KIconLoader::MatchExact);
+            if (icon.isValid()) {
+                break;
+            }
+
+            icon = themeNode->theme->iconPath(name + ext[i], size, KIconLoader::MatchBest);
+            if (icon.isValid()) {
+                break;
+            }
+        }
+
+        if (icon.isValid() && icon.path.contains("/apps/")) {
+            return icon;
+        }
+    }
+
+    foreach (KIconThemeNode *themeNode, links)
     {
         QString currentName = name;
 
-- 
1.8.1.4