summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Klinger2016-05-18 16:53:12 +0200
committerChristian Klinger2016-05-18 16:53:12 +0200
commitd41aa490b2c00ffe31023b96b3daff523d4757c1 (patch)
treef1a2edb5c7db5a61d6c6073a74d3c1209fdfb25d
parentprovided sample configuration. (diff)
downloadpvs2-d41aa490b2c00ffe31023b96b3daff523d4757c1.tar.gz
pvs2-d41aa490b2c00ffe31023b96b3daff523d4757c1.tar.xz
pvs2-d41aa490b2c00ffe31023b96b3daff523d4757c1.zip
added toolbar button to switch to manager.
The actual window switching logic is delegated to a pair of shell scripts.
-rw-r--r--gui/client/toolbar.ui38
-rw-r--r--src/client/toolbar/toolbar.cpp47
-rw-r--r--src/client/toolbar/toolbar.h4
3 files changed, 77 insertions, 12 deletions
diff --git a/gui/client/toolbar.ui b/gui/client/toolbar.ui
index 0c21f70..b4ac3b2 100644
--- a/gui/client/toolbar.ui
+++ b/gui/client/toolbar.ui
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>229</width>
+ <width>358</width>
<height>39</height>
</rect>
</property>
@@ -67,16 +67,7 @@ QCheckBox::indicator:checked:pressed {
</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="topMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
+ <property name="margin">
<number>0</number>
</property>
<item>
@@ -128,7 +119,7 @@ QCheckBox::indicator:checked:pressed {
</widget>
</item>
<item>
- <spacer name="spacer_right">
+ <spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@@ -152,6 +143,19 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item>
+ <spacer name="spacer_right">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
<widget class="QLabel" name="icon_cam">
<property name="minimumSize">
<size>
@@ -173,6 +177,16 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
+ <item>
+ <widget class="QPushButton" name="btnManager">
+ <property name="text">
+ <string>Switch</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
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<Room> 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<Room> 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();
+}
diff --git a/src/client/toolbar/toolbar.h b/src/client/toolbar/toolbar.h
index 6c61508..0980beb 100644
--- a/src/client/toolbar/toolbar.h
+++ b/src/client/toolbar/toolbar.h
@@ -49,11 +49,14 @@ private:
ServerConnection *_connection;
QTimer _blinkTimer;
VncWindow *_vnc;
+ bool _onWorkspace2;
+ bool _isManagerPc;
const QPixmap _cam32, _beWatchedEye;
void leaveEvent(QEvent* e);
void enterEvent(QEvent* e);
QList<Room> myRooms();
+ bool isManagerPc();
QString identifyMgrIP();
void init();
void initMenu();
@@ -63,6 +66,7 @@ private slots:
void onDisconnected();
void onConnected(ServerConnection* connection);
void onDoDisconnect();
+ void onBtnManager();
void exit();
void cameraBlink();
void showBar();