SYNERGY-694 Issues with clients messages

This commit is contained in:
Serhii Hadzhilov 2021-04-28 15:34:04 +03:00
parent 7c365c4dac
commit 7fa08c51e3
4 changed files with 40 additions and 10 deletions

View file

@ -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;
}

View file

@ -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

View file

@ -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,7 @@ void MainWindow::on_m_pRadioGroupClient_clicked(bool)
void MainWindow::on_m_pButtonConnect_clicked()
{
restartSynergy();
m_clientConnection.setCheckConnection(true);
restartSynergy();
}

View file

@ -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();