summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Rettberg2019-07-08 15:34:43 +0200
committerSimon Rettberg2019-07-08 15:34:43 +0200
commit6d4e332fc6da62cae08de3508ddec18f8830fb25 (patch)
treeb19d230e634c2dc4f986291a15182fd4c212d451 /src
parentChange WM spawning once again to hopefully fix invisible chooser (diff)
downloadvmchooser2-6d4e332fc6da62cae08de3508ddec18f8830fb25.tar.gz
vmchooser2-6d4e332fc6da62cae08de3508ddec18f8830fb25.tar.xz
vmchooser2-6d4e332fc6da62cae08de3508ddec18f8830fb25.zip
Get rid of ImgType, use string directly
The virtualizer ID should (mostly) be treated as an opaque value. The only place it's evaluated is where we determine whether a VM needs VTx or not. In the future this should be handled by meta data queried from run-virt (extend --query)
Diffstat (limited to 'src')
-rw-r--r--src/vsession.cpp30
-rw-r--r--src/vsession.h12
2 files changed, 13 insertions, 29 deletions
diff --git a/src/vsession.cpp b/src/vsession.cpp
index 0476cbb..eae6ee9 100644
--- a/src/vsession.cpp
+++ b/src/vsession.cpp
@@ -22,6 +22,9 @@
static QProcess _process;
+static const QString VMWARE("vmware");
+static const QString VIRTUALBOX("virtualbox");
+
struct IconMap {
QString icon;
QRegularExpression expr;
@@ -119,12 +122,8 @@ QIcon VSession::icon() const {
if (os.contains("linux"))
return iconHolder->getIcon("linux");
}
- // Fallback to generic virtualizer icon
- if (imgtype() == VMWARE)
- return iconHolder->getIcon("vmware");
- if (imgtype() == VBOX)
- return iconHolder->getIcon("virtualbox");
- return QIcon();
+ // Fallback to generic virtualizer icon (if found)
+ return iconHolder->getIcon(virtualizer());
}
QString VSession::toXml() const {
@@ -149,7 +148,6 @@ QString VSession::toXml() const {
QString VSession::getAttribute(const QString &nodeName,
const QString &attribute) const {
- QDomNode n = eintrag_.firstChildElement(nodeName);
return eintrag_.firstChildElement(nodeName).attribute(attribute);
}
@@ -189,18 +187,6 @@ QString VSession::getNodeText(const QString& nodeName) const {
return this->doc_.namedItem(nodeName).toText().data();
}
-ImgType VSession::imgtype() const {
- QString s(getAttribute("virtualmachine"));
-
- if (s.compare("vmware") == 0) {
- return VMWARE;
- } else if (s.compare("virtualbox") == 0 || s.compare("vbox") == 0) {
- return VBOX;
- } else {
- return OTHER;
- }
-}
-
bool VSession::isActive() const {
QString value(getAttribute("active"));
// Is disabled completely
@@ -365,9 +351,9 @@ QList<Session*> VSession::readXmlFile(const QString& filepath) {
}
bool VSession::needsVtx() const {
- ImgType type = imgtype();
- return (type == VMWARE && getAttribute("os").endsWith("-64"))
- || (type == VBOX && getAttribute("os").endsWith("_64")); // Vbox 6.x DOES support 32bit VMs without VT-x, but if
+ QString type = virtualizer();
+ return (type == VMWARE && os().endsWith("-64"))
+ || (type == VIRTUALBOX && os().endsWith("_64")); // Vbox 6.x DOES support 32bit VMs without VT-x, but if
// the config enables any feature that cannot work without VT-x, it will silently enable it and then fail to start (i.e. IOAPIC)
// TODO: qemu-kvm, ...
}
diff --git a/src/vsession.h b/src/vsession.h
index 6c48ce4..ad81833 100644
--- a/src/vsession.h
+++ b/src/vsession.h
@@ -8,17 +8,10 @@
#include "session.h"
#include "globals.h"
-enum ImgType {
- VMWARE,
- VBOX,
- OTHER
-};
-
class VSession : public Session {
public:
bool init(const QDomElement& xml);
- ImgType imgtype() const;
bool isActive() const;
bool isLocked() const;
bool isValid() const;
@@ -37,6 +30,10 @@ class VSession : public Session {
return getAttribute("allow_edit").toInt() != 0;
}
+ QString virtualizer() const {
+ return getAttribute(QLatin1String("virtualmachine"));
+ }
+
QString shortDescription() const {
return getAttribute("short_description");
}
@@ -90,6 +87,7 @@ class VSession : public Session {
static QList<Session*> readXmlFile(const QString& filepath);
private:
+
QList<QString> keywords_;
QDomDocument doc_;
QDomElement eintrag_;