From 5100b5195a8eba10074d1c4a75c08357925a9267 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Fri, 16 Apr 2021 09:39:47 +0200 Subject: [PATCH] fixed #385 --- .../gui/settings/settingsfeedsmessages.cpp | 3 +++ .../gui/settings/settingsfeedsmessages.ui | 26 ++++++++++++------- src/librssguard/miscellaneous/settings.cpp | 3 +++ src/librssguard/miscellaneous/settings.h | 3 +++ .../services/abstract/rootitem.cpp | 14 +++++++--- 5 files changed, 36 insertions(+), 13 deletions(-) diff --git a/src/librssguard/gui/settings/settingsfeedsmessages.cpp b/src/librssguard/gui/settings/settingsfeedsmessages.cpp index d93611667..54ecdeed4 100644 --- a/src/librssguard/gui/settings/settingsfeedsmessages.cpp +++ b/src/librssguard/gui/settings/settingsfeedsmessages.cpp @@ -37,6 +37,7 @@ SettingsFeedsMessages::SettingsFeedsMessages(Settings* settings, QWidget* parent connect(m_ui->m_spinHeightRowsFeeds, static_cast(&QSpinBox::valueChanged), 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); @@ -127,6 +128,7 @@ void SettingsFeedsMessages::loadSettings() { m_ui->m_spinHeightRowsMessages->setValue(settings()->value(GROUP(GUI), SETTING(GUI::HeightRowMessages)).toInt()); m_ui->m_spinHeightRowsFeeds->setValue(settings()->value(GROUP(GUI), SETTING(GUI::HeightRowFeeds)).toInt()); + m_ui->m_cbHideCountsIfNoUnread->setChecked(settings()->value(GROUP(Feeds), SETTING(Feeds::HideCountsIfNoUnread)).toBool()); 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()); @@ -186,6 +188,7 @@ void SettingsFeedsMessages::saveSettings() { settings()->setValue(GROUP(GUI), GUI::HeightRowMessages, m_ui->m_spinHeightRowsMessages->value()); settings()->setValue(GROUP(GUI), GUI::HeightRowFeeds, m_ui->m_spinHeightRowsFeeds->value()); + settings()->setValue(GROUP(Feeds), Feeds::HideCountsIfNoUnread, m_ui->m_cbHideCountsIfNoUnread->isChecked()); settings()->setValue(GROUP(Messages), Messages::DisplayFeedIconsInList, m_ui->m_checkDisplayFeedIcons->isChecked()); settings()->setValue(GROUP(Messages), Messages::BringAppToFrontAfterMessageOpenedExternally, m_ui->m_checkBringToForegroundAfterMsgOpened->isChecked()); diff --git a/src/librssguard/gui/settings/settingsfeedsmessages.ui b/src/librssguard/gui/settings/settingsfeedsmessages.ui index 112cc6f66..be57a5337 100644 --- a/src/librssguard/gui/settings/settingsfeedsmessages.ui +++ b/src/librssguard/gui/settings/settingsfeedsmessages.ui @@ -70,13 +70,6 @@ - - - - Only auto-download messages when application is unfocused - - - @@ -214,7 +207,7 @@ - + @@ -232,7 +225,7 @@ - + Qt::Vertical @@ -245,6 +238,20 @@ + + + + Hide message counts if there are no unread messages + + + + + + + Only auto-download messages when application is unfocused + + + @@ -449,6 +456,7 @@ m_spinFeedUpdateTimeout m_spinHeightRowsFeeds m_cmbCountsFeedList + m_cbHideCountsIfNoUnread m_checkRemoveReadMessagesOnExit m_checkDisplayPlaceholders m_checkDisplayFeedIcons diff --git a/src/librssguard/miscellaneous/settings.cpp b/src/librssguard/miscellaneous/settings.cpp index e523b3b9d..06b1fec57 100755 --- a/src/librssguard/miscellaneous/settings.cpp +++ b/src/librssguard/miscellaneous/settings.cpp @@ -63,6 +63,9 @@ DVALUE(bool) Feeds::ShowOnlyUnreadFeedsDef = false; DKEY Feeds::ShowTreeBranches = "show_tree_branches"; DVALUE(bool) Feeds::ShowTreeBranchesDef = true; +DKEY Feeds::HideCountsIfNoUnread = "hide_counts_if_no_unread"; +DVALUE(bool) Feeds::HideCountsIfNoUnreadDef = false; + DKEY Feeds::AutoExpandOnSelection = "auto_expand_on_selection"; DVALUE(bool) Feeds::AutoExpandOnSelectionDef = false; diff --git a/src/librssguard/miscellaneous/settings.h b/src/librssguard/miscellaneous/settings.h index 1a253b8a4..1e89578ee 100644 --- a/src/librssguard/miscellaneous/settings.h +++ b/src/librssguard/miscellaneous/settings.h @@ -83,6 +83,9 @@ namespace Feeds { KEY ShowTreeBranches; VALUE(bool) ShowTreeBranchesDef; + KEY HideCountsIfNoUnread; + VALUE(bool) HideCountsIfNoUnreadDef; + KEY AutoExpandOnSelection; VALUE(bool) AutoExpandOnSelectionDef; diff --git a/src/librssguard/services/abstract/rootitem.cpp b/src/librssguard/services/abstract/rootitem.cpp index b787549ea..7e7785bda 100644 --- a/src/librssguard/services/abstract/rootitem.cpp +++ b/src/librssguard/services/abstract/rootitem.cpp @@ -167,12 +167,18 @@ QVariant RootItem::data(int column, int role) const { return m_title; } else if (column == FDS_MODEL_COUNTS_INDEX) { - int count_all = countOfAllMessages(); int count_unread = countOfUnreadMessages(); - return qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::CountFormat)).toString() - .replace(PLACEHOLDER_UNREAD_COUNTS, count_unread < 0 ? QSL("-") : QString::number(count_unread)) - .replace(PLACEHOLDER_ALL_COUNTS, count_all < 0 ? QSL("-") : QString::number(count_all)); + if (count_unread <= 0 && qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::HideCountsIfNoUnread)).toBool()) { + return QString(); + } + else { + int count_all = countOfAllMessages(); + + return qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::CountFormat)).toString() + .replace(PLACEHOLDER_UNREAD_COUNTS, count_unread < 0 ? QSL("-") : QString::number(count_unread)) + .replace(PLACEHOLDER_ALL_COUNTS, count_all < 0 ? QSL("-") : QString::number(count_all)); + } } else { return QVariant();