From 6decac6613fef21869784df0d83a0b7c7d1c2008 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 28 Oct 2016 16:14:07 +0200 Subject: [client] Allow ESC key to cancel projection in hybrid mode --- src/client/toolbar/toolbar.cpp | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'src/client/toolbar/toolbar.cpp') diff --git a/src/client/toolbar/toolbar.cpp b/src/client/toolbar/toolbar.cpp index d6bcf22..8af15f4 100644 --- a/src/client/toolbar/toolbar.cpp +++ b/src/client/toolbar/toolbar.cpp @@ -103,17 +103,13 @@ 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())); /* Setup menu */ initMenu(); - /* setup manager button */ - if (clientApp->isManagerPc()) { - connect(_ui->btnManager, SIGNAL(toggled(bool)), this, SLOT(onBtnManager())); - } else { - setFixedWidth(width() - _ui->btnManager->width()); - _ui->btnManager->setVisible(false); - } + updateButtonVisibility(); /* setup lock desktop button*/ bool showLock = clientApp->getSettings()->value("showLockDesktopButton").toBool(); @@ -126,8 +122,6 @@ void Toolbar::init() /* hide attention button while disconnected */ _ui->btnAttention->setVisible(false); - - connect(_ui->btnAttention, SIGNAL(toggled(bool)), this, SLOT(onBtnAttention())); _ui->btnAttention->setMaximumWidth(30); /* Connect the signals from vnc server */ @@ -188,6 +182,23 @@ void Toolbar::initMenu() connect(_acnQuit, SIGNAL(triggered()), this, SLOT(exit())); } +void Toolbar::updateButtonVisibility() +{ + // "Toggle to manager view" (switch between desktop 1 and 2) + bool showManagerToggle = clientApp->isConfiguredAsManager() || clientApp->isConnectedToLocalManager(); + if (showManagerToggle == _ui->btnManager->isHidden()) { + // Visibility should change + if (showManagerToggle) { + connect(_ui->btnManager, SIGNAL(toggled(bool)), this, SLOT(onBtnManager())); + setFixedWidth(width() + _ui->btnManager->width()); + } else { + disconnect(_ui->btnManager, SIGNAL(toggled(bool)), this, SLOT(onBtnManager())); + setFixedWidth(width() - _ui->btnManager->width()); + } + _ui->btnManager->setVisible(showManagerToggle); + } +} + /***************************************************************************//** * Destructor of the Toolbar. Destroys the widget. All this widget's children * are deleted first. @@ -358,6 +369,7 @@ void Toolbar::onDisconnected(ServerConnection* connection) _ui->btnAttention->setVisible(false); onBtnAttention(); _hideTimer.start(); + QTimer::singleShot(1, this, SLOT(updateButtonVisibility())); } /***************************************************************************//** @@ -376,6 +388,7 @@ void Toolbar::onConnected(ServerConnection* connection) _ui->lblStatus->setText(tr("Online")); /* connected, show button */ _ui->btnAttention->setVisible(true); + QTimer::singleShot(1, this, SLOT(updateButtonVisibility())); // connect(connection, SIGNAL(disconnected(ServerConnection*)), this, SLOT(onDisconnected(ServerConnection*))); connect(connection, SIGNAL(openVnc(const QString&, int, const QString&, bool, bool, const QString&, const int, const QByteArray&)), -- cgit v1.2.3-55-g7522