Merge pull request #6988 from symless/SYNERGY-694-Issues-with-client-messages

SYNERGY-694 Issues with client messages
This commit is contained in:
Andrey Batyiev 2021-04-28 16:49:52 +03:00 committed by GitHub
commit a5d0bb12b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 63 additions and 16 deletions

View file

@ -19,7 +19,7 @@ Enhancements:
- #6973 Update synergy UI. Main window - #6973 Update synergy UI. Main window
- #6977 Update synergy UI. Configure server - #6977 Update synergy UI. Configure server
- #6978 Update synergy UI. Settings window - #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 - #6984 Update synergy UI. Client error messages
- #6962 | #6965 Add macOS 10.13 builder - #6962 | #6965 Add macOS 10.13 builder
=========== ===========

View file

@ -30,15 +30,20 @@ ClientConnection::ClientConnection(MainWindow& parent) :
void ClientConnection::update(const QString& line) void ClientConnection::update(const QString& line)
{ {
if (line.contains("failed to connect to server") && if (m_checkConnection && checkMainWindow())
checkMainWindow())
{ {
m_parent.stopSynergy(); if (line.contains("failed to connect to server"))
{
QMessageBox message(&m_parent); m_checkConnection = false;
message.addButton(QObject::tr("Close"), QMessageBox::RejectRole); if (!line.contains("server refused client with our name"))
message.setText(getMessage()); {
message.exec(); showMessage();
}
}
else if (line.contains("connected to server"))
{
m_checkConnection = false;
}
} }
} }
@ -69,3 +74,16 @@ QString ClientConnection::getMessage() const
return message; 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;
}

View file

@ -26,14 +26,17 @@ class MainWindow;
class ClientConnection class ClientConnection
{ {
MainWindow& m_parent; MainWindow& m_parent;
bool m_checkConnection = false;
public: public:
explicit ClientConnection(MainWindow& parent); explicit ClientConnection(MainWindow& parent);
void update(const QString& line); void update(const QString& line);
void setCheckConnection(bool checkConnection);
private: private:
QString getMessage() const; QString getMessage() const;
bool checkMainWindow(); bool checkMainWindow();
void showMessage();
}; };
#endif // CLIENTCONNECTION_H #endif // CLIENTCONNECTION_H

View file

@ -310,7 +310,7 @@ void MainWindow::initConnections()
{ {
connect(m_pActionMinimize, SIGNAL(triggered()), this, SLOT(hide())); connect(m_pActionMinimize, SIGNAL(triggered()), this, SLOT(hide()));
connect(m_pActionRestore, SIGNAL(triggered()), this, SLOT(showNormal())); 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_pActionStopSynergy, SIGNAL(triggered()), this, SLOT(stopSynergy()));
connect(m_pActionQuit, SIGNAL(triggered()), qApp, SLOT(quit())); connect(m_pActionQuit, SIGNAL(triggered()), qApp, SLOT(quit()));
connect(&m_VersionChecker, SIGNAL(updateFound(const QString&)), this, SLOT(updateFound(const QString&))); 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() void MainWindow::retryStart()
{ {
//This function is only called after a failed start //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() void MainWindow::on_m_pButtonApply_clicked()
{ {
m_clientConnection.setCheckConnection(true);
restartSynergy(); restartSynergy();
} }
@ -1425,6 +1432,6 @@ void MainWindow::on_m_pRadioGroupClient_clicked(bool)
void MainWindow::on_m_pButtonConnect_clicked() void MainWindow::on_m_pButtonConnect_clicked()
{ {
restartSynergy(); on_m_pButtonApply_clicked();
} }

View file

@ -143,6 +143,7 @@ public slots:
void appendLogError(const QString& text); void appendLogError(const QString& text);
void startSynergy(); void startSynergy();
void retryStart(); // If the connection failed this will retry a startSynergy void retryStart(); // If the connection failed this will retry a startSynergy
void actionStart();
protected slots: protected slots:
void updateLocalFingerprint(); void updateLocalFingerprint();

View file

@ -412,6 +412,23 @@ bool ServerConfig::isFull() const
return isFull; 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) void ServerConfig::setConfigFile(const QString& configFile)
{ {
m_pAppConfig->setConfigFile(configFile); m_pAppConfig->setConfigFile(configFile);

View file

@ -85,6 +85,7 @@ class ServerConfig : public BaseConfig, public GUI::Config::ConfigBase
const QString& getConfigFile() const; const QString& getConfigFile() const;
bool getUseExternalConfig() const; bool getUseExternalConfig() const;
bool isFull() const; bool isFull() const;
bool isScreenExists(const QString& screenName) const;
protected: protected:
QSettings& settings(); QSettings& settings();

View file

@ -59,10 +59,10 @@ bool ServerConnection::checkMainWindow()
void ServerConnection::addClient(const QString& clientName) 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); QMessageBox message(&m_parent);
message.addButton(QObject::tr("Ignore"), QMessageBox::RejectRole); message.addButton(QObject::tr("Ignore"), QMessageBox::RejectRole);
message.addButton(QObject::tr("Accept and configure"), QMessageBox::AcceptRole); message.addButton(QObject::tr("Accept and configure"), QMessageBox::AcceptRole);
@ -76,8 +76,6 @@ void ServerConnection::addClient(const QString& clientName)
{ {
m_ignoredClients.append(clientName); m_ignoredClients.append(clientName);
} }
m_parent.startSynergy();
} }
} }
@ -88,4 +86,6 @@ void ServerConnection::configureClient(const QString& clientName)
ServerConfigDialog dlg(&m_parent, config); ServerConfigDialog dlg(&m_parent, config);
dlg.exec(); dlg.exec();
m_parent.restartSynergy();
} }