aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mainwindow.cpp9
-rw-r--r--src/mainwindow.h7
2 files changed, 13 insertions, 3 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 14e4202..f9c9c65 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -1322,18 +1322,23 @@ void MainWindow::onDatabaseStatsReady(const DatabaseStats &stats,
number(stats.tags)));
}
-void MainWindow::showTagRulesDialog()
+void MainWindow::showTagRulesDialog(const TagRule &seed)
{
// One dialog. A second would edit a stale copy and the last Save would
// silently win, which is the lost-edit case the atomic write cannot help
// with because both writers are this process.
if (m_tagRulesDialog) {
+ // Seeded into the dialog already up rather than dropped: the menu item
+ // must do something visible, and a second dialog would edit a stale
+ // copy whose Save would silently win.
+ if (!seed.query.isEmpty())
+ m_tagRulesDialog->seedRule(seed);
m_tagRulesDialog->raise();
m_tagRulesDialog->activateWindow();
return;
}
- auto *dialog = new TagRulesDialog(this);
+ auto *dialog = new TagRulesDialog(seed, this);
dialog->setAttribute(Qt::WA_DeleteOnClose);
m_tagRulesDialog = dialog;
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 6e8501a..a68fcd9 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -34,6 +34,9 @@
// Included rather than forward-declared: SyncPhaseTracker is held by value, so
// its size must be known here. MailSync itself stays a forward declaration.
#include "mailsync.h"
+// Complete type, not a forward declaration: showTagRulesDialog() defaults its
+// seed to TagRule().
+#include "tagrules.h"
#include "syncmonitor.h"
#include "tagcolors.h"
#include "types.h"
@@ -376,7 +379,9 @@ private slots:
void onRulePreviewRequested(const QString &query);
/// Opens the auto-tagging rules editor, or raises the one already open.
- void showTagRulesDialog();
+ /// `seed` is an optional rule to open on, used by Create tagging rule on a
+ /// saved query. A default-constructed TagRule (empty query) means none.
+ void showTagRulesDialog(const TagRule &seed = TagRule());
/// Message counts for the rules dialog's queries, in the order it asked
/// for them. Does nothing if the dialog has since closed, or if a newer