diff options
author | Simon Rettberg | 2016-09-02 17:28:11 +0200 |
---|---|---|
committer | Simon Rettberg | 2016-09-02 17:28:11 +0200 |
commit | d4755df23b1c3a5791da4b176a56bbfdc4203255 (patch) | |
tree | ce190f19fdd79bdc601f2bd66b91887ae32e05e6 /src | |
parent | Don't allow selecting native sessions in exam mode (diff) | |
download | vmchooser2-d4755df23b1c3a5791da4b176a56bbfdc4203255.tar.gz vmchooser2-d4755df23b1c3a5791da4b176a56bbfdc4203255.tar.xz vmchooser2-d4755df23b1c3a5791da4b176a56bbfdc4203255.zip |
Really disable xsession button this time
Diffstat (limited to 'src')
-rw-r--r-- | src/dialog.cpp | 13 | ||||
-rw-r--r-- | src/dialog.h | 3 | ||||
-rw-r--r-- | src/main.cpp | 2 |
3 files changed, 11 insertions, 7 deletions
diff --git a/src/dialog.cpp b/src/dialog.cpp index 9dba767..8766981 100644 --- a/src/dialog.cpp +++ b/src/dialog.cpp @@ -20,7 +20,7 @@ #include "vsession.h" #include "choosersettings.h" -Dialog::Dialog(int defaultTab, bool allowNative, QWidget *parent) +Dialog::Dialog(int defaultTab, bool examMode, QWidget *parent) : QDialog(parent), ui(new Ui::Dialog) { model_[0] = new SessionTreeModel(parent); model_[1] = new SessionTreeModel(parent); @@ -30,6 +30,7 @@ Dialog::Dialog(int defaultTab, bool allowNative, QWidget *parent) qDebug() << "Default tab: " << defaultTab; userInteracted_ = false; genericExpandedOnce_ = false; + examMode_ = examMode; ui->setupUi(this); @@ -64,12 +65,12 @@ Dialog::Dialog(int defaultTab, bool allowNative, QWidget *parent) this, SLOT(treeView_selectionChanged(const QModelIndex&, const QModelIndex&))); */ - if (allowNative) { - this->onTabButtonChanged(TAB_NATIVE); - this->selectPreviousSession(); - } else { + if (examMode_) { ui->tabButtonLocal->setEnabled(false); this->onTabButtonChanged(TAB_ALL_VMS); + } else { + this->onTabButtonChanged(TAB_NATIVE); + this->selectPreviousSession(); } //activeTab_ = 2; //ui->tabButtonAllClasses->setChecked(true); @@ -180,6 +181,8 @@ void Dialog::addItems(const QList<Session*>& entries, int tab) { if (tab < 0 || tab > 2) { return; } + if (examMode_ && tab == TAB_NATIVE) + return; this->model_[tab]->addItems(entries); tabs_[tab]->setEnabled(this->model_[tab]->rowCount() != 0); if (tab == activeTab_) { diff --git a/src/dialog.h b/src/dialog.h index 342a988..ea042cd 100644 --- a/src/dialog.h +++ b/src/dialog.h @@ -30,7 +30,7 @@ class Dialog : public QDialog { static const int TAB_ALL_VMS = 2; static const int TAB_COUNT = 3; public: // Public methods - explicit Dialog(int defaultTab = -1, bool allowNative = true, QWidget *parent = 0); + explicit Dialog(int defaultTab = -1, bool examMode = false, QWidget *parent = 0); ~Dialog(); void addItems(const QList<Session*>&, int tab); void addStatusString(const int status); @@ -56,6 +56,7 @@ class Dialog : public QDialog { int defaultTab_; bool userInteracted_; bool genericExpandedOnce_; + bool examMode_; QString strings_[STR__MAX]; void onTabButtonChanged(int tab); void configClearButton(); diff --git a/src/main.cpp b/src/main.cpp index e451e1a..5e18c8c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -257,7 +257,7 @@ int main(int argc, char *argv[]) { /* read session files */ QList<Session*> xsessions(XSession::readSessions(xSessionPath)); - Dialog w(defaultTab, !cmdOptions.contains("exam-mode")); + Dialog w(defaultTab, cmdOptions.contains("exam-mode")); /* DOWNLOAD VSESSIONS */ HttpXmlDownloader httpxmldownloader; |