kdebase4-workspace/kde-workspace-4.11.22-systemsettings-icons.patch

48 lines
1.9 KiB
Diff

From: David Edmundson <kde@davidedmundson.co.uk>
Date: Wed, 01 Oct 2014 13:23:12 +0000
Subject: Pass icons by data instead of path
X-Git-Tag: v5.1.0
X-Git-Url: http://quickgit.kde.org/?p=systemsettings.git&a=commitdiff&h=b872365e3104aaaaf9d3fdb40820db321cfe58d0
---
Pass icons by data instead of path
This fixes issues if the icon is an SVG
BUG: 337138
(this commit backported to KDE4 by this patch)
---
diff -urN kde-workspace-4.11.22/systemsettings/classic/CategoryList.cpp kde-workspace-4.11.22-patched/systemsettings/classic/CategoryList.cpp
--- kde-workspace-4.11.22/systemsettings/classic/CategoryList.cpp 2015-08-12 17:03:15.000000000 +1000
+++ kde-workspace-4.11.22-patched/systemsettings/classic/CategoryList.cpp 2016-04-26 00:11:03.831685517 +1000
@@ -24,6 +24,8 @@
#include <QFile>
#include <QModelIndex>
#include <QTextStream>
+#include <QIcon>
+#include <QBuffer>
#include <KDebug>
#include <KLocale>
@@ -110,7 +112,19 @@
const QString szName = childItem->name();
const QString szComment = childItem->service()->comment();
content += szLink + szName + "</a></td><td class=\"kc_rightcol\">" + szLink + szComment + "</a>";
- content = content.arg( iconL->iconPath(childItem->service()->icon(), - KIconLoader::SizeSmallMedium ) );
+
+ //passing just the path is insufficient as some icon sets (breeze) only provide SVGs
+ //instead pass data inline
+
+ QIcon icon = QIcon::fromTheme(childItem->service()->icon());
+ QImage image(icon.pixmap(24).toImage()); //icons are hardcoded to size 24 above
+ QByteArray byteArray;
+ QBuffer buffer(&byteArray);
+ image.save(&buffer, "PNG"); // writes the image in PNG format inside the buffer
+ QString iconBase64 = QString::fromLatin1(byteArray.toBase64().data());
+
+ content = content.arg("data:image/png;base64," + iconBase64);
+
d->itemMap.insert( link.url(), childIndex );
content += "</td></tr>\n";
}