From 42020947105bde8543f4a2b5f87a6bd5b575cb50 Mon Sep 17 00:00:00 2001 From: Christian Klinger Date: Fri, 13 May 2016 10:05:55 +0200 Subject: connect/disconnect events are working (again). --- src/client/connectwindow/connectwindow.cpp | 63 ++++++++++++++++-------------- 1 file changed, 33 insertions(+), 30 deletions(-) (limited to 'src/client/connectwindow/connectwindow.cpp') diff --git a/src/client/connectwindow/connectwindow.cpp b/src/client/connectwindow/connectwindow.cpp index acb9e09..578bfa7 100644 --- a/src/client/connectwindow/connectwindow.cpp +++ b/src/client/connectwindow/connectwindow.cpp @@ -194,6 +194,34 @@ void ConnectWindow::connectToSession(const QByteArray sessionName, QString mgrIP * Slots */ + + +void ConnectWindow::DoConnect() { + qDebug() << "DoConnect()"; + // Connect (scan for session) + // qDebug() << _ui->lineEditName->text().toUtf8(); + 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); + } +} + +void ConnectWindow::DoDisconnect() { + qDebug() << "DoDisconnect()"; + _tryReconnect = false; + // Stop or disconnect + emit disconnect(); + _state = Idle; +} + + /***************************************************************************//** * Handle click on Connect/Disconnect button. * If already connected --> Stop/disconnect. @@ -210,30 +238,12 @@ void ConnectWindow::onBtnConnection() if (_serverDiscovery.isActive()) _serverDiscovery.stop(); - if (_state != Idle) - { - _tryReconnect = false; - // Stop or disconnect - emit disconnect(); - _state = Idle; - this->updateUserInterface(); - } - else - { - // Connect (scan for session) - // qDebug() << _ui->lineEditName->text().toUtf8(); - 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); - } + if (_state != Idle) { + DoDisconnect(); + } else { + DoConnect(); } + this->updateUserInterface(); } /** set the available rooms. @@ -350,10 +360,3 @@ void ConnectWindow::onConnectionDisconnected() connectToSession(_currentSession, _currentIp); } } -void ConnectWindow::onBtnAdvanced() { - if (_ui->stackedWidget->currentIndex()== 1) { - _ui->stackedWidget->setCurrentIndex(0); - } else { - _ui->stackedWidget->setCurrentIndex(1); - } -} -- cgit v1.2.3-55-g7522