diff --git a/ChangeLog b/ChangeLog index 09f29fd59f..7399f962cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,7 +19,7 @@ Enhancements: - #6973 Update synergy UI. Main window - #6977 Update synergy UI. Configure server - #6978 Update synergy UI. Settings window -- #6981 | #6987 Update synergy UI. Setup client configuration +- #6981 | #6987 | #6988 Update synergy UI. Setup client configuration - #6984 Update synergy UI. Client error messages - #6962 | #6965 Add macOS 10.13 builder =========== diff --git a/src/gui/src/ClientConnection.cpp b/src/gui/src/ClientConnection.cpp index 71207a5c44..e7e487760d 100644 --- a/src/gui/src/ClientConnection.cpp +++ b/src/gui/src/ClientConnection.cpp @@ -30,15 +30,20 @@ ClientConnection::ClientConnection(MainWindow& parent) : void ClientConnection::update(const QString& line) { - if (line.contains("failed to connect to server") && - checkMainWindow()) + if (m_checkConnection && checkMainWindow()) { - m_parent.stopSynergy(); - - QMessageBox message(&m_parent); - message.addButton(QObject::tr("Close"), QMessageBox::RejectRole); - message.setText(getMessage()); - message.exec(); + if (line.contains("failed to connect to server")) + { + m_checkConnection = false; + if (!line.contains("server refused client with our name")) + { + showMessage(); + } + } + else if (line.contains("connected to server")) + { + m_checkConnection = false; + } } } @@ -69,3 +74,16 @@ QString ClientConnection::getMessage() const return message; } + +void ClientConnection::showMessage() +{ + QMessageBox message(&m_parent); + message.addButton(QObject::tr("Close"), QMessageBox::RejectRole); + message.setText(getMessage()); + message.exec(); +} + +void ClientConnection::setCheckConnection(bool checkConnection) +{ + m_checkConnection = checkConnection; +} diff --git a/src/gui/src/ClientConnection.h b/src/gui/src/ClientConnection.h index 0d52e95a7d..1a2ec62524 100644 --- a/src/gui/src/ClientConnection.h +++ b/src/gui/src/ClientConnection.h @@ -26,14 +26,17 @@ class MainWindow; class ClientConnection { MainWindow& m_parent; + bool m_checkConnection = false; public: explicit ClientConnection(MainWindow& parent); void update(const QString& line); + void setCheckConnection(bool checkConnection); private: QString getMessage() const; bool checkMainWindow(); + void showMessage(); }; #endif // CLIENTCONNECTION_H diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp index 29568f159c..fc474c4398 100644 --- a/src/gui/src/MainWindow.cpp +++ b/src/gui/src/MainWindow.cpp @@ -310,7 +310,7 @@ void MainWindow::initConnections() { connect(m_pActionMinimize, SIGNAL(triggered()), this, SLOT(hide())); connect(m_pActionRestore, SIGNAL(triggered()), this, SLOT(showNormal())); - connect(m_pActionStartSynergy, SIGNAL(triggered()), this, SLOT(startSynergy())); + connect(m_pActionStartSynergy, SIGNAL(triggered()), this, SLOT(actionStart())); connect(m_pActionStopSynergy, SIGNAL(triggered()), this, SLOT(stopSynergy())); connect(m_pActionQuit, SIGNAL(triggered()), qApp, SLOT(quit())); connect(&m_VersionChecker, SIGNAL(updateFound(const QString&)), this, SLOT(updateFound(const QString&))); @@ -714,6 +714,12 @@ void MainWindow::startSynergy() } } +void MainWindow::actionStart() +{ + m_clientConnection.setCheckConnection(true); + startSynergy(); +} + void MainWindow::retryStart() { //This function is only called after a failed start @@ -1284,6 +1290,7 @@ void MainWindow::on_m_pActivate_triggered() void MainWindow::on_m_pButtonApply_clicked() { + m_clientConnection.setCheckConnection(true); restartSynergy(); } @@ -1425,6 +1432,6 @@ void MainWindow::on_m_pRadioGroupClient_clicked(bool) void MainWindow::on_m_pButtonConnect_clicked() { - restartSynergy(); + on_m_pButtonApply_clicked(); } diff --git a/src/gui/src/MainWindow.h b/src/gui/src/MainWindow.h index d3a444eec8..7c59a4aeb8 100644 --- a/src/gui/src/MainWindow.h +++ b/src/gui/src/MainWindow.h @@ -143,6 +143,7 @@ public slots: void appendLogError(const QString& text); void startSynergy(); void retryStart(); // If the connection failed this will retry a startSynergy + void actionStart(); protected slots: void updateLocalFingerprint(); diff --git a/src/gui/src/ServerConfig.cpp b/src/gui/src/ServerConfig.cpp index 2425b23d71..652118d32a 100644 --- a/src/gui/src/ServerConfig.cpp +++ b/src/gui/src/ServerConfig.cpp @@ -412,6 +412,23 @@ bool ServerConfig::isFull() const return isFull; } +bool ServerConfig::isScreenExists(const QString& screenName) const +{ + bool isExists = false; + + for (const auto& screen : screens()) + { + if (!screen.isNull() && + screen.name() == screenName) + { + isExists = true; + break; + } + } + + return isExists; +} + void ServerConfig::setConfigFile(const QString& configFile) { m_pAppConfig->setConfigFile(configFile); diff --git a/src/gui/src/ServerConfig.h b/src/gui/src/ServerConfig.h index e6294ad85d..ea8614a5a9 100644 --- a/src/gui/src/ServerConfig.h +++ b/src/gui/src/ServerConfig.h @@ -85,6 +85,7 @@ class ServerConfig : public BaseConfig, public GUI::Config::ConfigBase const QString& getConfigFile() const; bool getUseExternalConfig() const; bool isFull() const; + bool isScreenExists(const QString& screenName) const; protected: QSettings& settings(); diff --git a/src/gui/src/ServerConnection.cpp b/src/gui/src/ServerConnection.cpp index 30ad1d361f..878c6c9f7d 100644 --- a/src/gui/src/ServerConnection.cpp +++ b/src/gui/src/ServerConnection.cpp @@ -59,10 +59,10 @@ bool ServerConnection::checkMainWindow() void ServerConnection::addClient(const QString& clientName) { - if (!m_parent.serverConfig().isFull() && checkMainWindow()) + if (!m_parent.serverConfig().isFull() && + !m_parent.serverConfig().isScreenExists(clientName) && + checkMainWindow()) { - m_parent.stopSynergy(); - QMessageBox message(&m_parent); message.addButton(QObject::tr("Ignore"), QMessageBox::RejectRole); message.addButton(QObject::tr("Accept and configure"), QMessageBox::AcceptRole); @@ -76,8 +76,6 @@ void ServerConnection::addClient(const QString& clientName) { m_ignoredClients.append(clientName); } - - m_parent.startSynergy(); } } @@ -88,4 +86,6 @@ void ServerConnection::configureClient(const QString& clientName) ServerConfigDialog dlg(&m_parent, config); dlg.exec(); + + m_parent.restartSynergy(); }