summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Rettberg2021-10-21 10:32:10 +0200
committerSimon Rettberg2021-10-21 10:32:10 +0200
commitc00edf9e5e082637542f0c79cdbee7a4fe08fbed (patch)
tree17db9090c5b040863def3f575da1d2da6ddbc241 /src
parentAdd icon for QEMU virtualizer (diff)
downloadvmchooser2-c00edf9e5e082637542f0c79cdbee7a4fe08fbed.tar.gz
vmchooser2-c00edf9e5e082637542f0c79cdbee7a4fe08fbed.tar.xz
vmchooser2-c00edf9e5e082637542f0c79cdbee7a4fe08fbed.zip
vsession icon: Match agains OS display name too
Diffstat (limited to 'src')
-rw-r--r--src/vsession.cpp22
-rw-r--r--src/vsession.h4
2 files changed, 18 insertions, 8 deletions
diff --git a/src/vsession.cpp b/src/vsession.cpp
index b61c759..a7d86e0 100644
--- a/src/vsession.cpp
+++ b/src/vsession.cpp
@@ -104,27 +104,33 @@ QIcon VSession::icon() const {
return res_icon;
}
// Everything failed, try to guess the OS
- QString os(this->os().toLower());
- os = os.replace(cleanNameRegex, QString());
- if (!os.isEmpty()) {
+ QString os1(this->os().toLower());
+ QString os2(this->osDisplayName().toLower());
+ os1 = os1.replace(cleanNameRegex, QString());
+ os2 = os2.replace(cleanNameRegex, QString());
+ if (!os1.isEmpty() || !os2.isEmpty()) {
// Now try known good OS names via .startsWith()
for (const QString& str : directOsNames) {
- if (os.startsWith(str))
+ if (os1.startsWith(str) || os2.startsWith(str))
return iconHolder->getIcon(str);
}
// Fuzzy matching via regex
for (const IconMap& map : iconMapping) {
- if (map.expr.match(os).hasMatch())
+ if (map.expr.match(os1).hasMatch() || map.expr.match(os2).hasMatch())
return iconHolder->getIcon(map.icon);
}
// Running out of ideas...
- if (os.startsWith(QStringLiteral("win")))
+ if (os2.startsWith(QStringLiteral("win")))
return iconHolder->getIcon(QStringLiteral("windows"));
- if (os.contains(QStringLiteral("linux")))
+ if (os2.contains(QStringLiteral("linux")))
return iconHolder->getIcon(QStringLiteral("linux"));
}
// Fallback to generic virtualizer icon (if found)
- return iconHolder->getIcon(virtualizer());
+ QIcon ret = iconHolder->getIcon(virtualizer());
+ if (ret.isNull()) {
+ ret = QIcon(QPixmap(64, 64));
+ }
+ return ret;
}
QString VSession::toXml() const {
diff --git a/src/vsession.h b/src/vsession.h
index e571805..af01230 100644
--- a/src/vsession.h
+++ b/src/vsession.h
@@ -47,6 +47,10 @@ class VSession : public Session {
return getAttribute(QStringLiteral("os"));
}
+ QString osDisplayName() const {
+ return getAttribute(QStringLiteral("os_name"));
+ }
+
QString uuid() const {
return getAttribute(QStringLiteral("uuid"));
}