summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Schneider2014-05-06 14:37:44 +0200
committerManuel Schneider2014-05-06 15:16:20 +0200
commit35c3facc81cf10a2070cc5091e4e447ecc7416e3 (patch)
tree0a29051637a37d419407fa266cb1d8234666f9d6
parentReduces button block time (diff)
downloadpvs2-35c3facc81cf10a2070cc5091e4e447ecc7416e3.tar.gz
pvs2-35c3facc81cf10a2070cc5091e4e447ecc7416e3.tar.xz
pvs2-35c3facc81cf10a2070cc5091e4e447ecc7416e3.zip
Changes the approach of Qt Gui initialization to the member pointer approach. This means multiple inheritance is avoided and the form is now a member pointer of the class. Immlicitely renamed some ui elements for clearification. Again changed unnecessary use of QDialog to QWidget.
-rw-r--r--gui/client/connect.ui8
-rw-r--r--gui/client/toolbar.ui30
-rw-r--r--src/client/connectwindow/connectwindow.cpp56
-rw-r--r--src/client/connectwindow/connectwindow.h11
-rw-r--r--src/client/toolbar/toolbar.cpp23
-rw-r--r--src/client/toolbar/toolbar.h13
-rw-r--r--src/server/mainwindow/mainwindow.h3
-rw-r--r--src/server/sessionnamewindow/sessionnamewindow.h5
-rw-r--r--src/shared/settings.h2
9 files changed, 88 insertions, 63 deletions
diff --git a/gui/client/connect.ui b/gui/client/connect.ui
index c702123..1cb873c 100644
--- a/gui/client/connect.ui
+++ b/gui/client/connect.ui
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
- <class>Dialog</class>
- <widget class="QDialog" name="Dialog">
+ <class>ConnectWindow</class>
+ <widget class="QWidget" name="ConnectWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
- <width>511</width>
- <height>121</height>
+ <width>512</width>
+ <height>128</height>
</rect>
</property>
<property name="windowTitle">
diff --git a/gui/client/toolbar.ui b/gui/client/toolbar.ui
index 8f32658..199eef2 100644
--- a/gui/client/toolbar.ui
+++ b/gui/client/toolbar.ui
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
- <class>ToolbarClass</class>
- <widget class="QWidget" name="ToolbarClass">
+ <class>Toolbar</class>
+ <widget class="QWidget" name="Toolbar">
<property name="geometry">
<rect>
<x>0</x>
@@ -66,8 +66,17 @@ QCheckBox::indicator:checked:pressed {
}
</string>
</property>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <property name="margin">
+ <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">
<number>0</number>
</property>
<item>
@@ -78,12 +87,12 @@ QCheckBox::indicator:checked:pressed {
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
- <layout class="QHBoxLayout" name="horizontalLayout">
+ <layout class="QHBoxLayout" name="horizontalLayout2">
<item>
<widget class="QPushButton" name="cmdMenu">
<property name="minimumSize">
<size>
- <width>68</width>
+ <width>84</width>
<height>0</height>
</size>
</property>
@@ -96,7 +105,7 @@ QCheckBox::indicator:checked:pressed {
</widget>
</item>
<item>
- <spacer name="horizontalSpacer">
+ <spacer name="spacer_left">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@@ -119,7 +128,7 @@ QCheckBox::indicator:checked:pressed {
</widget>
</item>
<item>
- <spacer name="horizontalSpacer_3">
+ <spacer name="spacer_right">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@@ -132,7 +141,7 @@ QCheckBox::indicator:checked:pressed {
</spacer>
</item>
<item>
- <widget class="QLabel" name="label">
+ <widget class="QLabel" name="icon_pvs">
<property name="text">
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
@@ -143,7 +152,7 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item>
- <widget class="QLabel" name="label_3">
+ <widget class="QLabel" name="icon_cam">
<property name="maximumSize">
<size>
<width>16</width>
@@ -168,7 +177,6 @@ p, li { white-space: pre-wrap; }
</widget>
<resources>
<include location="../../pvsclient.qrc"/>
- <include location="../../pvsclient.qrc"/>
</resources>
<connections/>
</ui>
diff --git a/src/client/connectwindow/connectwindow.cpp b/src/client/connectwindow/connectwindow.cpp
index ca01404..5215a32 100644
--- a/src/client/connectwindow/connectwindow.cpp
+++ b/src/client/connectwindow/connectwindow.cpp
@@ -5,26 +5,28 @@
* Author: sr
*/
-#include "connectwindow.h"
+#include <QNetworkInterface>
#include "../../shared/settings.h"
#include "../../shared/network.h"
#include "../../shared/util.h"
-
#include "../net/serverconnection.h"
-
-#include <QNetworkInterface>
+#include "connectwindow.h"
+#include "ui_connect.h"
#define UDPBUFSIZ 9000
#define SALT_LEN 18
ConnectWindow::ConnectWindow(QWidget *parent) :
- QDialog(parent), _connected(false), _timerDiscover(0), _timerHide(0), _connection(NULL), _state(Idle),
- _hashErrorCount(0), _hashSslErrorCount(0), _certErrorCount(0), _ipErrorCount(0), _discoveryInterval(800)
+ QWidget(parent), _ui(new Ui::ConnectWindow), _connected(false),
+ _timerDiscover(0), _timerHide(0), _connection(NULL), _state(Idle),
+ _hashErrorCount(0), _hashSslErrorCount(0), _certErrorCount(0),
+ _ipErrorCount(0), _discoveryInterval(800)
{
- setupUi(this);
- //
- connect(cmdOK, SIGNAL(clicked()), this, SLOT(onOkClick()));
- connect(cmdCancel, SIGNAL(clicked()), this, SLOT(onCancelClick()));
+ // Initialize the GUI
+ _ui->setupUi(this);
+
+ connect(_ui->cmdOK, SIGNAL(clicked()), this, SLOT(onOkClick()));
+ connect(_ui->cmdCancel, SIGNAL(clicked()), this, SLOT(onCancelClick()));
int tries = 10;
while (tries-- != 0)
{
@@ -66,51 +68,51 @@ void ConnectWindow::setState(const ConnectionState state)
void ConnectWindow::updateState()
{
- txtName->setEnabled(_state == Idle && !_connected);
+ _ui->txtName->setEnabled(_state == Idle && !_connected);
if (_connected)
{
- cmdOK->setEnabled(true);
- cmdOK->setText(tr("&Disconnect"));
- lblStatus->setText(tr("Connected."));
- txtName->setEnabled(false);
+ _ui->cmdOK->setEnabled(true);
+ _ui->cmdOK->setText(tr("&Disconnect"));
+ _ui->lblStatus->setText(tr("Connected."));
+ _ui->txtName->setEnabled(false);
return;
}
if (_state != Idle)
- cmdOK->setText(tr("&Stop"));
+ _ui->cmdOK->setText(tr("&Stop"));
else
- cmdOK->setText(tr("&Connect"));
+ _ui->cmdOK->setText(tr("&Connect"));
switch (_state)
{
case Idle:
- lblStatus->setText(tr("Ready to connect; please enter session name."));
+ _ui->lblStatus->setText(tr("Ready to connect; please enter session name."));
break;
case Scanning:
- lblStatus->setText(tr("Scanning for session %1.").arg(txtName->text()));
+ _ui->lblStatus->setText(tr("Scanning for session %1.").arg(_ui->txtName->text()));
_timerDiscover = startTimer(_discoveryInterval);
break;
case Connecting:
- lblStatus->setText(tr("Found session, connecting..."));
+ _ui->lblStatus->setText(tr("Found session, connecting..."));
break;
case AwaitingChallenge:
- lblStatus->setText(tr("Waiting for server challenge..."));
+ _ui->lblStatus->setText(tr("Waiting for server challenge..."));
break;
case AwaitingChallengeResponse:
- lblStatus->setText(tr("Replied to challenge, sent own..."));
+ _ui->lblStatus->setText(tr("Replied to challenge, sent own..."));
break;
case LoggingIn:
- lblStatus->setText(tr("Logging in..."));
+ _ui->lblStatus->setText(tr("Logging in..."));
break;
case Connected:
- lblStatus->setText(tr("Connection established!"));
+ _ui->lblStatus->setText(tr("Connection established!"));
break;
case InvalidIpList:
case InvalidHash:
case InvalidCert:
case InvalidSslHash:
- lblError->setText(tr("Invalid hash: %1; invalid cert: %2; invalid iplist: %3; invalid sslhash: %4")
+ _ui->lblError->setText(tr("Invalid hash: %1; invalid cert: %2; invalid iplist: %3; invalid sslhash: %4")
.arg(_hashErrorCount).arg(_certErrorCount).arg(_ipErrorCount).arg(_hashSslErrorCount));
break;
}
@@ -189,7 +191,7 @@ void ConnectWindow::closeEvent(QCloseEvent *e)
void ConnectWindow::showEvent(QShowEvent* event)
{
- txtName->setFocus();
+ _ui->txtName->setFocus();
}
/*
@@ -214,7 +216,7 @@ void ConnectWindow::onOkClick()
{
// Connect (scan for session)
_discoveryInterval = 800;
- _nameBytes = txtName->text().toUtf8();
+ _nameBytes = _ui->txtName->text().toUtf8();
_timerDiscover = startTimer(_discoveryInterval);
_hashErrorCount = _hashSslErrorCount = _certErrorCount = _ipErrorCount = 0;
this->setState(Scanning);
diff --git a/src/client/connectwindow/connectwindow.h b/src/client/connectwindow/connectwindow.h
index 2bc2f86..191121c 100644
--- a/src/client/connectwindow/connectwindow.h
+++ b/src/client/connectwindow/connectwindow.h
@@ -19,13 +19,14 @@
#include <QtGui>
#include <QUdpSocket>
#include <QSslSocket>
-#include "ui_connect.h"
-
#include "../../shared/networkmessage.h"
+namespace Ui{
+class ConnectWindow;
+}
class ServerConnection;
-class ConnectWindow : public QDialog, private Ui_Dialog
+class ConnectWindow : public QWidget
{
Q_OBJECT
@@ -46,6 +47,8 @@ public:
};
private:
+ Ui::ConnectWindow *_ui;
+
bool _connected;
int _timerDiscover, _timerHide;
ServerConnection *_connection;
@@ -62,7 +65,7 @@ private:
void updateState();
public:
- ConnectWindow(QWidget *parent = NULL);
+ explicit ConnectWindow(QWidget *parent = NULL);
virtual ~ConnectWindow();
void setConnected(const bool connected);
diff --git a/src/client/toolbar/toolbar.cpp b/src/client/toolbar/toolbar.cpp
index 34dafd5..bce6b6e 100644
--- a/src/client/toolbar/toolbar.cpp
+++ b/src/client/toolbar/toolbar.cpp
@@ -5,20 +5,26 @@
* Author: sr
*/
-#include "toolbar.h"
#include "../../shared/settings.h"
#include "../net/serverconnection.h"
#include "../vnc/vncwindow.h"
#include "../vnc/vncserver.h"
+#include "toolbar.h"
+#include "ui_toolbar.h"
+
Toolbar::Toolbar(QWidget *parent) :
- QWidget(parent), _location(POSITION_TOP_CENTER), _hideTimer(0), _connection(NULL)
+ QWidget(parent), _ui(new Ui::Toolbar), _location(POSITION_TOP_CENTER),
+ _hideTimer(0), _connection(NULL)
{
- setupUi(this);
+ // Initialize the GUI
+ _ui->setupUi(this);
+
setWindowFlags(Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint | Qt::FramelessWindowHint);
setAttribute(Qt::WA_AlwaysShowToolTips);
setAttribute(Qt::WA_QuitOnClose);
setVisible(true);
+
// VNC Window
_vnc = new VncWindow(NULL);
// Connect window
@@ -44,7 +50,7 @@ void Toolbar::setupMenu()
_menu->addSeparator();
_menu->addAction(_acnQuit);
- cmdMenu->setMenu(_menu);
+ _ui->cmdMenu->setMenu(_menu);
connect(_acnQuit, SIGNAL(triggered()), this, SLOT(onQuit()));
connect(_acnDisconnect, SIGNAL(triggered()), _connectWindow, SLOT(show()));
@@ -55,6 +61,7 @@ Toolbar::~Toolbar()
VncServer::instance()->stop();
_vnc->deleteLater();
_connectWindow->deleteLater();
+ delete _ui;
}
//###########\\/\/
@@ -164,14 +171,14 @@ void Toolbar::onDisconnected()
if (_connection != NULL)
_connection->blockSignals(true);
_connection = NULL;
- lblStatus->setStyleSheet("color:red");
- lblStatus->setText(tr("Offline"));
+ _ui->lblStatus->setStyleSheet("color:red");
+ _ui->lblStatus->setText(tr("Offline"));
}
void Toolbar::onConnected(ServerConnection* connection)
{
- lblStatus->setStyleSheet("color:green");
- lblStatus->setText(tr("Online"));
+ _ui->lblStatus->setStyleSheet("color:green");
+ _ui->lblStatus->setText(tr("Online"));
//
if (_connection != NULL)
{
diff --git a/src/client/toolbar/toolbar.h b/src/client/toolbar/toolbar.h
index 8887ca7..be42aa2 100644
--- a/src/client/toolbar/toolbar.h
+++ b/src/client/toolbar/toolbar.h
@@ -15,18 +15,23 @@
#define PVSCLIENTGUI_H_
#include <QtGui>
-#include "ui_toolbar.h"
class ServerConnection;
class VncWindow;
class ConnectWindow;
class BlankScreen;
-class Toolbar : public QWidget, private Ui_ToolbarClass
+namespace Ui{
+class Toolbar;
+}
+
+class Toolbar : public QWidget
{
-Q_OBJECT
+ Q_OBJECT
private:
+ Ui::Toolbar *_ui;
+
int _location;
int _hideTimer;
int _hideDelay;
@@ -48,7 +53,7 @@ private:
void timerEvent(QTimerEvent* event);
public:
- Toolbar(QWidget *parent = NULL);
+ explicit Toolbar(QWidget *parent = 0);
virtual ~Toolbar();
int const static POSITION_TOP_LEFT = 0;
diff --git a/src/server/mainwindow/mainwindow.h b/src/server/mainwindow/mainwindow.h
index 3ea82ca..c06f8e9 100644
--- a/src/server/mainwindow/mainwindow.h
+++ b/src/server/mainwindow/mainwindow.h
@@ -11,8 +11,7 @@ class ConnectionFrame;
class ListenServer;
class DiscoveryListener;
-namespace Ui
-{
+namespace Ui{
class MainWindow;
}
diff --git a/src/server/sessionnamewindow/sessionnamewindow.h b/src/server/sessionnamewindow/sessionnamewindow.h
index ed944c1..ee93ea2 100644
--- a/src/server/sessionnamewindow/sessionnamewindow.h
+++ b/src/server/sessionnamewindow/sessionnamewindow.h
@@ -4,8 +4,7 @@
#include <QtGui>
-namespace Ui
-{
+namespace Ui{
class SessionName;
}
@@ -14,7 +13,7 @@ class SessionNameWindow : public QDialog
Q_OBJECT
private:
- Ui::SessionName *ui;
+ Ui::SessionName *ui;
public:
SessionNameWindow(QWidget *parent = 0);
diff --git a/src/shared/settings.h b/src/shared/settings.h
index c1c45c1..2713693 100644
--- a/src/shared/settings.h
+++ b/src/shared/settings.h
@@ -1,6 +1,8 @@
#ifndef _SETTINGS_H_
#define _SETTINGS_H_
+#include <QString>
+
#define CLIENT_PORT 5194
static const QString CLIENT_PORT_STR(QString::number(CLIENT_PORT));
static const QByteArray CLIENT_PORT_ARRAY(QString::number(CLIENT_PORT).toUtf8());