summaryrefslogtreecommitdiffstats
path: root/src/sessionsiconholder.cpp
diff options
context:
space:
mode:
authorJonathan Bauer2016-02-18 16:05:59 +0100
committerJonathan Bauer2016-02-18 16:05:59 +0100
commit25960be7c786690c14586f3e873012d45935080f (patch)
treebf3ac5b726c26104f7e096126a982399111622ae /src/sessionsiconholder.cpp
parentfix formating (diff)
downloadvmchooser2-25960be7c786690c14586f3e873012d45935080f.tar.gz
vmchooser2-25960be7c786690c14586f3e873012d45935080f.tar.xz
vmchooser2-25960be7c786690c14586f3e873012d45935080f.zip
load icon from the filesystem (if path is set in the xsession file)
if no icon is found as a resource or from the filesystem always load the default linux icon as fallback
Diffstat (limited to 'src/sessionsiconholder.cpp')
-rw-r--r--src/sessionsiconholder.cpp30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/sessionsiconholder.cpp b/src/sessionsiconholder.cpp
index 7cce455..076abe8 100644
--- a/src/sessionsiconholder.cpp
+++ b/src/sessionsiconholder.cpp
@@ -62,16 +62,17 @@ QIcon SessionsIconHolder::getIcon(const QString& name) {
if (icons.contains(name)) {
return icons[name];
}
-
// else load icon from resource
QIcon icon;
- QString resName(":" + name.toLower());
- if (QResource(resName + ".svg").isValid()) {
- icon = QIcon(resName + ".svg");
- } else if (QResource(resName).isValid()) {
- icon = QIcon(resName);
- } else {
- icon = QIcon();
+ icon = getIconFromResource(name);
+ // if we didn't find any, check filesystem
+ if (icon.isNull() && QFile::exists(name)) {
+ icon = QIcon(name);
+ }
+ if (icon.isNull()) {
+ // no cached icon, no icon in ressource, no icon in filesystem
+ // fallback to linux icon if that works ;-)
+ icon = getIconFromResource("linux");
}
// insert icon to hash table
@@ -106,3 +107,16 @@ QIcon SessionsIconHolder::getIcon(const QUrl& url) {
return QIcon();
}
+
+QIcon SessionsIconHolder::getIconFromResource(const QString& name) {
+ QIcon icon;
+ QString resName(":" + name.toLower());
+ if (QResource(resName + ".svg").isValid()) {
+ icon = QIcon(resName + ".svg");
+ } else if (QResource(resName).isValid()) {
+ icon = QIcon(resName);
+ } else {
+ icon = QIcon();
+ }
+ return icon;
+}