From 3d82bfc698165bb20f3c38d42f2b77ab855c1edf Mon Sep 17 00:00:00 2001 From: Christian Klinger Date: Thu, 29 Sep 2016 15:40:18 +0200 Subject: astyle. --- src/client/connectwindow/connectwindow.cpp | 140 ++++++++++++++--------------- src/client/connectwindow/connectwindow.h | 23 ++--- 2 files changed, 82 insertions(+), 81 deletions(-) (limited to 'src/client/connectwindow') 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 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 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"; + } } diff --git a/src/client/connectwindow/connectwindow.h b/src/client/connectwindow/connectwindow.h index 3eed6e0..aa89094 100644 --- a/src/client/connectwindow/connectwindow.h +++ b/src/client/connectwindow/connectwindow.h @@ -24,7 +24,8 @@ #include "../net/serverdiscovery.h" #include "../util/room.h" -namespace Ui{ +namespace Ui +{ class ConnectWindow; } class ServerConnection; @@ -38,7 +39,7 @@ class ServerConnection; */ class ConnectWindow : public QWidget { -Q_OBJECT + Q_OBJECT public: enum ConnectionState { @@ -55,9 +56,9 @@ public: explicit ConnectWindow(QWidget *parent = NULL); virtual ~ConnectWindow(); - + void connectToSession(const QByteArray sessionName, QString mgrIP); - void setAvailableRooms(QList m); + void setAvailableRooms(QList m); private: Ui::ConnectWindow *_ui; @@ -67,7 +68,7 @@ private: ConnectionState _state; QByteArray _currentSession; QString _currentIp; - QString _defaultSessionName; + QString _defaultSessionName; NetworkMessage _packet; bool _tryReconnect; int _timerHide; @@ -84,7 +85,7 @@ protected slots: void onBtnConnection(); void onBtnCancel(); - void onRoomSelection(int index); + void onRoomSelection(int index); void onConnectionStateChange(ConnectWindow::ConnectionState state); void onConnectionClosed(QObject* connection); @@ -92,13 +93,13 @@ 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); + void onComboBox_keyPressed(QKeyEvent* e); public slots: - /** actually connects the connection **/ - void DoConnect(); - /** actually disconnects the connection **/ - void DoDisconnect(); + /** actually connects the connection **/ + void DoConnect(); + /** actually disconnects the connection **/ + void DoDisconnect(); signals: void disconnect(); void connected(ServerConnection* connection); -- cgit v1.2.3-55-g7522