aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/tagrulesdialog.cpp19
-rw-r--r--src/tagrulesdialog.h7
2 files changed, 26 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
diff --git a/src/tagrulesdialog.h b/src/tagrulesdialog.h
index 1613507..f396557 100644
--- a/src/tagrulesdialog.h
+++ b/src/tagrulesdialog.h
@@ -98,6 +98,9 @@ public:
void applyForTest() { onApply(); }
/// Ticks or clears the archive box, as a click would.
void setArchiveForTest(bool on);
+ bool applyEnabledForTest() const;
+ void copyRuleForTest() { onCopyRule(); }
+ void deleteRuleForTest() { onDeleteRule(); }
/// Types into the query field and toggles the mode, so the refusal path
/// can be reached without a synthetic click. The refusal reports through
@@ -244,6 +247,10 @@ private:
/// Enables Apply only for a rule worth applying.
void updateApplyButton();
+ /// Re-renders the banner when the skip sentence changed. Not called from
+ /// reloadList(), which runs once before the constructor's showWarnings().
+ void refreshSkipWarning();
+
/// The only way the warning label is written. An empty string hides it.
/// One route in so the icon and the red styling cannot drift between the
/// load path, the save refusal and the text-mode notice.