From 6e0ae9c6a9f83bde0ee58a537fdb376878e3e46d Mon Sep 17 00:00:00 2001
From: Christian Klinger
Date: Thu, 12 May 2016 14:13:01 +0200
Subject: polished the connect window.
---
gui/client/connect.ui | 135 ++++++++++-------------------
src/client/connectwindow/connectwindow.cpp | 37 +++++++-
src/client/connectwindow/connectwindow.h | 2 +
3 files changed, 83 insertions(+), 91 deletions(-)
diff --git a/gui/client/connect.ui b/gui/client/connect.ui
index b5c8340..39649e2 100644
--- a/gui/client/connect.ui
+++ b/gui/client/connect.ui
@@ -10,7 +10,7 @@
0
0
512
- 150
+ 233
@@ -32,98 +32,59 @@
0
-
+
0
- -
-
-
- Auto-Connect is available.
-
-
-
- -
-
-
- Room:
-
-
-
- -
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
-
-
-
-
- -
-
-
- Manually connect with session name
-
+
-
+
+
+ Connection
+
+
+
-
+
+
+ Connect to
+
+
+
+ -
+
+
+
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
- -
-
-
- -
-
-
- Session Name
+
-
+
+
+
+ 0
+ 0
+
+
+ Manual Connection
+
+
+
-
+
+
+ Session Name
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+
diff --git a/src/client/connectwindow/connectwindow.cpp b/src/client/connectwindow/connectwindow.cpp
index 716dd6e..9bd8d12 100644
--- a/src/client/connectwindow/connectwindow.cpp
+++ b/src/client/connectwindow/connectwindow.cpp
@@ -47,6 +47,12 @@ ConnectWindow::ConnectWindow(QWidget *parent) : QWidget(parent)
connect(&_serverDiscovery, SIGNAL(serverDetected(QString,quint16,QByteArray,QByteArray,bool)),
this, SLOT(onServerDetected(QString,quint16,QByteArray,QByteArray,bool)));
+ /* finally the most requested feature: connect on press of the enter key */
+ connect(_ui->lineEditName, SIGNAL(returnPressed()),_ui->btn_connection, SIGNAL(clicked()));
+
+ /* by default don't show the manual connection box */
+ _ui->box_manual->setVisible(false);
+
this->updateUserInterface();
}
@@ -216,7 +222,17 @@ void ConnectWindow::onBtnConnection()
{
// Connect (scan for session)
// qDebug() << _ui->lineEditName->text().toUtf8();
- connectToSession(_ui->lineEditName->text().toUtf8(), NULL);
+ int index = _ui->comboBox_rooms->currentIndex();
+ QString selectedMgrIP =_ui->comboBox_rooms->itemData(index).toString();
+
+ if (selectedMgrIP == "manual_connection") {
+ qDebug() << "connect to sessionName by manual connection";
+ QByteArray sessionName = _ui->lineEditName->text().toUtf8();
+ connectToSession(sessionName, "");
+ } else {
+ qDebug() << "connect to mgrIP (through room selection) " << selectedMgrIP;
+ connectToSession("", selectedMgrIP);
+ }
}
}
@@ -227,10 +243,10 @@ void ConnectWindow::setAvailableRooms(QList m) {
if (!m.empty()) {
_ui->comboBox_rooms->clear();
foreach (Room r, m) {
- _ui->comboBox_rooms->addItem(r.name, r.mgr);
+ _ui->comboBox_rooms->addItem(tr("Room ") + r.name, r.mgr);
}
/* also add a pseudo-room "manual choice" */
- _ui->comboBox_rooms->addItem(tr("manual connection"), "manual_connection");
+ _ui->comboBox_rooms->addItem(tr("Session Name..."), "manual_connection");
} else {
_ui->stackedWidget->setCurrentIndex(1);
}
@@ -251,7 +267,12 @@ void ConnectWindow::onRoomSelection(int index) {
QString sessionName = _ui->comboBox_rooms->itemData(index).toString();
if (sessionName == "manual_connection") {
qDebug() << "switch to manual connection";
- _ui->stackedWidget->setCurrentIndex(1);
+ _ui->box_manual->setVisible(true);
+ //this->setSize(QSize(300,200));
+ this->resize(300, 200);
+ } else {
+ _ui->box_manual->setVisible(false);
+ this->resize(300, 140);
}
}
@@ -300,6 +321,14 @@ void ConnectWindow::onConnectionStateChange(ConnectWindow::ConnectionState state
}
}
+void ConnectWindow::onComboBox_keyPressed(QKeyEvent* e) {
+ qDebug() << "key released";
+ if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return ) {
+ qDebug() << "enter pressed";
+ }
+
+}
+
/***************************************************************************//**
* If connection is closed set _connection = NULL.
* @param connection
diff --git a/src/client/connectwindow/connectwindow.h b/src/client/connectwindow/connectwindow.h
index bdd564a..a94f6d9 100644
--- a/src/client/connectwindow/connectwindow.h
+++ b/src/client/connectwindow/connectwindow.h
@@ -93,6 +93,8 @@ protected slots:
// void onUdpReadyRead();
void onServerDetected(const QString& host, const quint16 port, const QByteArray& sessionName, const QByteArray& certHash, bool autoConnect);
+ void onComboBox_keyPressed(QKeyEvent* e);
+
signals:
void disconnect();
void connected(ServerConnection* connection);
--
cgit v1.2.3-55-g7522