From 57530207207a6cf9b21433e9da19d8f23091344a Mon Sep 17 00:00:00 2001 From: Manuel Schneider Date: Wed, 23 Jul 2014 14:04:08 +0200 Subject: Only set the sessionID. Drop old pvs stuff. --- src/dialog.cpp | 117 +++++++++++++-------------------------------------------- 1 file changed, 26 insertions(+), 91 deletions(-) (limited to 'src/dialog.cpp') diff --git a/src/dialog.cpp b/src/dialog.cpp index f6b67b1..ae157ba 100644 --- a/src/dialog.cpp +++ b/src/dialog.cpp @@ -32,9 +32,6 @@ Dialog::Dialog(QWidget *parent) strings_[STR_URL_ERROR] = QCoreApplication::instance()->translate("Dialog", "URL Error"); strings_[STR_NO_ITEMS] = QCoreApplication::instance()->translate("Dialog", "No Items"); - pvsSettings_ = NULL; - ui->PVSOptionsGroupBox->hide(); - // Re-center dialog every second to account for resolution changes QRect desktopRect = QApplication::desktop()->availableGeometry(this); oldCenter_ = desktopRect.center(); @@ -94,25 +91,32 @@ void Dialog::on_treeView_activated(QModelIndex index) { return; } - // Run session start script - if (QFile::exists(sessionStartScript)) { - QProcess scriptProcess; - scriptProcess.start(sessionStartScript, QIODevice::ReadOnly); - scriptProcess.waitForFinished(); - scriptProcess.close(); - } - - if (s->run()) { - writePVSSettings(); - ChooserSettings::setSetting("last-session", (s->shortDescription())); - ChooserSettings::setSetting("last-tab", QString::number(activeTab_)); - setVisible(false); - - } else { - QMessageBox::warning( - this, trUtf8("vmchooser"), - trUtf8("Vmchooser failed to run the selected session!")); - } + if (s->run()) { + // Run session start script + if (QFile::exists(sessionStartScript)) { + // Use the current environment variables and add the necessary + // information for the startUpScipt. In this case it is intended to tell + // the startupscript if the PVS should be started. Further in the future + // the session id will be passed this way. + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + if (ui->PVS_checkbox->isChecked()) { + env.insert("PVS_SESSIONID", "xxxx"); + } + QProcess scriptProcess; + scriptProcess.setProcessEnvironment(env); + scriptProcess.start(sessionStartScript, QIODevice::ReadOnly); + scriptProcess.waitForFinished(); + scriptProcess.close(); + } + + ChooserSettings::setSetting("last-session", (s->shortDescription())); + ChooserSettings::setSetting("last-tab", QString::number(activeTab_)); + setVisible(false); + } else { + QMessageBox::warning( + this, trUtf8("vmchooser"), + trUtf8("Vmchooser failed to run the selected session!")); + } } void Dialog::addItems(const QList& entries, int tab) { @@ -157,65 +161,6 @@ void Dialog::on_pushButtonStart_clicked() { this->on_treeView_activated(ui->treeView->selectionModel()->currentIndex()); } -void Dialog::readPVSSettings() { - if (!pvsSettings_) return; - QString value; - - value = pvsSettings_->value("Permissions/vnc_lecturer").toString(); - if (value == "rw") { - ui->comboBoxLecturer->setCurrentIndex(2); - } else if (value == "ro") { - ui->comboBoxLecturer->setCurrentIndex(1); - } else { - ui->comboBoxLecturer->setCurrentIndex(0); - } - - value = pvsSettings_->value("Permissions/vnc_other").toString(); - if (value == "rw") { - ui->comboBoxOthers->setCurrentIndex(2); - } else if (value == "ro") { - ui->comboBoxOthers->setCurrentIndex(1); - } else { - ui->comboBoxOthers->setCurrentIndex(0); - } -} - -void Dialog::writePVSSettings() { - if (!pvsSettings_) return; - int accessLecturer = ui->comboBoxLecturer->currentIndex(); - if (accessLecturer == 2) { - pvsSettings_->setValue("Permissions/vnc_lecturer", "rw"); - } else if (accessLecturer == 1) { - pvsSettings_->setValue("Permissions/vnc_lecturer", "ro"); - } else { - pvsSettings_->setValue("Permissions/vnc_lecturer", "no"); - } - - int accessOthers = ui->comboBoxOthers->currentIndex(); - if (accessOthers == 2) { - pvsSettings_->setValue("Permissions/vnc_other", "rw"); - } else if (accessOthers == 1) { - pvsSettings_->setValue("Permissions/vnc_other", "ro"); - } else { - pvsSettings_->setValue("Permissions/vnc_other", "no"); - } - pvsSettings_->sync(); -} - -void Dialog::on_comboBoxLecturer_currentIndexChanged(int index) { - // TODO (Jan): may others have more access than lecturer? - if (index < ui->comboBoxOthers->currentIndex()) { - ui->comboBoxOthers->setCurrentIndex(index); - } -} - -void Dialog::on_comboBoxOthers_currentIndexChanged(int index) { - // TODO (Jan): may others have more access than lecturer? - if (index > ui->comboBoxLecturer->currentIndex()) { - ui->comboBoxLecturer->setCurrentIndex(index); - } -} - bool Dialog::selectSession(const QString& name) { QModelIndex root(ui->treeView->rootIndex()); @@ -260,16 +205,6 @@ void Dialog::startSession(const QString& name) { autoStartEntry_ = name; } -void Dialog::showSettingsPVS() { - pvsSettings_ = new QSettings("openslx", "pvs", this); - QStringList accessOptions; - accessOptions << trUtf8("None") << trUtf8("View Only") << trUtf8("Full"); - ui->comboBoxLecturer->insertItems(0, accessOptions); - ui->comboBoxOthers->insertItems(0, accessOptions); - readPVSSettings(); - ui->PVSOptionsGroupBox->show(); -} - void Dialog::setTheme() { QString label_l_style, label_r_style; QString backgroundColor, imageLeft, imageRight; -- cgit v1.2.3-55-g7522