aboutsummaryrefslogtreecommitdiffstats
path: root/src/tagrulesdialog.cpp
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-10-31 11:58:57 +0100
committerDanilo M. <danix@danix.xyz>2026-11-17 10:26:23 +0100
commit78645253a6d55d70d70aefdf4e64c585f8e93c8c (patch)
treeda70d626a5f31111dd673fdabfc9fd52a2842fa2 /src/tagrulesdialog.cpp
parent86ff3c6a66c2973a96c589151855a2d54d807236 (diff)
downloadqtmaildir-78645253a6d55d70d70aefdf4e64c585f8e93c8c.tar.gz
qtmaildir-78645253a6d55d70d70aefdf4e64c585f8e93c8c.zip
fix: keep the rules banner true after Apply, delete and copy
The dialog stays open after Apply, so a refusal from a failed attempt and the load warnings about a file Apply has just rewritten both outlived what they described. A successful Apply rereads the file and redraws the banner. Deleting the last rule now disables Apply, and copying or deleting a rule re-checks which rules the sync hook will skip. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'src/tagrulesdialog.cpp')
-rw-r--r--src/tagrulesdialog.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/tagrulesdialog.cpp b/src/tagrulesdialog.cpp
index 5aaf8ab..2344915 100644
--- a/src/tagrulesdialog.cpp
+++ b/src/tagrulesdialog.cpp
@@ -675,6 +675,9 @@ void TagRulesDialog::reloadList()
if (!m_working.isEmpty())
m_list->setCurrentItem(m_list->topLevelItem(0));
+ // Here as well as on selection: with no rule left, nothing is selected
+ // and onSelectionChanged() never runs to disable it.
+ updateApplyButton();
}
int TagRulesDialog::currentIndex() const
@@ -791,7 +794,11 @@ void TagRulesDialog::applyEditsToCurrentRule()
fillItem(m_list->topLevelItem(index), rule);
updateApplyButton();
+ refreshSkipWarning();
+}
+void TagRulesDialog::refreshSkipWarning()
+{
if (hookSkipWarning() != m_lastSkipWarning)
showWarnings();
}
@@ -852,6 +859,7 @@ void TagRulesDialog::onCopyRule()
m_working.insert(index + 1, copy);
reloadList();
m_list->setCurrentItem(m_list->topLevelItem(index + 1));
+ refreshSkipWarning();
}
void TagRulesDialog::onDeleteRule()
@@ -861,6 +869,7 @@ void TagRulesDialog::onDeleteRule()
return;
m_working.removeAt(index);
reloadList();
+ refreshSkipWarning();
}
QStringList TagRulesDialog::countQueries() const
@@ -930,12 +939,22 @@ void TagRulesDialog::onApply()
// The dialog stays open; only OK closes it.
if (!saveRules())
return;
+ // The dialog stays open, so the banner must stop describing a file that
+ // has just been rewritten: rereading it clears the load warnings, and
+ // showWarnings() replaces any refusal from an earlier attempt.
+ m_rules.load();
+ showWarnings();
const int index = currentIndex();
if (index < 0 || index >= m_working.size())
return;
emit applyRequested(m_working.at(index));
}
+bool TagRulesDialog::applyEnabledForTest() const
+{
+ return m_applyButton->isEnabled();
+}
+
void TagRulesDialog::setArchiveForTest(bool on)
{
m_archive->setChecked(on); // toggled -> applyEditsToCurrentRule