From 4a917d171d156812ed24320c6de727667ddcabaf Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Tue, 14 Jul 2020 23:55:23 -0400 Subject: [PATCH] Improve restart requests * Fixes #4959 * Ask to restart when changing languages in application settings. --- src/gui/ApplicationSettingsWidget.cpp | 11 ++++++++++- src/gui/MainWindow.cpp | 15 +++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/gui/ApplicationSettingsWidget.cpp b/src/gui/ApplicationSettingsWidget.cpp index 691115368..8d958ab7a 100644 --- a/src/gui/ApplicationSettingsWidget.cpp +++ b/src/gui/ApplicationSettingsWidget.cpp @@ -27,6 +27,7 @@ #include "core/Global.h" #include "core/Resources.h" #include "core/Translator.h" +#include "gui/MainWindow.h" #include "gui/osutils/OSUtils.h" #include "MessageBox.h" @@ -324,7 +325,15 @@ void ApplicationSettingsWidget::saveSettings() config()->set(Config::AutoTypeEntryURLMatch, m_generalUi->autoTypeEntryURLMatchCheckBox->isChecked()); config()->set(Config::FaviconDownloadTimeout, m_generalUi->faviconTimeoutSpinBox->value()); - config()->set(Config::GUI_Language, m_generalUi->languageComboBox->currentData().toString()); + auto language = m_generalUi->languageComboBox->currentData().toString(); + if (config()->get(Config::GUI_Language) != language) { + QTimer::singleShot(200, [] { + getMainWindow()->restartApp( + tr("You must restart the application to set the new language. Would you like to restart now?")); + }); + } + config()->set(Config::GUI_Language, language); + config()->set(Config::GUI_MovableToolbar, m_generalUi->toolbarMovableCheckBox->isChecked()); config()->set(Config::GUI_MonospaceNotes, m_generalUi->monospaceNotesCheckBox->isChecked()); diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 9751a3e77..2ae78157e 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -1679,17 +1679,20 @@ void MainWindow::initViewMenu() } } - connect(themeActions, &QActionGroup::triggered, this, [this](QAction* action) { - if (action->data() != config()->get(Config::GUI_ApplicationTheme)) { - config()->set(Config::GUI_ApplicationTheme, action->data()); + connect(themeActions, &QActionGroup::triggered, this, [this, theme](QAction* action) { + config()->set(Config::GUI_ApplicationTheme, action->data()); + if (action->data() != theme) { restartApp(tr("You must restart the application to apply this setting. Would you like to restart now?")); } }); - m_ui->actionCompactMode->setChecked(config()->get(Config::GUI_CompactMode).toBool()); - connect(m_ui->actionCompactMode, &QAction::toggled, this, [this](bool checked) { + bool compact = config()->get(Config::GUI_CompactMode).toBool(); + m_ui->actionCompactMode->setChecked(compact); + connect(m_ui->actionCompactMode, &QAction::toggled, this, [this, compact](bool checked) { config()->set(Config::GUI_CompactMode, checked); - restartApp(tr("You must restart the application to apply this setting. Would you like to restart now?")); + if (checked != compact) { + restartApp(tr("You must restart the application to apply this setting. Would you like to restart now?")); + } }); m_ui->actionShowToolbar->setChecked(!config()->get(Config::GUI_HideToolbar).toBool());