summaryrefslogtreecommitdiffstats
path: root/src/client/connectwindow
diff options
context:
space:
mode:
authorChristian Klinger2016-05-10 17:30:37 +0200
committerChristian Klinger2016-05-10 17:30:37 +0200
commit93cd9571c534bb48af3707e1dc6c8bab28461df7 (patch)
tree6e50373bf46d27071ea100229ced7f1c244caa12 /src/client/connectwindow
parentPriorities for rooms. (diff)
downloadpvs2-93cd9571c534bb48af3707e1dc6c8bab28461df7.tar.gz
pvs2-93cd9571c534bb48af3707e1dc6c8bab28461df7.tar.xz
pvs2-93cd9571c534bb48af3707e1dc6c8bab28461df7.zip
first new version of the connect window; needs some polish though.
Diffstat (limited to 'src/client/connectwindow')
-rw-r--r--src/client/connectwindow/connectwindow.cpp31
-rw-r--r--src/client/connectwindow/connectwindow.h8
2 files changed, 37 insertions, 2 deletions
diff --git a/src/client/connectwindow/connectwindow.cpp b/src/client/connectwindow/connectwindow.cpp
index 818cbd2..716dd6e 100644
--- a/src/client/connectwindow/connectwindow.cpp
+++ b/src/client/connectwindow/connectwindow.cpp
@@ -40,7 +40,8 @@ ConnectWindow::ConnectWindow(QWidget *parent) : QWidget(parent)
// 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_advanced, SIGNAL(clicked()), this, SLOT(onBtnAdvanced()));
+
+ connect(_ui->comboBox_rooms, SIGNAL(currentIndexChanged(int)), this, SLOT(onRoomSelection(int)));
// React on discovery signal
connect(&_serverDiscovery, SIGNAL(serverDetected(QString,quint16,QByteArray,QByteArray,bool)),
@@ -145,6 +146,9 @@ void ConnectWindow::closeEvent(QCloseEvent *e)
void ConnectWindow::doShow()
{
+ /* reset to automatic connect window */
+ _ui->stackedWidget->setCurrentIndex(0);
+ _ui->comboBox_rooms->setCurrentIndex(0);
show();
showNormal();
activateWindow();
@@ -216,6 +220,21 @@ 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) {
+ if (!m.empty()) {
+ _ui->comboBox_rooms->clear();
+ foreach (Room r, m) {
+ _ui->comboBox_rooms->addItem(r.name, r.mgr);
+ }
+ /* also add a pseudo-room "manual choice" */
+ _ui->comboBox_rooms->addItem(tr("manual connection"), "manual_connection");
+ } else {
+ _ui->stackedWidget->setCurrentIndex(1);
+ }
+}
/***************************************************************************//**
* Handle click on Cancel/Hide Button.
* Just hide the window.
@@ -225,6 +244,16 @@ void ConnectWindow::onBtnHide()
this->hide();
}
+/** check if "manual_connection" is selected, then switch to manual
+ * connection page */
+void ConnectWindow::onRoomSelection(int index) {
+ qDebug() << "onRoomSelection";
+ QString sessionName = _ui->comboBox_rooms->itemData(index).toString();
+ if (sessionName == "manual_connection") {
+ qDebug() << "switch to manual connection";
+ _ui->stackedWidget->setCurrentIndex(1);
+ }
+}
/***************************************************************************//**
* @brief ConnectWindow::onServerDetected
diff --git a/src/client/connectwindow/connectwindow.h b/src/client/connectwindow/connectwindow.h
index 9daa420..bdd564a 100644
--- a/src/client/connectwindow/connectwindow.h
+++ b/src/client/connectwindow/connectwindow.h
@@ -17,10 +17,12 @@
#define PVSCONNECTWINDOW_H_
#include <QtGui>
+#include <QMap>
#include <QUdpSocket>
#include <QSslSocket>
#include "../../shared/networkmessage.h"
#include "../net/serverdiscovery.h"
+#include "../util/room.h"
namespace Ui{
class ConnectWindow;
@@ -53,8 +55,9 @@ public:
explicit ConnectWindow(QWidget *parent = NULL);
virtual ~ConnectWindow();
-
+
void connectToSession(const QByteArray sessionName, QString mgrIP);
+ void setAvailableRooms(QList<Room> m);
private:
Ui::ConnectWindow *_ui;
@@ -64,6 +67,7 @@ private:
ConnectionState _state;
QByteArray _currentSession;
QString _currentIp;
+ QString _defaultSessionName;
NetworkMessage _packet;
bool _tryReconnect;
int _timerHide;
@@ -81,6 +85,8 @@ protected slots:
void onBtnAdvanced();
void onBtnHide();
+ void onRoomSelection(int index);
+
void onConnectionStateChange(ConnectWindow::ConnectionState state);
void onConnectionClosed(QObject* connection);
void onConnectionDisconnected();