summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Klinger2016-05-13 10:05:55 +0200
committerChristian Klinger2016-05-13 10:05:55 +0200
commit42020947105bde8543f4a2b5f87a6bd5b575cb50 (patch)
treeb100a4afecbde6fdbcc32c14d8544539349b9c81
parentrename hide->cancel (diff)
downloadpvs2-42020947105bde8543f4a2b5f87a6bd5b575cb50.tar.gz
pvs2-42020947105bde8543f4a2b5f87a6bd5b575cb50.tar.xz
pvs2-42020947105bde8543f4a2b5f87a6bd5b575cb50.zip
connect/disconnect events are working (again).
-rw-r--r--src/client/connectwindow/connectwindow.cpp63
-rw-r--r--src/client/connectwindow/connectwindow.h6
-rw-r--r--src/client/toolbar/toolbar.cpp14
3 files changed, 46 insertions, 37 deletions
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);
- }
-}
diff --git a/src/client/connectwindow/connectwindow.h b/src/client/connectwindow/connectwindow.h
index aa6dccd..3eed6e0 100644
--- a/src/client/connectwindow/connectwindow.h
+++ b/src/client/connectwindow/connectwindow.h
@@ -82,7 +82,6 @@ protected:
protected slots:
void doShow();
void onBtnConnection();
- void onBtnAdvanced();
void onBtnCancel();
void onRoomSelection(int index);
@@ -95,6 +94,11 @@ protected slots:
void onComboBox_keyPressed(QKeyEvent* e);
+public slots:
+ /** actually connects the connection **/
+ void DoConnect();
+ /** actually disconnects the connection **/
+ void DoDisconnect();
signals:
void disconnect();
void connected(ServerConnection* connection);
diff --git a/src/client/toolbar/toolbar.cpp b/src/client/toolbar/toolbar.cpp
index 4c74a4a..f938494 100644
--- a/src/client/toolbar/toolbar.cpp
+++ b/src/client/toolbar/toolbar.cpp
@@ -122,6 +122,7 @@ void Toolbar::init()
// Connect the signals
connect(_menu, SIGNAL(aboutToHide()), this, SLOT(hideBar()));
connect(_acnConnect, SIGNAL(triggered()), _connectWindow, SLOT(doShow()));
+ connect(_acnDisconnect, SIGNAL(triggered()), _connectWindow, SLOT(DoDisconnect()));
connect(_acnAbout, SIGNAL(triggered()), this, SLOT(showAboutDialog()));
connect(_acnQuit, SIGNAL(triggered()), this, SLOT(exit()));
@@ -302,13 +303,15 @@ void Toolbar::onVncServerIsRunning(int port)
* A slot for the onDisconnected signal of the ConnectWindow. This slot will
* change the UI according to the state fo the connection.
*/
-void Toolbar::onDisconnected()
-{
+void Toolbar::onDisconnected() {
if (_connection != NULL)
_connection->blockSignals(true);
_connection = NULL;
_ui->lblStatus->setStyleSheet("color:red");
_ui->lblStatus->setText(tr("Offline"));
+
+ this->_acnConnect->setEnabled(true);
+ this->_acnDisconnect->setEnabled(false);
}
/***************************************************************************//**
@@ -319,8 +322,10 @@ void Toolbar::onDisconnected()
*/
void Toolbar::onConnected(ServerConnection* connection)
{
-
this->_acnConnect->setEnabled(false);
+ this->_acnDisconnect->setEnabled(true);
+
+
_ui->lblStatus->setStyleSheet("color:green");
_ui->lblStatus->setText(tr("Online"));
//
@@ -345,9 +350,6 @@ void Toolbar::onDoDisconnect()
{
if (_connection != NULL)
_connection->disconnectFromServer();
-
- this->_acnConnect->setEnabled(true);
- this->_acnDisconnect->setEnabled(false);
}
/***************************************************************************//**