diff options
author | Simon Rettberg | 2019-07-09 11:33:27 +0200 |
---|---|---|
committer | Simon Rettberg | 2019-07-09 11:33:27 +0200 |
commit | 947133905679e19196663bd9923fd063ae4d5b85 (patch) | |
tree | 4edc66c64853ce58fbab49e85c547e4e0dea5070 /src/session.h | |
parent | vsession.*: Use QStringLiteral for most C-Strings (diff) | |
download | vmchooser2-947133905679e19196663bd9923fd063ae4d5b85.tar.gz vmchooser2-947133905679e19196663bd9923fd063ae4d5b85.tar.xz vmchooser2-947133905679e19196663bd9923fd063ae4d5b85.zip |
Gray out and warn about VMs with missing hypervisor
Diffstat (limited to 'src/session.h')
-rw-r--r-- | src/session.h | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/session.h b/src/session.h index 70bee42..01f8ad5 100644 --- a/src/session.h +++ b/src/session.h @@ -2,6 +2,7 @@ #define VMCHOOSER_SESSION_H_ #include <QVariant> +#include <QMessageBox> class QString; class QIcon; @@ -20,7 +21,20 @@ class Session { virtual bool isActive() const = 0; virtual bool isLocked() const = 0; - virtual bool isValid() const = 0; + virtual void checkCanRun() final { + error = checkCanRunInternal(); + } + virtual bool canRun(bool showError = false) const final { + if (!error.isEmpty()) { + if (showError) { + QMessageBox::critical( + nullptr, QObject::trUtf8("vmchooser"), + QObject::trUtf8("Cannot start selected session:") + QStringLiteral("\n") + error); + } + return false; + } + return true; + } virtual int priority() const = 0; virtual QString shortDescription() const = 0; virtual QString description() const = 0; @@ -40,5 +54,11 @@ class Session { virtual bool containsKeywords(const QList<QString>& keywords) const = 0; +protected: + virtual QString checkCanRunInternal() const = 0; + +private: + QString error; + }; #endif /*VMCHOOSER_SESSION_H_*/ |