diff options
Diffstat (limited to 'src/client/toolbar/toolbar.cpp')
-rw-r--r-- | src/client/toolbar/toolbar.cpp | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/src/client/toolbar/toolbar.cpp b/src/client/toolbar/toolbar.cpp index 5fe34e4..10f9d22 100644 --- a/src/client/toolbar/toolbar.cpp +++ b/src/client/toolbar/toolbar.cpp @@ -92,8 +92,6 @@ void Toolbar::init() /* Initialize the GUI */ _ui->setupUi(this); - _onWorkspace2 = false; - /* Set window properties */ setWindowFlags(Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint | Qt::FramelessWindowHint); setAttribute(Qt::WA_AlwaysShowToolTips); @@ -115,7 +113,7 @@ void Toolbar::init() /* setup manager button */ _isManagerPc = isManagerPc(); if (_isManagerPc) { - connect(_ui->btnManager, SIGNAL(clicked()), this, SLOT(onBtnManager())); + connect(_ui->btnManager, SIGNAL(toggled(bool)), this, SLOT(onBtnManager())); } else { setFixedWidth(width() - _ui->btnManager->width()); _ui->btnManager->setVisible(false); @@ -130,6 +128,8 @@ void Toolbar::init() _ui->btnLockDesktop->setVisible(false); } + connect(_ui->btnAttention, SIGNAL(toggled(bool)), this, SLOT(onBtnAttention())); + /* Connect the signals from vnc server */ connect(VncServer::instance(), SIGNAL(started(int, QString&, QString&)), this, SLOT(onVncServerIsRunning(int))); @@ -379,6 +379,8 @@ void Toolbar::onDisconnected() this->_acnConnect->setEnabled(true); this->_acnDisconnect->setEnabled(false); + onBtnAttention(); + _hideTimer.start(); } /***************************************************************************//** @@ -392,7 +394,7 @@ void Toolbar::onConnected(ServerConnection* connection) this->_acnConnect->setEnabled(false); this->_acnDisconnect->setEnabled(true); - + _ui->btnAttention->setChecked(false); _ui->lblStatus->setStyleSheet("color:green"); _ui->lblStatus->setText(tr("Online")); // @@ -406,6 +408,7 @@ void Toolbar::onConnected(ServerConnection* connection) connect(_connection, SIGNAL(openVnc(const QString&, int, const QString&, bool, bool, const QString&, const int, const QByteArray&)), _vnc, SLOT(open(const QString&, int, const QString&, bool, bool, const QString&, const int, const QByteArray&))); connect(_connection, SIGNAL(closeVnc()), _vnc, SLOT(close())); + connect(_connection, SIGNAL(attentionChanged(const bool)), this, SLOT(onServerAttentionChanged(const bool))); connect(_vnc, SIGNAL(running(const bool, const int)), _connection, SLOT(onVncViewerStartStop(const bool, const int))); } @@ -418,6 +421,16 @@ void Toolbar::onDoDisconnect() _connection->disconnectFromServer(); } +void Toolbar::onServerAttentionChanged(const bool on) +{ + _ui->btnAttention->setChecked(on); + if (on) { + showBar(); + } else { + hideBar(); + } +} + /***************************************************************************//** * This slot hides the toolbar. Places the toolbar hidden behind the edge of the * screen just showing 2 pixels. @@ -425,7 +438,7 @@ void Toolbar::onDoDisconnect() void Toolbar::hideBar() { // Don't hide window if any menu is open or VNC Server is running from this client. - if (_menu->isVisible() || VncServer::instance()->isVncServerRunning()) + if (_menu->isVisible() || _ui->btnAttention->isChecked() || VncServer::instance()->isVncServerRunning()) return; const QDesktopWidget desktop; const QRect primaryScreen = desktop.screenGeometry(); @@ -465,17 +478,30 @@ void Toolbar::showBar() const QRect primaryScreen = desktop.screenGeometry(); move(x(), primaryScreen.top()); } + +void Toolbar::onBtnAttention() +{ + const bool on = _connection != NULL && _ui->btnAttention->isChecked(); + if (on != _ui->btnAttention->isChecked()) { + _ui->btnAttention->setChecked(on); + return; + } + if (_connection != NULL) { + _connection->sendAttention(on); + } + _ui->btnAttention->setStyleSheet(on ? "color:red" : ""); +} + /** call script to switch to workspace of the manager */ void Toolbar::onBtnManager() { QProcess switchP; - if (_onWorkspace2) { - switchP.start("/bin/sh", QStringList() << "/opt/openslx/pvs2/switchBack.sh"); - } else { + const bool on = _ui->btnAttention->isChecked(); + if (on) { switchP.start("/bin/sh", QStringList() << "/opt/openslx/pvs2/switchToManager.sh"); + } else { + switchP.start("/bin/sh", QStringList() << "/opt/openslx/pvs2/switchBack.sh"); } - _ui->btnManager->setDown(_onWorkspace2); - _onWorkspace2 = !_onWorkspace2; switchP.waitForFinished(); } |