fix notifications enabled/disabled

This commit is contained in:
Martin Rotter 2021-06-18 13:53:27 +02:00
parent 50e1d79c42
commit ab1011bebc
8 changed files with 53 additions and 72 deletions

View File

@ -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());

View File

@ -73,7 +73,14 @@
</property>
</widget>
</item>
<item row="4" column="0">
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="m_checkAutoUpdateOnlyUnfocused">
<property name="text">
<string>Only auto-download messages when application is unfocused</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QGroupBox" name="groupBox_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
@ -105,7 +112,17 @@
</layout>
</widget>
</item>
<item row="5" column="1">
<item row="4" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Feed connection timeout</string>
</property>
<property name="buddy">
<cstring>m_spinFeedUpdateTimeout</cstring>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="m_spinFeedUpdateTimeout">
<property name="toolTip">
<string>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.</string>
@ -124,7 +141,7 @@
</property>
</widget>
</item>
<item row="6" column="0">
<item row="5" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Height or rows in feed list (-1 = default height)</string>
@ -134,7 +151,7 @@
</property>
</widget>
</item>
<item row="6" column="1">
<item row="5" column="1">
<widget class="QSpinBox" name="m_spinHeightRowsFeeds">
<property name="minimum">
<number>-1</number>
@ -144,7 +161,7 @@
</property>
</widget>
</item>
<item row="7" column="0">
<item row="6" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Message count format in feed list</string>
@ -154,7 +171,7 @@
</property>
</widget>
</item>
<item row="7" column="1">
<item row="6" column="1">
<widget class="QComboBox" name="m_cmbCountsFeedList">
<property name="toolTip">
<string notr="true"/>
@ -164,7 +181,7 @@
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<item row="7" column="0" colspan="2">
<widget class="QLabel" name="label_9">
<property name="font">
<font>
@ -182,7 +199,21 @@
</property>
</widget>
</item>
<item row="11" column="0" colspan="2">
<item row="8" column="0" colspan="2">
<widget class="QCheckBox" name="m_cbHideCountsIfNoUnread">
<property name="text">
<string>Hide message counts if there are no unread messages</string>
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<widget class="QCheckBox" name="m_checkShowTooltips">
<property name="text">
<string>Display tooltips for feeds and messages</string>
</property>
</widget>
</item>
<item row="10" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -195,44 +226,6 @@
</property>
</spacer>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Feed connection timeout</string>
</property>
<property name="buddy">
<cstring>m_spinFeedUpdateTimeout</cstring>
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<widget class="QCheckBox" name="m_cbHideCountsIfNoUnread">
<property name="text">
<string>Hide message counts if there are no unread messages</string>
</property>
</widget>
</item>
<item row="10" column="0" colspan="2">
<widget class="QCheckBox" name="m_checkShowTooltips">
<property name="text">
<string>Display tooltips for feeds and messages</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="m_checkAutoUpdateOnlyUnfocused">
<property name="text">
<string>Only auto-download messages when application is unfocused</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="m_checkAutoUpdateNotification">
<property name="text">
<string>Enable &quot;auto-download started&quot; notification</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="m_tabMessages">
@ -432,7 +425,6 @@
<tabstop>m_spinStartupUpdateDelay</tabstop>
<tabstop>m_checkAutoUpdate</tabstop>
<tabstop>m_spinAutoUpdateInterval</tabstop>
<tabstop>m_checkAutoUpdateNotification</tabstop>
<tabstop>m_checkAutoUpdateOnlyUnfocused</tabstop>
<tabstop>m_btnChangeFeedListFont</tabstop>
<tabstop>m_spinFeedUpdateTimeout</tabstop>

View File

@ -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();

View File

@ -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() {

View File

@ -316,13 +316,11 @@ 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);
}
}
}
QList<MessageFilter*> FeedReader::messageFilters() const {

View File

@ -17,7 +17,7 @@ QList<Notification> 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();
}

View File

@ -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";

View File

@ -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.