From ab1011bebc9d8cf2cb6db22813cec774dff90407 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Fri, 18 Jun 2021 13:53:27 +0200 Subject: [PATCH] fix notifications enabled/disabled --- .../gui/settings/settingsfeedsmessages.cpp | 3 - .../gui/settings/settingsfeedsmessages.ui | 86 +++++++++---------- .../gui/settings/settingsnotifications.cpp | 4 +- src/librssguard/gui/systemtrayicon.cpp | 2 +- src/librssguard/miscellaneous/feedreader.cpp | 10 +-- .../miscellaneous/notificationfactory.cpp | 2 +- src/librssguard/miscellaneous/settings.cpp | 9 +- src/librssguard/miscellaneous/settings.h | 9 +- 8 files changed, 53 insertions(+), 72 deletions(-) diff --git a/src/librssguard/gui/settings/settingsfeedsmessages.cpp b/src/librssguard/gui/settings/settingsfeedsmessages.cpp index e0888829b..ad8a3a7e0 100644 --- a/src/librssguard/gui/settings/settingsfeedsmessages.cpp +++ b/src/librssguard/gui/settings/settingsfeedsmessages.cpp @@ -38,7 +38,6 @@ SettingsFeedsMessages::SettingsFeedsMessages(Settings* settings, QWidget* parent this, &SettingsFeedsMessages::requireRestart); connect(m_ui->m_cbHideCountsIfNoUnread, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings); - connect(m_ui->m_checkAutoUpdateNotification, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings); connect(m_ui->m_checkAutoUpdate, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings); connect(m_ui->m_checkAutoUpdateOnlyUnfocused, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings); connect(m_ui->m_checkDisplayFeedIcons, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings); @@ -133,7 +132,6 @@ void SettingsFeedsMessages::loadSettings() { m_ui->m_checkDisplayFeedIcons->setChecked(settings()->value(GROUP(Messages), SETTING(Messages::DisplayFeedIconsInList)).toBool()); m_ui->m_checkBringToForegroundAfterMsgOpened->setChecked(settings()->value(GROUP(Messages), SETTING(Messages::BringAppToFrontAfterMessageOpenedExternally)).toBool()); - m_ui->m_checkAutoUpdateNotification->setChecked(settings()->value(GROUP(Feeds), SETTING(Feeds::EnableAutoUpdateNotification)).toBool()); m_ui->m_checkKeppMessagesInTheMiddle->setChecked(settings()->value(GROUP(Messages), SETTING(Messages::KeepCursorInCenter)).toBool()); m_ui->m_checkRemoveReadMessagesOnExit->setChecked(settings()->value(GROUP(Messages), SETTING(Messages::ClearReadOnExit)).toBool()); m_ui->m_checkAutoUpdate->setChecked(settings()->value(GROUP(Feeds), SETTING(Feeds::AutoUpdateEnabled)).toBool()); @@ -194,7 +192,6 @@ void SettingsFeedsMessages::saveSettings() { settings()->setValue(GROUP(Messages), Messages::DisplayFeedIconsInList, m_ui->m_checkDisplayFeedIcons->isChecked()); settings()->setValue(GROUP(Messages), Messages::BringAppToFrontAfterMessageOpenedExternally, m_ui->m_checkBringToForegroundAfterMsgOpened->isChecked()); - settings()->setValue(GROUP(Feeds), Feeds::EnableAutoUpdateNotification, m_ui->m_checkAutoUpdateNotification->isChecked()); settings()->setValue(GROUP(Messages), Messages::KeepCursorInCenter, m_ui->m_checkKeppMessagesInTheMiddle->isChecked()); settings()->setValue(GROUP(Messages), Messages::ClearReadOnExit, m_ui->m_checkRemoveReadMessagesOnExit->isChecked()); settings()->setValue(GROUP(Feeds), Feeds::AutoUpdateEnabled, m_ui->m_checkAutoUpdate->isChecked()); diff --git a/src/librssguard/gui/settings/settingsfeedsmessages.ui b/src/librssguard/gui/settings/settingsfeedsmessages.ui index de142f710..272b11f4b 100644 --- a/src/librssguard/gui/settings/settingsfeedsmessages.ui +++ b/src/librssguard/gui/settings/settingsfeedsmessages.ui @@ -73,7 +73,14 @@ - + + + + Only auto-download messages when application is unfocused + + + + @@ -105,7 +112,17 @@ - + + + + Feed connection timeout + + + m_spinFeedUpdateTimeout + + + + Connection timeout is time interval which is reserved for downloading new messages for the feed. If this time interval elapses, then download process is aborted. @@ -124,7 +141,7 @@ - + Height or rows in feed list (-1 = default height) @@ -134,7 +151,7 @@ - + -1 @@ -144,7 +161,7 @@ - + Message count format in feed list @@ -154,7 +171,7 @@ - + @@ -164,7 +181,7 @@ - + @@ -182,7 +199,21 @@ - + + + + Hide message counts if there are no unread messages + + + + + + + Display tooltips for feeds and messages + + + + Qt::Vertical @@ -195,44 +226,6 @@ - - - - Feed connection timeout - - - m_spinFeedUpdateTimeout - - - - - - - Hide message counts if there are no unread messages - - - - - - - Display tooltips for feeds and messages - - - - - - - Only auto-download messages when application is unfocused - - - - - - - Enable "auto-download started" notification - - - @@ -432,7 +425,6 @@ m_spinStartupUpdateDelay m_checkAutoUpdate m_spinAutoUpdateInterval - m_checkAutoUpdateNotification m_checkAutoUpdateOnlyUnfocused m_btnChangeFeedListFont m_spinFeedUpdateTimeout diff --git a/src/librssguard/gui/settings/settingsnotifications.cpp b/src/librssguard/gui/settings/settingsnotifications.cpp index 64b432919..c9d125800 100755 --- a/src/librssguard/gui/settings/settingsnotifications.cpp +++ b/src/librssguard/gui/settings/settingsnotifications.cpp @@ -34,7 +34,7 @@ void SettingsNotifications::loadSettings() { m_ui.m_lblAvailableSounds->setText(QSL("Built-in sounds:\n%1").arg(descs)); // Load fancy notification settings. - m_ui.m_checkEnableNotifications->setChecked(settings()->value(GROUP(Notifications), SETTING(Notifications::EnableNotifications)).toBool()); + m_ui.m_checkEnableNotifications->setChecked(settings()->value(GROUP(GUI), SETTING(GUI::EnableNotifications)).toBool()); m_ui.m_editor->loadNotifications(qApp->notifications()->allNotifications()); onEndLoadSettings(); @@ -44,7 +44,7 @@ void SettingsNotifications::saveSettings() { onBeginSaveSettings(); // Save notifications. - settings()->setValue(GROUP(Notifications), Notifications::EnableNotifications, m_ui.m_checkEnableNotifications->isChecked()); + settings()->setValue(GROUP(GUI), GUI::EnableNotifications, m_ui.m_checkEnableNotifications->isChecked()); qApp->notifications()->save(m_ui.m_editor->allNotifications(), settings()); onEndSaveSettings(); diff --git a/src/librssguard/gui/systemtrayicon.cpp b/src/librssguard/gui/systemtrayicon.cpp index f321ae0ea..71ddc27b7 100644 --- a/src/librssguard/gui/systemtrayicon.cpp +++ b/src/librssguard/gui/systemtrayicon.cpp @@ -71,7 +71,7 @@ bool SystemTrayIcon::isSystemTrayDesired() { } bool SystemTrayIcon::areNotificationsEnabled() { - return qApp->settings()->value(GROUP(Notifications), SETTING(Notifications::EnableNotifications)).toBool(); + return qApp->settings()->value(GROUP(GUI), SETTING(GUI::EnableNotifications)).toBool(); } void SystemTrayIcon::showPrivate() { diff --git a/src/librssguard/miscellaneous/feedreader.cpp b/src/librssguard/miscellaneous/feedreader.cpp index f64b1a849..d3c0d7c2f 100644 --- a/src/librssguard/miscellaneous/feedreader.cpp +++ b/src/librssguard/miscellaneous/feedreader.cpp @@ -316,12 +316,10 @@ void FeedReader::executeNextAutoUpdate() { updateFeeds(feeds_for_update); // NOTE: OSD/bubble informing about performing of scheduled update can be shown now. - if (qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::EnableAutoUpdateNotification)).toBool()) { - qApp->showGuiMessage(Notification::Event::ArticlesFetchingStarted, - tr("Starting auto-download of some feeds' articles"), - tr("I will auto-download new articles for %n feed(s).", nullptr, feeds_for_update.size()), - QSystemTrayIcon::MessageIcon::Information); - } + qApp->showGuiMessage(Notification::Event::ArticlesFetchingStarted, + tr("Starting auto-download of some feeds' articles"), + tr("I will auto-download new articles for %n feed(s).", nullptr, feeds_for_update.size()), + QSystemTrayIcon::MessageIcon::Information); } } diff --git a/src/librssguard/miscellaneous/notificationfactory.cpp b/src/librssguard/miscellaneous/notificationfactory.cpp index c311db968..25d526727 100755 --- a/src/librssguard/miscellaneous/notificationfactory.cpp +++ b/src/librssguard/miscellaneous/notificationfactory.cpp @@ -17,7 +17,7 @@ QList NotificationFactory::allNotifications() const { } Notification NotificationFactory::notificationForEvent(Notification::Event event) const { - if (!qApp->settings()->value(GROUP(Notifications), SETTING(Notifications::EnableNotifications)).toBool()) { + if (!qApp->settings()->value(GROUP(GUI), SETTING(GUI::EnableNotifications)).toBool()) { return Notification(); } diff --git a/src/librssguard/miscellaneous/settings.cpp b/src/librssguard/miscellaneous/settings.cpp index adf44ddcb..6a08f4a8e 100755 --- a/src/librssguard/miscellaneous/settings.cpp +++ b/src/librssguard/miscellaneous/settings.cpp @@ -39,9 +39,6 @@ DKEY Feeds::ID = "feeds"; DKEY Feeds::UpdateTimeout = "feed_update_timeout"; DVALUE(int) Feeds::UpdateTimeoutDef = DOWNLOAD_TIMEOUT; -DKEY Feeds::EnableAutoUpdateNotification = "enable_auto_update_notification"; -DVALUE(bool) Feeds::EnableAutoUpdateNotificationDef = false; - DKEY Feeds::CountFormat = "count_format"; DVALUE(char*) Feeds::CountFormatDef = "(%unread)"; @@ -181,6 +178,9 @@ DVALUE(bool) GUI::MessageViewerToolbarsVisibleDef = true; DKEY GUI::StatusBarVisible = "enable_status_bar"; DVALUE(bool) GUI::StatusBarVisibleDef = true; +DKEY GUI::EnableNotifications = "enable_notifications"; +DVALUE(bool) GUI::EnableNotificationsDef = true; + DKEY GUI::HideMainWindowWhenMinimized = "hide_when_minimized"; DVALUE(bool) GUI::HideMainWindowWhenMinimizedDef = false; @@ -312,9 +312,6 @@ DKEY Keyboard::ID = "keyboard"; // Notifications. DKEY Notifications::ID = "notifications"; -DKEY Notifications::EnableNotifications = "enable_notifications"; -DVALUE(bool) Notifications::EnableNotificationsDef = true; - // Web browser. DKEY Browser::ID = "browser"; diff --git a/src/librssguard/miscellaneous/settings.h b/src/librssguard/miscellaneous/settings.h index 02e6e4e7b..c6414378d 100644 --- a/src/librssguard/miscellaneous/settings.h +++ b/src/librssguard/miscellaneous/settings.h @@ -56,9 +56,6 @@ namespace Feeds { KEY UpdateTimeout; VALUE(int) UpdateTimeoutDef; - KEY EnableAutoUpdateNotification; - VALUE(bool) EnableAutoUpdateNotificationDef; - KEY CountFormat; VALUE(char*) CountFormatDef; @@ -144,6 +141,9 @@ namespace Messages { namespace GUI { KEY ID; + KEY EnableNotifications; + VALUE(bool) EnableNotificationsDef; + KEY MessageViewState; VALUE(QString) MessageViewStateDef; @@ -360,9 +360,6 @@ namespace Keyboard { // Notifications. namespace Notifications { KEY ID; - - KEY EnableNotifications; - VALUE(bool) EnableNotificationsDef; } // Web browser.