From d41aa490b2c00ffe31023b96b3daff523d4757c1 Mon Sep 17 00:00:00 2001 From: Christian Klinger Date: Wed, 18 May 2016 16:53:12 +0200 Subject: added toolbar button to switch to manager. The actual window switching logic is delegated to a pair of shell scripts. --- src/client/toolbar/toolbar.cpp | 47 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'src/client/toolbar/toolbar.cpp') diff --git a/src/client/toolbar/toolbar.cpp b/src/client/toolbar/toolbar.cpp index 83b1a9d..1f98a8b 100644 --- a/src/client/toolbar/toolbar.cpp +++ b/src/client/toolbar/toolbar.cpp @@ -88,6 +88,8 @@ 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); @@ -106,6 +108,12 @@ void Toolbar::init() /* Setup menu */ initMenu(); + /* setup manager button */ + _isManagerPc = isManagerPc(); + _ui->btnManager->setVisible(_isManagerPc); + connect(_ui->btnManager, SIGNAL(clicked()), this, SLOT(onBtnManager())); + + /* Connect the signals from vnc server */ connect(VncServer::instance(), SIGNAL(started(int, QString&, QString&)), this, SLOT(onVncServerIsRunning(int))); @@ -210,6 +218,30 @@ void Toolbar::enterEvent(QEvent* e) * */ + +/* returns true when the pc of this client is also eligible to be a manager */ +bool Toolbar::isManagerPc(){ + QList myRooms; + SYSTEM_SETTINGS(conf); + QStringList roomNames = conf.value("rooms").toStringList(); + + /* go through all rooms and check if this client is a manager of the room. */ + for (auto roomName : roomNames) { + conf.beginGroup(roomName); + QString mgrIP = conf.value("mgrIP").toString(); + + foreach (const QHostAddress &address, QNetworkInterface::allAddresses()) { + QString ip = conf.value("ip").toString(); + if (address.toString() == mgrIP) { + qDebug() << "this pc could be a manager of room " << roomName << "because this address is " << address; + return true; + } + } + conf.endGroup(); + } + return false; +} + /* returns a sorted list of available rooms. * (Available means that this client is configured to be in that room) */ QList Toolbar::myRooms() { @@ -407,3 +439,18 @@ void Toolbar::showBar() const QRect primaryScreen = desktop.screenGeometry(); move(x(), primaryScreen.top()); } +void Toolbar::onBtnManager() { + /* TODO */ + qDebug() << "onBtnManager()"; + + /* call script to switch to workspace of the manager */ + QProcess switchP; + if (_onWorkspace2) { + switchP.start("/bin/sh", QStringList() << "/opt/openslx/pvs2/switchBack.sh"); + } else { + switchP.start("/bin/sh", QStringList() << "/opt/openslx/pvs2/switchToManager.sh"); + } + _ui->btnManager->setDown(_onWorkspace2); + _onWorkspace2 = !_onWorkspace2; + switchP.waitForFinished(); +} -- cgit v1.2.3-55-g7522