#6538 Added event to live swap configs as soon as the scope is changed in settings
This commit is contained in:
parent
70f50a655b
commit
a2009d0aa0
2 changed files with 73 additions and 54 deletions
|
|
@ -49,6 +49,64 @@ SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) :
|
|||
|
||||
m_Locale.fillLanguageComboBox(m_pComboLanguage);
|
||||
|
||||
loadFromConfig();
|
||||
}
|
||||
|
||||
void SettingsDialog::accept()
|
||||
{
|
||||
appConfig().setScreenName(m_pLineEditScreenName->text());
|
||||
appConfig().setPort(m_pSpinBoxPort->value());
|
||||
appConfig().setNetworkInterface(m_pLineEditInterface->text());
|
||||
appConfig().setLogLevel(m_pComboLogLevel->currentIndex());
|
||||
appConfig().setLogToFile(m_pCheckBoxLogToFile->isChecked());
|
||||
appConfig().setLogFilename(m_pLineEditLogFilename->text());
|
||||
appConfig().setLanguage(m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString());
|
||||
appConfig().setElevateMode(static_cast<ElevateMode>(m_pComboElevate->currentIndex()));
|
||||
appConfig().setAutoHide(m_pCheckBoxAutoHide->isChecked());
|
||||
appConfig().setAutoConfig(m_pCheckBoxAutoConfig->isChecked());
|
||||
appConfig().setMinimizeToTray(m_pCheckBoxMinimizeToTray->isChecked());
|
||||
|
||||
//We only need to test the System scoped Radio as they are connected
|
||||
appConfig().setLoadFromSystemScope(m_pRadioSystemScope->isChecked());
|
||||
appConfig().saveSettings();
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void SettingsDialog::reject()
|
||||
{
|
||||
if (appConfig().language() != m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString()) {
|
||||
QSynergyApplication::getInstance()->switchTranslator(appConfig().language());
|
||||
}
|
||||
|
||||
QDialog::reject();
|
||||
}
|
||||
|
||||
void SettingsDialog::changeEvent(QEvent* event)
|
||||
{
|
||||
if (event != nullptr)
|
||||
{
|
||||
switch (event->type())
|
||||
{
|
||||
case QEvent::LanguageChange:
|
||||
{
|
||||
int logLevelIndex = m_pComboLogLevel->currentIndex();
|
||||
|
||||
m_pComboLanguage->blockSignals(true);
|
||||
retranslateUi(this);
|
||||
m_pComboLanguage->blockSignals(false);
|
||||
|
||||
m_pComboLogLevel->setCurrentIndex(logLevelIndex);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
QDialog::changeEvent(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsDialog::loadFromConfig() {
|
||||
|
||||
m_pLineEditScreenName->setText(appConfig().screenName());
|
||||
m_pSpinBoxPort->setValue(appConfig().port());
|
||||
m_pLineEditInterface->setText(appConfig().networkInterface());
|
||||
|
|
@ -105,58 +163,6 @@ SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) :
|
|||
#endif
|
||||
}
|
||||
|
||||
void SettingsDialog::accept()
|
||||
{
|
||||
appConfig().setScreenName(m_pLineEditScreenName->text());
|
||||
appConfig().setPort(m_pSpinBoxPort->value());
|
||||
appConfig().setNetworkInterface(m_pLineEditInterface->text());
|
||||
appConfig().setLogLevel(m_pComboLogLevel->currentIndex());
|
||||
appConfig().setLogToFile(m_pCheckBoxLogToFile->isChecked());
|
||||
appConfig().setLogFilename(m_pLineEditLogFilename->text());
|
||||
appConfig().setLanguage(m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString());
|
||||
appConfig().setElevateMode(static_cast<ElevateMode>(m_pComboElevate->currentIndex()));
|
||||
appConfig().setAutoHide(m_pCheckBoxAutoHide->isChecked());
|
||||
appConfig().setAutoConfig(m_pCheckBoxAutoConfig->isChecked());
|
||||
appConfig().setMinimizeToTray(m_pCheckBoxMinimizeToTray->isChecked());
|
||||
|
||||
//We only need to test the System scoped Radio as they are connected
|
||||
appConfig().setLoadFromSystemScope(m_pRadioSystemScope->isChecked());
|
||||
appConfig().saveSettings();
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void SettingsDialog::reject()
|
||||
{
|
||||
if (appConfig().language() != m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString()) {
|
||||
QSynergyApplication::getInstance()->switchTranslator(appConfig().language());
|
||||
}
|
||||
|
||||
QDialog::reject();
|
||||
}
|
||||
|
||||
void SettingsDialog::changeEvent(QEvent* event)
|
||||
{
|
||||
if (event != nullptr)
|
||||
{
|
||||
switch (event->type())
|
||||
{
|
||||
case QEvent::LanguageChange:
|
||||
{
|
||||
int logLevelIndex = m_pComboLogLevel->currentIndex();
|
||||
|
||||
m_pComboLanguage->blockSignals(true);
|
||||
retranslateUi(this);
|
||||
m_pComboLanguage->blockSignals(false);
|
||||
|
||||
m_pComboLogLevel->setCurrentIndex(logLevelIndex);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
QDialog::changeEvent(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsDialog::allowAutoConfig()
|
||||
{
|
||||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue