From 290046118326ae16dacfcba94378060902dd14cb Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 7 Feb 2014 18:01:30 +0100 Subject: Add support for autostarting a session predefined in /opt/openslx/config in SLX_BENCHMARK_VM --- src/dialog.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/dialog.cpp') 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(); -- cgit v1.2.3-55-g7522