fix unnecessary prompts to restart app cause by notification settings in settings dialog

This commit is contained in:
Martin Rotter 2023-11-02 07:41:55 +01:00
parent 24cbeb9491
commit 79d7147c36
2 changed files with 12 additions and 9 deletions

View File

@ -30,9 +30,6 @@ SettingsNotifications::SettingsNotifications(Settings* settings, QWidget* parent
connect(m_ui.m_sbScreen, QOverload<int>::of(&QSpinBox::valueChanged), this, &SettingsNotifications::dirtifySettings); connect(m_ui.m_sbScreen, QOverload<int>::of(&QSpinBox::valueChanged), this, &SettingsNotifications::dirtifySettings);
connect(m_ui.m_sbScreen, QOverload<int>::of(&QSpinBox::valueChanged), this, &SettingsNotifications::requireRestart); connect(m_ui.m_sbScreen, QOverload<int>::of(&QSpinBox::valueChanged), this, &SettingsNotifications::requireRestart);
m_ui.m_sbScreen->setMinimum(-1);
m_ui.m_sbScreen->setMaximum(QGuiApplication::screens().size() - 1);
connect(m_ui.m_sbScreen, QOverload<int>::of(&QSpinBox::valueChanged), this, &SettingsNotifications::showScreenInfo); connect(m_ui.m_sbScreen, QOverload<int>::of(&QSpinBox::valueChanged), this, &SettingsNotifications::showScreenInfo);
connect(m_ui.m_cbCustomNotificationsPosition, connect(m_ui.m_cbCustomNotificationsPosition,
@ -43,6 +40,13 @@ SettingsNotifications::SettingsNotifications(Settings* settings, QWidget* parent
QOverload<int>::of(&QComboBox::currentIndexChanged), QOverload<int>::of(&QComboBox::currentIndexChanged),
this, this,
&SettingsNotifications::requireRestart); &SettingsNotifications::requireRestart);
}
void SettingsNotifications::loadSettings() {
onBeginLoadSettings();
m_ui.m_sbScreen->setMinimum(-1);
m_ui.m_sbScreen->setMaximum(QGuiApplication::screens().size() - 1);
QMetaEnum enm = QMetaEnum::fromType<ToastNotificationsManager::NotificationPosition>(); QMetaEnum enm = QMetaEnum::fromType<ToastNotificationsManager::NotificationPosition>();
@ -52,10 +56,6 @@ SettingsNotifications::SettingsNotifications(Settings* settings, QWidget* parent
textForPosition(ToastNotificationsManager::NotificationPosition(enm.value(i))), textForPosition(ToastNotificationsManager::NotificationPosition(enm.value(i))),
enm.value(i)); enm.value(i));
} }
}
void SettingsNotifications::loadSettings() {
onBeginLoadSettings();
// Load fancy notification settings. // Load fancy notification settings.
m_ui.m_checkEnableNotifications m_ui.m_checkEnableNotifications

View File

@ -5,7 +5,8 @@
#include "miscellaneous/settings.h" #include "miscellaneous/settings.h"
SettingsPanel::SettingsPanel(Settings* settings, QWidget* parent) SettingsPanel::SettingsPanel(Settings* settings, QWidget* parent)
: QWidget(parent), m_requiresRestart(false), m_isDirty(false), m_isLoading(false), m_isLoaded(false), m_settings(settings) {} : QWidget(parent), m_requiresRestart(false), m_isDirty(false), m_isLoading(false), m_isLoaded(false),
m_settings(settings) {}
void SettingsPanel::onBeginLoadSettings() { void SettingsPanel::onBeginLoadSettings() {
m_isLoading = true; m_isLoading = true;
@ -41,7 +42,9 @@ void SettingsPanel::setRequiresRestart(bool requiresRestart) {
} }
void SettingsPanel::requireRestart() { void SettingsPanel::requireRestart() {
setRequiresRestart(true); if (!m_isLoading) {
setRequiresRestart(true);
}
} }
bool SettingsPanel::isLoaded() const { bool SettingsPanel::isLoaded() const {