From 3fabb2c294d58cf73fd1a0390f01f0efcf9d0c8c Mon Sep 17 00:00:00 2001 From: Serhii Hadzhilov Date: Thu, 15 Apr 2021 17:59:03 +0300 Subject: [PATCH] SYNERGY-799 Don't select type by default --- src/gui/src/AppConfig.cpp | 2 +- src/gui/src/MainWindow.cpp | 64 +++++++++++++++++++++-------------- src/gui/src/MainWindow.h | 6 ++-- src/gui/src/MainWindowBase.ui | 3 ++ 4 files changed, 47 insertions(+), 28 deletions(-) diff --git a/src/gui/src/AppConfig.cpp b/src/gui/src/AppConfig.cpp index e0f4fd3a3c..61eecda178 100644 --- a/src/gui/src/AppConfig.cpp +++ b/src/gui/src/AppConfig.cpp @@ -237,7 +237,7 @@ void AppConfig::loadSettings() m_UseExternalConfig = loadSetting(kUseExternalConfig, false).toBool(); m_ConfigFile = loadSetting(kConfigFile, QDir::homePath() + "/" + synergyConfigName).toString(); m_UseInternalConfig = loadSetting(kUseInternalConfig, false).toBool(); - m_ClientGroupChecked = loadSetting(kGroupClientCheck, true).toBool(); + m_ClientGroupChecked = loadSetting(kGroupClientCheck, false).toBool(); m_ServerHostname = loadSetting(kServerHostname).toString(); //only change the serial key if the settings being loaded contains a key diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp index d9bbbfb6f1..b3b8ad2ce6 100644 --- a/src/gui/src/MainWindow.cpp +++ b/src/gui/src/MainWindow.cpp @@ -298,10 +298,8 @@ void MainWindow::createMenuBar() void MainWindow::loadSettings() { - on_m_pRadioGroupServer_clicked(appConfig().getServerGroupChecked()); - on_m_pRadioGroupClient_clicked(appConfig().getClientGroupChecked()); - m_pRadioGroupServer->setChecked(appConfig().getServerGroupChecked()); - m_pRadioGroupClient->setChecked(appConfig().getClientGroupChecked()); + enableServer(appConfig().getServerGroupChecked()); + enableClient(appConfig().getClientGroupChecked()); m_pLineEditHostname->setText(appConfig().getServerHostname()); } @@ -1365,18 +1363,38 @@ void MainWindow::updateScreenName() serverConfig().updateServerName(); } -void MainWindow::on_m_pRadioGroupServer_clicked(bool on) +void MainWindow::enableServer(bool enable) { - m_pRadioGroupServer->setChecked(true); - if (on) + m_pRadioGroupServer->setChecked(enable); + + if (enable) { - //show server controls m_pButtonConfigureServer->show(); m_pLabelServerState->show(); updateLocalFingerprint(); + m_pButtonToggleStart->setEnabled(enable); + } + else + { + m_pLabelFingerprint->hide(); + m_pButtonConfigureServer->hide(); + m_pLabelServerState->hide(); + } +} - //hide client controls - m_pRadioGroupClient->setChecked(false); +void MainWindow::enableClient(bool enable) +{ + m_pRadioGroupClient->setChecked(enable); + + if (enable) + { + m_pLabelServerName->show(); + m_pLineEditHostname->show(); + m_pButtonConnect->show(); + m_pButtonToggleStart->setEnabled(enable); + } + else + { m_pLabelClientState->hide(); m_pLabelServerName->hide(); m_pLineEditHostname->hide(); @@ -1384,25 +1402,21 @@ void MainWindow::on_m_pRadioGroupServer_clicked(bool on) } } -void MainWindow::on_m_pRadioGroupClient_clicked(bool on) -{ - m_pRadioGroupClient->setChecked(true); - if (on) - { - //show client controls - m_pLabelServerName->show(); - m_pLineEditHostname->show(); - m_pButtonConnect->show(); - //hide server controls - m_pRadioGroupServer->setChecked(false); - m_pLabelFingerprint->hide(); - m_pButtonConfigureServer->hide(); - m_pLabelServerState->hide(); - } +void MainWindow::on_m_pRadioGroupServer_clicked(bool) +{ + enableServer(true); + enableClient(false); +} + +void MainWindow::on_m_pRadioGroupClient_clicked(bool) +{ + enableClient(true); + enableServer(false); } void MainWindow::on_m_pButtonConnect_clicked() { restartSynergy(); } + diff --git a/src/gui/src/MainWindow.h b/src/gui/src/MainWindow.h index dec656ab26..55397f0b75 100644 --- a/src/gui/src/MainWindow.h +++ b/src/gui/src/MainWindow.h @@ -143,8 +143,8 @@ public slots: protected slots: void updateLocalFingerprint(); void updateScreenName(); - void on_m_pRadioGroupServer_clicked(bool on); - void on_m_pRadioGroupClient_clicked(bool on); + void on_m_pRadioGroupServer_clicked(bool); + void on_m_pRadioGroupClient_clicked(bool); void on_m_pButtonConfigureServer_clicked(); bool on_m_pActionSave_triggered(); void on_m_pActionAbout_triggered(); @@ -187,6 +187,8 @@ public slots: void stopDesktop(); void changeEvent(QEvent* event); void retranslateMenuBar(); + void enableServer(bool enable); + void enableClient(bool enable); #if defined(Q_OS_WIN) bool isServiceRunning(QString name); diff --git a/src/gui/src/MainWindowBase.ui b/src/gui/src/MainWindowBase.ui index f8aebf3a03..79d3604e15 100644 --- a/src/gui/src/MainWindowBase.ui +++ b/src/gui/src/MainWindowBase.ui @@ -866,6 +866,9 @@ + + false + &Start