From a2009d0aa022c6c0efb9da5d1b525f92e7d08e84 Mon Sep 17 00:00:00 2001 From: Jamie Newbon Date: Fri, 28 Feb 2020 11:34:28 +0000 Subject: [PATCH] #6538 Added event to live swap configs as soon as the scope is changed in settings --- src/gui/src/SettingsDialog.cpp | 120 ++++++++++++++++++--------------- src/gui/src/SettingsDialog.h | 7 ++ 2 files changed, 73 insertions(+), 54 deletions(-) diff --git a/src/gui/src/SettingsDialog.cpp b/src/gui/src/SettingsDialog.cpp index b33bbdb01..f1546687c 100644 --- a/src/gui/src/SettingsDialog.cpp +++ b/src/gui/src/SettingsDialog.cpp @@ -49,60 +49,7 @@ SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) : m_Locale.fillLanguageComboBox(m_pComboLanguage); - m_pLineEditScreenName->setText(appConfig().screenName()); - m_pSpinBoxPort->setValue(appConfig().port()); - m_pLineEditInterface->setText(appConfig().networkInterface()); - m_pComboLogLevel->setCurrentIndex(appConfig().logLevel()); - m_pCheckBoxLogToFile->setChecked(appConfig().logToFile()); - m_pLineEditLogFilename->setText(appConfig().logFilename()); - setIndexFromItemData(m_pComboLanguage, appConfig().language()); - m_pCheckBoxAutoHide->setChecked(appConfig().getAutoHide()); - m_pCheckBoxMinimizeToTray->setChecked(appConfig().getMinimizeToTray()); - m_pCheckBoxEnableCrypto->setChecked(m_appConfig.getCryptoEnabled()); - - if (m_appConfig.isSystemScoped()) { - m_pRadioSystemScope->setChecked(true); - } - else { - m_pRadioUserScope->setChecked(true); - } - -#if defined(Q_OS_WIN) - m_pBonjourWindows = new BonjourWindows(this, m_pMainWindow, m_appConfig); - if (m_pBonjourWindows->isRunning()) { - allowAutoConfig(); - } - - m_pComboElevate->setCurrentIndex(static_cast(appConfig().elevateMode())); - -#else - // elevate checkbox is only useful on ms windows. - m_pLabelElevate->hide(); - m_pComboElevate->hide(); - - // for linux and mac, allow auto config by default - allowAutoConfig(); -#endif - - m_pCheckBoxEnableCrypto->setChecked(m_appConfig.getCryptoEnabled()); - -#ifdef SYNERGY_ENTERPRISE - - m_pCheckBoxEnableCrypto->setEnabled(true); - m_pLabelProUpgrade->hide(); - - m_pCheckBoxAutoConfig->hide(); - m_pLabelInstallBonjour->hide(); - -#else - - bool isPro = m_appConfig.edition() == kPro; - m_pCheckBoxEnableCrypto->setEnabled(isPro); - m_pLabelProUpgrade->setVisible(!isPro); - - m_pCheckBoxAutoConfig->setChecked(appConfig().autoConfig()); - -#endif + loadFromConfig(); } void SettingsDialog::accept() @@ -158,6 +105,65 @@ void SettingsDialog::changeEvent(QEvent* event) } } +void SettingsDialog::loadFromConfig() { + + m_pLineEditScreenName->setText(appConfig().screenName()); + m_pSpinBoxPort->setValue(appConfig().port()); + m_pLineEditInterface->setText(appConfig().networkInterface()); + m_pComboLogLevel->setCurrentIndex(appConfig().logLevel()); + m_pCheckBoxLogToFile->setChecked(appConfig().logToFile()); + m_pLineEditLogFilename->setText(appConfig().logFilename()); + setIndexFromItemData(m_pComboLanguage, appConfig().language()); + m_pCheckBoxAutoHide->setChecked(appConfig().getAutoHide()); + m_pCheckBoxMinimizeToTray->setChecked(appConfig().getMinimizeToTray()); + m_pCheckBoxEnableCrypto->setChecked(m_appConfig.getCryptoEnabled()); + + if (m_appConfig.isSystemScoped()) { + m_pRadioSystemScope->setChecked(true); + } + else { + m_pRadioUserScope->setChecked(true); + } + +#if defined(Q_OS_WIN) + m_pBonjourWindows = new BonjourWindows(this, m_pMainWindow, m_appConfig); + if (m_pBonjourWindows->isRunning()) { + allowAutoConfig(); + } + + m_pComboElevate->setCurrentIndex(static_cast(appConfig().elevateMode())); + +#else + // elevate checkbox is only useful on ms windows. + m_pLabelElevate->hide(); + m_pComboElevate->hide(); + + // for linux and mac, allow auto config by default + allowAutoConfig(); +#endif + + m_pCheckBoxEnableCrypto->setChecked(m_appConfig.getCryptoEnabled()); + +#ifdef SYNERGY_ENTERPRISE + + m_pCheckBoxEnableCrypto->setEnabled(true); + m_pLabelProUpgrade->hide(); + + m_pCheckBoxAutoConfig->hide(); + m_pLabelInstallBonjour->hide(); + +#else + + bool isPro = m_appConfig.edition() == kPro; + m_pCheckBoxEnableCrypto->setEnabled(isPro); + m_pLabelProUpgrade->setVisible(!isPro); + + m_pCheckBoxAutoConfig->setChecked(appConfig().autoConfig()); + +#endif +} + + void SettingsDialog::allowAutoConfig() { m_pLabelInstallBonjour->hide(); @@ -209,3 +215,9 @@ void SettingsDialog::on_m_pLabelInstallBonjour_linkActivated(const QString&) m_pBonjourWindows->downloadAndInstall(); #endif } + +void SettingsDialog::on_m_pRadioSystemScope_toggled(bool checked) +{ + appConfig().setLoadFromSystemScope(checked); + loadFromConfig(); +} diff --git a/src/gui/src/SettingsDialog.h b/src/gui/src/SettingsDialog.h index 738bb4578..64596dda5 100644 --- a/src/gui/src/SettingsDialog.h +++ b/src/gui/src/SettingsDialog.h @@ -45,6 +45,9 @@ class SettingsDialog : public QDialog, public Ui::SettingsDialogBase void changeEvent(QEvent* event); AppConfig& appConfig() { return m_appConfig; } + /// @brief Causes the dialog to load all the settings from m_appConfig + void loadFromConfig(); + private: MainWindow* m_pMainWindow; AppConfig& m_appConfig; @@ -58,6 +61,10 @@ class SettingsDialog : public QDialog, public Ui::SettingsDialogBase void on_m_pCheckBoxLogToFile_stateChanged(int ); void on_m_pButtonBrowseLog_clicked(); void on_m_pLabelInstallBonjour_linkActivated(const QString &link); + + /// @brief Handles the toggling of the system scoped radio button + /// As the user scope radio is connected this will fire for either radio button + void on_m_pRadioSystemScope_toggled(bool checked); }; #endif