This commit is contained in:
Martin Rotter 2021-04-16 09:39:47 +02:00
parent 991ded863a
commit 5100b5195a
5 changed files with 36 additions and 13 deletions

View File

@ -37,6 +37,7 @@ SettingsFeedsMessages::SettingsFeedsMessages(Settings* settings, QWidget* parent
connect(m_ui->m_spinHeightRowsFeeds, static_cast<void (QSpinBox::*)(int)>(&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());

View File

@ -70,13 +70,6 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="m_checkAutoUpdateOnlyUnfocused">
<property name="text">
<string>Only auto-download messages when application is unfocused</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QGroupBox" name="groupBox_6">
<property name="title">
@ -214,7 +207,7 @@
</item>
</layout>
</item>
<item row="8" column="0" colspan="2">
<item row="9" column="0" colspan="2">
<widget class="QLabel" name="label_9">
<property name="font">
<font>
@ -232,7 +225,7 @@
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<item row="10" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -245,6 +238,20 @@
</property>
</spacer>
</item>
<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="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>
</layout>
</widget>
<widget class="QWidget" name="m_tabMessages">
@ -449,6 +456,7 @@
<tabstop>m_spinFeedUpdateTimeout</tabstop>
<tabstop>m_spinHeightRowsFeeds</tabstop>
<tabstop>m_cmbCountsFeedList</tabstop>
<tabstop>m_cbHideCountsIfNoUnread</tabstop>
<tabstop>m_checkRemoveReadMessagesOnExit</tabstop>
<tabstop>m_checkDisplayPlaceholders</tabstop>
<tabstop>m_checkDisplayFeedIcons</tabstop>

View File

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

View File

@ -83,6 +83,9 @@ namespace Feeds {
KEY ShowTreeBranches;
VALUE(bool) ShowTreeBranchesDef;
KEY HideCountsIfNoUnread;
VALUE(bool) HideCountsIfNoUnreadDef;
KEY AutoExpandOnSelection;
VALUE(bool) AutoExpandOnSelectionDef;

View File

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