summaryrefslogtreecommitdiffstats
path: root/src/session.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/session.h')
-rw-r--r--src/session.h22
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_*/