Improve restart requests

* Fixes #4959
* Ask to restart when changing languages in application settings.
This commit is contained in:
Jonathan White 2020-07-14 23:55:23 -04:00
parent 2fe74c2947
commit 4a917d171d
2 changed files with 19 additions and 7 deletions

View file

@ -27,6 +27,7 @@
#include "core/Global.h" #include "core/Global.h"
#include "core/Resources.h" #include "core/Resources.h"
#include "core/Translator.h" #include "core/Translator.h"
#include "gui/MainWindow.h"
#include "gui/osutils/OSUtils.h" #include "gui/osutils/OSUtils.h"
#include "MessageBox.h" #include "MessageBox.h"
@ -324,7 +325,15 @@ void ApplicationSettingsWidget::saveSettings()
config()->set(Config::AutoTypeEntryURLMatch, m_generalUi->autoTypeEntryURLMatchCheckBox->isChecked()); config()->set(Config::AutoTypeEntryURLMatch, m_generalUi->autoTypeEntryURLMatchCheckBox->isChecked());
config()->set(Config::FaviconDownloadTimeout, m_generalUi->faviconTimeoutSpinBox->value()); 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_MovableToolbar, m_generalUi->toolbarMovableCheckBox->isChecked());
config()->set(Config::GUI_MonospaceNotes, m_generalUi->monospaceNotesCheckBox->isChecked()); config()->set(Config::GUI_MonospaceNotes, m_generalUi->monospaceNotesCheckBox->isChecked());

View file

@ -1679,17 +1679,20 @@ void MainWindow::initViewMenu()
} }
} }
connect(themeActions, &QActionGroup::triggered, this, [this](QAction* action) { connect(themeActions, &QActionGroup::triggered, this, [this, theme](QAction* action) {
if (action->data() != config()->get(Config::GUI_ApplicationTheme)) { config()->set(Config::GUI_ApplicationTheme, action->data());
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?")); 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()); bool compact = config()->get(Config::GUI_CompactMode).toBool();
connect(m_ui->actionCompactMode, &QAction::toggled, this, [this](bool checked) { m_ui->actionCompactMode->setChecked(compact);
connect(m_ui->actionCompactMode, &QAction::toggled, this, [this, compact](bool checked) {
config()->set(Config::GUI_CompactMode, 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()); m_ui->actionShowToolbar->setChecked(!config()->get(Config::GUI_HideToolbar).toBool());