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. --- src/client/connectwindow/connectwindow.cpp | 37 ++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'src/client/connectwindow/connectwindow.cpp') 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 -- cgit v1.2.3-55-g7522