summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/toolbar/toolbar.cpp23
-rw-r--r--src/client/toolbar/toolbar.h7
2 files changed, 20 insertions, 10 deletions
diff --git a/src/client/toolbar/toolbar.cpp b/src/client/toolbar/toolbar.cpp
index ddb55f1..a3e2c31 100644
--- a/src/client/toolbar/toolbar.cpp
+++ b/src/client/toolbar/toolbar.cpp
@@ -106,8 +106,10 @@ void Toolbar::init()
// Connect the signals
connect(clientApp->connectWindow(), SIGNAL(disconnect()), this, SLOT(onDoDisconnect()));
connect(clientApp->connectWindow(), SIGNAL(connected(ServerConnection*)), this, SLOT(onConnected(ServerConnection*)));
- connect(_ui->btnManager, SIGNAL(toggled(bool)), this, SLOT(onBtnManager()));
connect(_ui->btnAttention, SIGNAL(toggled(bool)), this, SLOT(onBtnAttention()));
+ connect(_ui->btnManager, &QPushButton::toggled, [=](bool pressed) {
+ this->toggleDesktop(pressed ? Desktop::Manager : Desktop::Primary);
+ });
/* Setup menu */
initMenu();
@@ -198,11 +200,14 @@ void Toolbar::updateButtonVisibility()
if (showManagerToggle == _ui->btnManager->isHidden()) {
// Visibility should change
if (showManagerToggle) {
- connect(_ui->btnManager, SIGNAL(toggled(bool)), this, SLOT(onBtnManager()));
+ _ui->btnManager->blockSignals(false);
setFixedWidth(width() + _ui->btnManager->width());
} else {
- disconnect(_ui->btnManager, SIGNAL(toggled(bool)), this, SLOT(onBtnManager()));
+ // Hide "toggle manager" -- assume manager was closed, switch to first desktop where the VM should be running
+ _ui->btnManager->blockSignals(true);
+ _ui->btnManager->setChecked(false);
setFixedWidth(width() - _ui->btnManager->width());
+ toggleDesktop(Desktop::Primary);
}
_ui->btnManager->setVisible(showManagerToggle);
}
@@ -497,14 +502,16 @@ void Toolbar::onBtnAttention()
}
/** call script to switch to workspace of the manager */
-void Toolbar::onBtnManager()
+void Toolbar::toggleDesktop(Desktop d)
{
QProcess switchP;
- const bool on = _ui->btnManager->isChecked();
- if (on) {
+ if (d == Desktop::Manager) {
switchP.start("/bin/sh", QStringList() << "/opt/openslx/pvs2/switchToManager.sh");
- } else {
+ } else if (d == Desktop::Primary) {
switchP.start("/bin/sh", QStringList() << "/opt/openslx/pvs2/switchBack.sh");
+ } else {
+ qDebug() << "Invalid toggleDesktop call";
+ return;
}
switchP.waitForFinished();
}
@@ -513,7 +520,6 @@ void Toolbar::onBtnLockDesktop()
{
if (this->lockDesktopP.state() == QProcess::NotRunning) {
_ui->btnLockDesktop->setEnabled(false);
- _ui->btnManager->setEnabled(false);
this->lockDesktopP.start("/bin/sh", QStringList() << "/opt/openslx/pvs2/lockDesktop.sh");
QTimer::singleShot(2 * 1000, this, SLOT(enableLockBtn()));
@@ -526,7 +532,6 @@ void Toolbar::onBtnLockDesktop()
void Toolbar::enableLockBtn()
{
_ui->btnLockDesktop->setEnabled(true);
- _ui->btnManager->setEnabled(true);
}
void Toolbar::setToolbarPosition(const QRect &availableGeometry)
diff --git a/src/client/toolbar/toolbar.h b/src/client/toolbar/toolbar.h
index a8e929f..fd1d993 100644
--- a/src/client/toolbar/toolbar.h
+++ b/src/client/toolbar/toolbar.h
@@ -27,6 +27,11 @@ namespace Ui
class Toolbar;
}
+enum class Desktop {
+ Primary,
+ Manager,
+};
+
class Toolbar : public QWidget
{
Q_OBJECT
@@ -61,6 +66,7 @@ private:
QString identifyMgrIP();
void init();
void initMenu();
+ void toggleDesktop(Desktop d);
QProcess lockDesktopP;
@@ -70,7 +76,6 @@ private slots:
void onConnected(ServerConnection* connection);
void onServerAttentionChanged(const bool on);
void onDoDisconnect();
- void onBtnManager();
void onBtnLockDesktop();
void onBtnAttention();
void exit();