summaryrefslogtreecommitdiffstats
path: root/src/client/toolbar
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/toolbar')
-rw-r--r--src/client/toolbar/toolbar.cpp67
-rw-r--r--src/client/toolbar/toolbar.h42
-rw-r--r--src/client/toolbar/toolbar.ui233
3 files changed, 292 insertions, 50 deletions
diff --git a/src/client/toolbar/toolbar.cpp b/src/client/toolbar/toolbar.cpp
index 880e24f..bd5d689 100644
--- a/src/client/toolbar/toolbar.cpp
+++ b/src/client/toolbar/toolbar.cpp
@@ -2,7 +2,6 @@
#include "../net/serverconnection.h"
#include "../vnc/vncwindow.h"
#include "../vnc/vncserver.h"
-#include "../util/util.h"
#include "../informationdialog/informationdialog.h"
#include "../clientapp/clientapp.h"
#include "../addons/addons.h"
@@ -10,9 +9,11 @@
#include "toolbar.h"
#include "ui_toolbar.h"
-#include <QtAlgorithms>
#include <QNetworkInterface>
-#include <QProcess>
+#include <QScreen>
+#include <QMenu>
+#include <QMouseEvent>
+#include <QMessageBox>
/**
* @brief
@@ -24,8 +25,13 @@
* another widget, this widget becomes a child window inside parent. The new
* widget is deleted when its parent is deleted.
*/
-Toolbar::Toolbar(const QByteArray sessionName, QWidget *parent)
- : QWidget(parent), _showTimer(this), _hideTimer(this), _hideCountdown(10), _blinkTimer(this), _beWatchedEye(":eye")
+Toolbar::Toolbar(const QByteArray& sessionName, QWidget *parent)
+ : QWidget(parent)
+ , _showTimer(this)
+ , _hideTimer(this)
+ , _hideCountdown(10)
+ , _blinkTimer(this)
+ , _beWatchedEye(":eye")
{
qDebug() << "sessionName - constructor";
init();
@@ -44,7 +50,12 @@ Toolbar::Toolbar(const QByteArray sessionName, QWidget *parent)
* widget is deleted when its parent is deleted.
*/
Toolbar::Toolbar(const bool autoConnect, QWidget *parent)
- : QWidget(parent), _showTimer(this), _hideTimer(this), _hideCountdown(10), _blinkTimer(this), _beWatchedEye(":eye")
+ : QWidget(parent)
+ , _showTimer(this)
+ , _hideTimer(this)
+ , _hideCountdown(10)
+ , _blinkTimer(this)
+ , _beWatchedEye(":eye")
{
qDebug() << "auto - constructor!";
init();
@@ -100,9 +111,9 @@ void Toolbar::init()
/* Create the connect window */
clientApp->connectWindow()->setAvailableRooms(myRooms());
// Connect the signals
- connect(clientApp->connectWindow(), SIGNAL(disconnect()), this, SLOT(onDoDisconnect()));
- connect(clientApp->connectWindow(), SIGNAL(connected(ServerConnection*)), this, SLOT(onConnected(ServerConnection*)));
- connect(_ui->btnAttention, SIGNAL(toggled(bool)), this, SLOT(onBtnAttention()));
+ connect(clientApp->connectWindow(), &ConnectWindow::disconnect, this, &Toolbar::onDoDisconnect);
+ connect(clientApp->connectWindow(), &ConnectWindow::connected, this, &Toolbar::onConnected);
+ connect(_ui->btnAttention, &QToolButton::toggled, this, &Toolbar::onBtnAttention);
/* Setup menu */
initButtonsAndMenus();
@@ -112,7 +123,7 @@ void Toolbar::init()
_ui->btnAttention->setMaximumWidth(30);
/* Connect the signals from vnc server */
- connect(VncServer::instance(), SIGNAL(started(int, QString&, QString&)), this, SLOT(onVncServerIsRunning(int)));
+ connect(VncServer::instance(), &VncServer::started, this, &Toolbar::onVncServerIsRunning);
/* React to screen geometry change */
connect(QGuiApplication::primaryScreen(), &QScreen::availableGeometryChanged, this, &Toolbar::setToolbarPosition);
@@ -124,10 +135,10 @@ void Toolbar::init()
/* Setup show & hide timer */
_showTimer.setInterval(500);
_showTimer.setSingleShot(true);
- connect(&_showTimer, SIGNAL(timeout()), this, SLOT(showBar()));
+ connect(&_showTimer, &QTimer::timeout, this, &Toolbar::showBar);
_hideTimer.setInterval(50);
_hideTimer.setSingleShot(false);
- connect(&_hideTimer, SIGNAL(timeout()), this, SLOT(hideBar()));
+ connect(&_hideTimer, &QTimer::timeout, this, &Toolbar::hideBar);
setVisible(true);
raise();
@@ -135,11 +146,11 @@ void Toolbar::init()
/* Setup blink timer */
_blinkTimer.setInterval(500);
- connect(&_blinkTimer, SIGNAL(timeout()), this, SLOT(cameraBlink()));
+ connect(&_blinkTimer, &QTimer::timeout, this, &Toolbar::cameraBlink);
}
static QFrame* makeVerticalLine() {
- QFrame *f = new QFrame();
+ auto *f = new QFrame();
f->setFrameShape(QFrame::HLine);
f->setFrameShadow(QFrame::Sunken);
return f;
@@ -191,12 +202,12 @@ void Toolbar::initButtonsAndMenus()
_acnQuit->setVisible(allow);
// Connect the signals
- connect(_menu, SIGNAL(aboutToHide()), this, SLOT(delayedHideBar()));
- connect(_acnConnect, SIGNAL(triggered()), clientApp->connectWindow(), SLOT(doShow()));
- connect(_acnDisconnect, SIGNAL(triggered()), clientApp->connectWindow(), SLOT(DoDisconnect()));
- connect(_acnInformation, SIGNAL(triggered()), this, SLOT(showInformationDialog()));
- connect(_acnAbout, SIGNAL(triggered()), this, SLOT(showAboutDialog()));
- connect(_acnQuit, SIGNAL(triggered()), this, SLOT(exit()));
+ connect(_menu, &QMenu::aboutToHide, this, &Toolbar::delayedHideBar);
+ connect(_acnConnect, &QAction::triggered, clientApp->connectWindow(), &ConnectWindow::doShow);
+ connect(_acnDisconnect, &QAction::triggered, clientApp->connectWindow(), &ConnectWindow::DoDisconnect);
+ connect(_acnInformation, &QAction::triggered, this, &Toolbar::showInformationDialog);
+ connect(_acnAbout, &QAction::triggered, this, &Toolbar::showAboutDialog);
+ connect(_acnQuit, &QAction::triggered, this, &Toolbar::exit);
// Delay until bar is visible
QTimer::singleShot(10, [=]() {
@@ -363,7 +374,7 @@ void Toolbar::onVncServerIsRunning(int port)
void Toolbar::onDisconnected(ServerConnection* connection)
{
if (connection != nullptr) {
- disconnect(connection, SIGNAL(disconnected(ServerConnection*)), this, SLOT(onDisconnected(ServerConnection*)));
+ disconnect(connection, &ServerConnection::disconnected, this, &Toolbar::onDisconnected);
}
_ui->lblStatus->setStyleSheet("color:red");
_ui->lblStatus->setText(tr("Offline"));
@@ -394,12 +405,12 @@ void Toolbar::onConnected(ServerConnection* connection)
_ui->btnAttention->setVisible(true);
AddonManager::connectEvent(connection->isLocalConnection(), connection->getPeerAdress());
//
- 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&)),
- _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)));
+ connect(connection, &ServerConnection::disconnected, this, &Toolbar::onDisconnected);
+ connect(connection, &ServerConnection::openVnc,
+ _vnc, &VncWindow::open);
+ connect(connection, &ServerConnection::closeVnc, _vnc, &VncWindow::close);
+ connect(connection, &ServerConnection::attentionChanged, this, &Toolbar::onServerAttentionChanged);
+ connect(_vnc, &VncWindow::running, connection, &ServerConnection::onVncViewerStartStop);
}
/**
@@ -489,7 +500,7 @@ void Toolbar::showAboutDialog()
void Toolbar::showInformationDialog()
{
- InformationDialog* d = new InformationDialog();
+ auto* d = new InformationDialog();
d->exec();
d->deleteLater();
}
diff --git a/src/client/toolbar/toolbar.h b/src/client/toolbar/toolbar.h
index 48fbf03..702bae2 100644
--- a/src/client/toolbar/toolbar.h
+++ b/src/client/toolbar/toolbar.h
@@ -14,13 +14,15 @@
#ifndef PVSCLIENTGUI_H_
#define PVSCLIENTGUI_H_
-#include <QtWidgets>
+#include <QWidget>
+#include <QTimer>
#include "../util/room.h"
class ServerConnection;
class VncWindow;
class BlankScreen;
+class QMenu;
namespace Ui
{
@@ -32,47 +34,43 @@ class Toolbar : public QWidget
Q_OBJECT
public:
- Toolbar(QWidget *parent = 0);
- Toolbar(const QByteArray sessionName, QWidget *parent = 0);
- Toolbar(const bool autoConnect, QWidget *parent = 0);
- virtual ~Toolbar();
+ explicit Toolbar(QWidget *parent = nullptr);
+ explicit Toolbar(const QByteArray& sessionName, QWidget *parent = nullptr);
+ explicit Toolbar(bool autoConnect, QWidget *parent = nullptr);
+ ~Toolbar() override;
private:
- Ui::Toolbar *_ui;
- QMenu *_menu;
- QAction *_acnDisconnect;
- QAction *_acnConnect;
- QAction *_acnInformation;
- QAction *_acnAbout;
- QAction *_acnQuit;
+ Ui::Toolbar *_ui{};
+ QMenu *_menu{};
+ QAction *_acnDisconnect{};
+ QAction *_acnConnect{};
+ QAction *_acnInformation{};
+ QAction *_acnAbout{};
+ QAction *_acnQuit{};
QTimer _showTimer;
QTimer _hideTimer;
int _hideCountdown;
QTimer _blinkTimer;
- VncWindow *_vnc;
- bool _isManagerPc;
+ VncWindow *_vnc{};
const QPixmap _cam32, _beWatchedEye;
QPoint _lastDragPos;
- int _yPos;
- int _yPosHidden;
+ int _yPos{};
+ int _yPosHidden{};
void enterEvent(QEvent* e) override;
void mousePressEvent(QMouseEvent* event) override;
void mouseMoveEvent(QMouseEvent* event) override;
- QList<Room> myRooms();
- bool isManagerPc();
- QString identifyMgrIP();
+ static QList<Room> myRooms();
+ static QString identifyMgrIP();
void init();
void initButtonsAndMenus();
- QProcess lockDesktopP;
-
private slots:
void onVncServerIsRunning(int port);
void onDisconnected(ServerConnection* connection);
void onConnected(ServerConnection* connection);
- void onServerAttentionChanged(const bool on);
+ void onServerAttentionChanged(bool on);
void onDoDisconnect();
void onBtnAttention();
void exit();
diff --git a/src/client/toolbar/toolbar.ui b/src/client/toolbar/toolbar.ui
new file mode 100644
index 0000000..9908dda
--- /dev/null
+++ b/src/client/toolbar/toolbar.ui
@@ -0,0 +1,233 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Toolbar</class>
+ <widget class="QWidget" name="Toolbar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>281</width>
+ <height>28</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string notr="true">Form</string>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">#Toolbar {
+ background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #f6f7fa, stop: 1 #dadbde);
+ border-radius: 0px;
+}
+QLabel {
+ background-color: none;
+}
+/* QPushButton */
+QPushButton {
+ background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #f6f7fa, stop: 1 #dadbde);
+ border: 2px solid #8f8f91;
+ border-radius: 4px;
+ min-width: 80px;
+}
+QPushButton:hover {
+ border: 2px solid rgb(0, 170, 255);
+}
+QPushButton:pressed {
+ background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #dadbde, stop: 1 #f6f7fa);
+}
+QPushButton:checked {
+ background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #cacbce, stop: 1 #e6e7ea);
+}
+QPushButton::menu-indicator {
+ image: url(:/darrow16.svg);
+}
+</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="spacing">
+ <number>1</number>
+ </property>
+ <property name="leftMargin">
+ <number>2</number>
+ </property>
+ <property name="topMargin">
+ <number>2</number>
+ </property>
+ <property name="rightMargin">
+ <number>2</number>
+ </property>
+ <property name="bottomMargin">
+ <number>2</number>
+ </property>
+ <item>
+ <widget class="QPushButton" name="cmdMenu">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>84</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Menu</string>
+ </property>
+ <property name="text">
+ <string>Menu</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="spacer_left">
+ <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="lblStatus">
+ <property name="styleSheet">
+ <string notr="true">color:red</string>
+ </property>
+ <property name="text">
+ <string notr="true">Offline</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>19</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLabel" name="icon_cam">
+ <property name="minimumSize">
+ <size>
+ <width>16</width>
+ <height>16</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>16</width>
+ <height>16</height>
+ </size>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="scaledContents">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="icon_pvs">
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ <weight>75</weight>
+ <italic>true</italic>
+ <bold>true</bold>
+ <kerning>true</kerning>
+ </font>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">color:#05f;</string>
+ </property>
+ <property name="text">
+ <string notr="true">PVS</string>
+ </property>
+ </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>
+ <layout class="QHBoxLayout" name="buttonContainer"/>
+ </item>
+ <item>
+ <widget class="QToolButton" name="btnAttention">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>30</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>30</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="sizeIncrement">
+ <size>
+ <width>30</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="baseSize">
+ <size>
+ <width>30</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string notr="true"/>
+ </property>
+ <property name="icon">
+ <iconset resource="../../pvsclient.qrc">
+ <normaloff>:/hand-raise</normaloff>
+ <normalon>:/hand-raise-red</normalon>:/hand-raise</iconset>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>22</width>
+ <height>22</height>
+ </size>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources>
+ <include location="../../pvsclient.qrc"/>
+ </resources>
+ <connections/>
+</ui>