diff options
author | Simon Rettberg | 2014-02-07 18:01:30 +0100 |
---|---|---|
committer | Simon Rettberg | 2014-02-07 18:01:30 +0100 |
commit | 290046118326ae16dacfcba94378060902dd14cb (patch) | |
tree | 227029e3b48deb1d4d01ce497d9ec3b8d47f7a61 /src | |
parent | Check if the window is still centered once a second and move it if neccessary. (diff) | |
download | vmchooser-290046118326ae16dacfcba94378060902dd14cb.tar.gz vmchooser-290046118326ae16dacfcba94378060902dd14cb.tar.xz vmchooser-290046118326ae16dacfcba94378060902dd14cb.zip |
Add support for autostarting a session predefined in /opt/openslx/config in SLX_BENCHMARK_VMHEADmaster
Diffstat (limited to 'src')
-rw-r--r-- | src/dialog.cpp | 18 | ||||
-rw-r--r-- | src/dialog.h | 4 | ||||
-rw-r--r-- | src/globals.h | 2 | ||||
-rw-r--r-- | src/main.cpp | 10 |
4 files changed, 30 insertions, 4 deletions
diff --git a/src/dialog.cpp b/src/dialog.cpp index 8ff215e..d758b0a 100644 --- a/src/dialog.cpp +++ b/src/dialog.cpp @@ -150,7 +150,7 @@ void Dialog::on_comboBoxOthers_currentIndexChanged(int index) { } } -void Dialog::selectSession(const QString& name) { +bool Dialog::selectSession(const QString& name) { QModelIndex root(ui->treeView->rootIndex()); for (int i = 0; i < model_->rowCount(root); ++i) { @@ -167,16 +167,21 @@ void Dialog::selectSession(const QString& name) { if (s->shortDescription() == name) { ui->treeView->selectionModel() ->setCurrentIndex(index, QItemSelectionModel::Select); - return; + return true; } } } + return false; } void Dialog::selectPreviousSession() { selectSession(readSessionName()); } +void Dialog::startSession(const QString& name) { + autoStartEntry_ = name; +} + void Dialog::showSettingsPVS() { pvsSettings_ = new QSettings("openslx", "pvs", this); QStringList accessOptions; @@ -223,6 +228,15 @@ void Dialog::setTheme() { } void Dialog::on_centerTimer() { + if (!autoStartEntry_.isEmpty()) { + if (this->selectSession(autoStartEntry_)) { + this->on_treeView_activated(ui->treeView->selectionModel()->currentIndex()); + } else { + QMessageBox::critical(this, "Autostart", QString::fromUtf8("Konnte %1 nicht starten.").arg(autoStartEntry_)); + } + autoStartEntry_.clear(); + return; + } // center dialog on primary screen QRect desktopRect = QApplication::desktop()->availableGeometry(this); QPoint center = desktopRect.center(); diff --git a/src/dialog.h b/src/dialog.h index cc3627a..d1daa68 100644 --- a/src/dialog.h +++ b/src/dialog.h @@ -19,10 +19,11 @@ class Dialog : public QDialog { explicit Dialog(QWidget *parent = 0); ~Dialog(); void addItems(const QList<Session*>&, const QString& section); - void selectSession(const QString& name); + bool selectSession(const QString& name); void selectPreviousSession(); void showSettingsPVS(); void setTheme(); + void startSession(const QString& name); protected: void changeEvent(QEvent *e); @@ -33,6 +34,7 @@ class Dialog : public QDialog { QSettings *pvsSettings_; QPoint oldCenter_; QTimer *centerTimer_; + QString autoStartEntry_; void readPVSSettings(); void writePVSSettings(); diff --git a/src/globals.h b/src/globals.h index f32fc64..32ecedb 100644 --- a/src/globals.h +++ b/src/globals.h @@ -16,6 +16,8 @@ #define VMCHOOSER_DEFAULT_WIDTH 500 #define VMCHOOSER_DEFAULT_HEIGHT 580 +#define OPENSLXCONFIG "/opt/openslx/config" + class QString; extern bool debugMode; diff --git a/src/main.cpp b/src/main.cpp index e5b8ce5..8ccbba2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -217,7 +217,15 @@ int main(int argc, char *argv[]) { qSort(vsessions.begin(), vsessions.end(), myLessThan); w.addItems(vsessions, a.translate("Dialog", "Virtual Sessions")); } - w.selectSession(defaultSession); + + QSettings SLXsettings(OPENSLXCONFIG, QSettings::NativeFormat); + if ( SLXsettings.contains("SLX_BENCHMARK_VM") ) { + QString vm = SLXsettings.value("SLX_BENCHMARK_VM").toString(); + vm.remove('\''); + w.startSession(vm); + } else { + w.selectSession(defaultSession); + } w.show(); // center dialog on primary screen |