diff options
author | Christian Klinger | 2016-09-29 15:40:18 +0200 |
---|---|---|
committer | Christian Klinger | 2016-09-29 15:40:18 +0200 |
commit | 3d82bfc698165bb20f3c38d42f2b77ab855c1edf (patch) | |
tree | 2c170bcdd5c89259bb0b530fa11fdfe701c99850 /src/client/connectwindow/connectwindow.cpp | |
parent | added an information dialog that displays ip and hostname. (diff) | |
download | pvs2-3d82bfc698165bb20f3c38d42f2b77ab855c1edf.tar.gz pvs2-3d82bfc698165bb20f3c38d42f2b77ab855c1edf.tar.xz pvs2-3d82bfc698165bb20f3c38d42f2b77ab855c1edf.zip |
astyle.
Diffstat (limited to 'src/client/connectwindow/connectwindow.cpp')
-rw-r--r-- | src/client/connectwindow/connectwindow.cpp | 140 |
1 files changed, 70 insertions, 70 deletions
diff --git a/src/client/connectwindow/connectwindow.cpp b/src/client/connectwindow/connectwindow.cpp index 712691e..fed4256 100644 --- a/src/client/connectwindow/connectwindow.cpp +++ b/src/client/connectwindow/connectwindow.cpp @@ -21,7 +21,7 @@ * @param parent */ ConnectWindow::ConnectWindow(QWidget *parent) : QWidget(parent) -{ +{ _ui = new Ui::ConnectWindow; _timerHide = 0; _connection = NULL; @@ -41,17 +41,17 @@ ConnectWindow::ConnectWindow(QWidget *parent) : QWidget(parent) connect(_ui->btn_connection, SIGNAL(clicked()), this, SLOT(onBtnConnection())); connect(_ui->btn_hide, SIGNAL(clicked()), this, SLOT(onBtnCancel())); - connect(_ui->comboBox_rooms, SIGNAL(currentIndexChanged(int)), this, SLOT(onRoomSelection(int))); + connect(_ui->comboBox_rooms, SIGNAL(currentIndexChanged(int)), this, SLOT(onRoomSelection(int))); // React on discovery signal - connect(&_serverDiscovery, SIGNAL(serverDetected(QString,quint16,QByteArray,QByteArray,bool)), - this, SLOT(onServerDetected(QString,quint16,QByteArray,QByteArray,bool))); + 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())); + /* 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); + /* by default don't show the manual connection box */ + _ui->box_manual->setVisible(false); this->updateUserInterface(); } @@ -59,7 +59,7 @@ ConnectWindow::ConnectWindow(QWidget *parent) : QWidget(parent) /***************************************************************************//** * @brief ConnectWindow::~ConnectWindow */ -ConnectWindow::~ConnectWindow(){} +ConnectWindow::~ConnectWindow() {} @@ -71,8 +71,7 @@ void ConnectWindow::updateUserInterface() { _ui->lineEditName->setEnabled(_state == Idle); - if (_state == Connected) - { + if (_state == Connected) { _ui->btn_connection->setEnabled(true); _ui->btn_connection->setText(tr("&Disconnect")); _ui->lblStatus->setText(tr("Connected to %1").arg(_connection->getPeerAdress())); @@ -86,8 +85,7 @@ void ConnectWindow::updateUserInterface() else _ui->btn_connection->setText(tr("&Connect")); - switch (_state) - { + switch (_state) { case Idle: _ui->lblStatus->setText(tr("Ready to connect.")); break; @@ -128,14 +126,12 @@ void ConnectWindow::updateUserInterface() */ void ConnectWindow::timerEvent(QTimerEvent* event) { - if(event->timerId() == _timerHide) - { + if (event->timerId() == _timerHide) { killTimer(_timerHide); _timerHide = 0; this->hide(); _ui->stackedWidget->setCurrentIndex(0); - } - else + } else // Unknown/Old timer id, kill it ??? PALM -> FACE killTimer(event->timerId()); } @@ -152,9 +148,9 @@ void ConnectWindow::closeEvent(QCloseEvent *e) void ConnectWindow::doShow() { - /* reset to automatic connect window */ - _ui->stackedWidget->setCurrentIndex(0); - _ui->comboBox_rooms->setCurrentIndex(0); + /* reset to automatic connect window */ + _ui->stackedWidget->setCurrentIndex(0); + _ui->comboBox_rooms->setCurrentIndex(0); show(); showNormal(); activateWindow(); @@ -196,29 +192,31 @@ void ConnectWindow::connectToSession(const QByteArray sessionName, QString mgrIP -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::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; +void ConnectWindow::DoDisconnect() +{ + qDebug() << "DoDisconnect()"; + _tryReconnect = false; + // Stop or disconnect + emit disconnect(); + _state = Idle; } @@ -229,7 +227,7 @@ void ConnectWindow::DoDisconnect() { */ void ConnectWindow::onBtnConnection() { - if (_timerHide){ + if (_timerHide) { killTimer(_timerHide); _timerHide = 0; _ui->stackedWidget->setCurrentIndex(0); @@ -239,23 +237,24 @@ void ConnectWindow::onBtnConnection() _serverDiscovery.stop(); if (_state != Idle) { - DoDisconnect(); + DoDisconnect(); } else { - DoConnect(); + DoConnect(); } - this->updateUserInterface(); + this->updateUserInterface(); } /** set the available rooms. * If the list of rooms is empty, switches automatically to the "manual * connection" page */ -void ConnectWindow::setAvailableRooms(QList<Room> m) { - _ui->comboBox_rooms->clear(); - foreach (Room r, m) { - _ui->comboBox_rooms->addItem(tr("Room ") + r.name, r.mgr); - } - /* also add a pseudo-room "manual choice" */ - _ui->comboBox_rooms->addItem(tr("Session Name..."), "manual_connection"); +void ConnectWindow::setAvailableRooms(QList<Room> m) +{ + _ui->comboBox_rooms->clear(); + foreach (Room r, m) { + _ui->comboBox_rooms->addItem(tr("Room ") + r.name, r.mgr); + } + /* also add a pseudo-room "manual choice" */ + _ui->comboBox_rooms->addItem(tr("Session Name..."), "manual_connection"); } /***************************************************************************//** * Handle click on Cancel/Hide Button. @@ -268,17 +267,18 @@ void ConnectWindow::onBtnCancel() /** check if "manual_connection" is selected, then switch to manual * connection page */ -void ConnectWindow::onRoomSelection(int index) { - QString sessionName = _ui->comboBox_rooms->itemData(index).toString(); - if (sessionName == "manual_connection") { - qDebug() << "switch to manual connection"; - _ui->box_manual->setVisible(true); - //this->setSize(QSize(300,200)); - this->resize(300, 200); - } else { - _ui->box_manual->setVisible(false); - this->resize(300, 140); - } +void ConnectWindow::onRoomSelection(int index) +{ + QString sessionName = _ui->comboBox_rooms->itemData(index).toString(); + if (sessionName == "manual_connection") { + qDebug() << "switch to manual connection"; + _ui->box_manual->setVisible(true); + //this->setSize(QSize(300,200)); + this->resize(300, 200); + } else { + _ui->box_manual->setVisible(false); + this->resize(300, 140); + } } /***************************************************************************//** @@ -313,8 +313,7 @@ void ConnectWindow::onConnectionStateChange(ConnectWindow::ConnectionState state if (reset) { _state = Scanning; } - if (state == Connected) - { + if (state == Connected) { QObject::disconnect(_connection, SIGNAL(stateChange(ConnectWindow::ConnectionState)), this, SLOT(onConnectionStateChange(ConnectWindow::ConnectionState))); QObject::disconnect(_connection, SIGNAL(destroyed(QObject*)), this, SLOT(onConnectionClosed(QObject*))); emit connected(_connection); @@ -326,11 +325,12 @@ 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"; - } +void ConnectWindow::onComboBox_keyPressed(QKeyEvent* e) +{ + qDebug() << "key released"; + if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return ) { + qDebug() << "enter pressed"; + } } |