summaryrefslogtreecommitdiffstats
path: root/src/client/connectwindow/connectwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/connectwindow/connectwindow.cpp')
-rw-r--r--src/client/connectwindow/connectwindow.cpp36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/client/connectwindow/connectwindow.cpp b/src/client/connectwindow/connectwindow.cpp
index 7674cc2..0bc6835 100644
--- a/src/client/connectwindow/connectwindow.cpp
+++ b/src/client/connectwindow/connectwindow.cpp
@@ -7,16 +7,21 @@
#include <QNetworkInterface>
#include "../../shared/settings.h"
-#include "../../shared/network.h"
#include "../../shared/util.h"
#include "../net/serverconnection.h"
#include "../clientapp/clientapp.h"
#include "connectwindow.h"
-#include "ui_connect.h"
+#include "ui_connectwindow.h"
+
+#include <QCloseEvent>
#define UDPBUFSIZ 9000
#define SALT_LEN 18
+namespace Ui {
+ class ConnectWindow;
+}
+
/**
* Initialize Connection Window.
* @param parent
@@ -39,17 +44,16 @@ ConnectWindow::ConnectWindow(QWidget *parent) : QWidget(parent)
_ui->stackedWidget->setCurrentIndex(0);
// Set actions of buttons
- connect(_ui->btn_connection, SIGNAL(clicked()), this, SLOT(onBtnConnection()));
- connect(_ui->btn_hide, SIGNAL(clicked()), this, SLOT(onBtnHide()));
+ connect(_ui->btn_connection, &QPushButton::clicked, this, &ConnectWindow::onBtnConnection);
+ connect(_ui->btn_hide, &QPushButton::clicked, this, &ConnectWindow::onBtnHide);
- connect(_ui->comboBox_rooms, SIGNAL(currentIndexChanged(int)), this, SLOT(onRoomSelection(int)));
+ connect(_ui->comboBox_rooms, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ConnectWindow::onRoomSelection);
// React on discovery signal
- connect(&_serverDiscovery, SIGNAL(serverDetected(QString, quint16, QByteArray, QByteArray, bool)),
- this, SLOT(onServerDetected(QString, quint16, QByteArray, QByteArray, bool)));
+ connect(&_serverDiscovery, &ServerDiscovery::serverDetected, this, &ConnectWindow::onServerDetected);
/* finally the most requested feature: connect on press of the enter key */
- connect(_ui->lineEditName, SIGNAL(returnPressed()), _ui->btn_connection, SIGNAL(clicked()));
+ connect(_ui->lineEditName, &QLineEdit::returnPressed, this, &ConnectWindow::onBtnConnection);
/* by default don't show the manual connection box */
_ui->box_manual->setVisible(false);
@@ -60,7 +64,7 @@ ConnectWindow::ConnectWindow(QWidget *parent) : QWidget(parent)
/**
* @brief ConnectWindow::~ConnectWindow
*/
-ConnectWindow::~ConnectWindow() {}
+ConnectWindow::~ConnectWindow() = default;
@@ -177,7 +181,7 @@ void ConnectWindow::showEvent(QShowEvent* /* event */ )
* if not --> connect to given sessionName.
* @param sessionName
*/
-void ConnectWindow::connectToSession(const QByteArray sessionName, QString mgrIP)
+void ConnectWindow::connectToSession(const QByteArray& sessionName, const QString &mgrIP)
{
if (_state != Idle)
return;
@@ -250,7 +254,7 @@ void ConnectWindow::onBtnConnection()
/** set the available rooms.
* If the list of rooms is empty, switches automatically to the "manual
* connection" page */
-void ConnectWindow::setAvailableRooms(QList<Room> m)
+void ConnectWindow::setAvailableRooms(const QList<Room>& m)
{
_ui->comboBox_rooms->clear();
foreach (Room r, m) {
@@ -294,9 +298,9 @@ void ConnectWindow::onRoomSelection(int index)
void ConnectWindow::onServerDetected(const QString& host, const quint16 port, const QByteArray& sessionName, const QByteArray& certHash, bool autoConnect)
{
_pendingConnection = new ServerConnection(host, port, sessionName, certHash, autoConnect);
- connect(_pendingConnection, SIGNAL(stateChange(ConnectWindow::ConnectionState)), this, SLOT(onConnectionStateChange(ConnectWindow::ConnectionState)));
- connect(_pendingConnection, SIGNAL(destroyed(QObject*)), this, SLOT(onConnectionClosed(QObject*)));
- connect(_pendingConnection, SIGNAL(disconnected(ServerConnection*)), this, SLOT(onConnectionDisconnected(ServerConnection*)));
+ connect(_pendingConnection, &ServerConnection::stateChange, this, &ConnectWindow::onConnectionStateChange);
+ connect(_pendingConnection, &ServerConnection::destroyed, this, &ConnectWindow::onConnectionClosed);
+ connect(_pendingConnection, &ServerConnection::disconnected, this, &ConnectWindow::onConnectionDisconnected);
}
@@ -317,8 +321,8 @@ void ConnectWindow::onConnectionStateChange(ConnectWindow::ConnectionState state
_state = Scanning;
}
if (state == Connected) {
- QObject::disconnect(_pendingConnection, SIGNAL(stateChange(ConnectWindow::ConnectionState)), this, SLOT(onConnectionStateChange(ConnectWindow::ConnectionState)));
- QObject::disconnect(_pendingConnection, SIGNAL(destroyed(QObject*)), this, SLOT(onConnectionClosed(QObject*)));
+ QObject::disconnect(_pendingConnection, &ServerConnection::stateChange, this, &ConnectWindow::onConnectionStateChange);
+ QObject::disconnect(_pendingConnection, &ServerConnection::destroyed, this, &ConnectWindow::onConnectionClosed);
emit connected(_pendingConnection);
_pendingConnection = nullptr;
_timerHide = startTimer(2000);