diff options
| author | Danilo M. <danix@danix.xyz> | 2026-08-14 18:04:32 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-08-14 18:04:32 +0200 |
| commit | de1f7dba196d59cdaa46d2938e5e40e40f97a692 (patch) | |
| tree | 539fef2d664c1a83cc9ee7c7d69968ddc1f52b37 /src | |
| parent | 612eb64871de7e00f21a9b7ebf33d8179caa16bc (diff) | |
| download | qtmaildir-de1f7dba196d59cdaa46d2938e5e40e40f97a692.tar.gz qtmaildir-de1f7dba196d59cdaa46d2938e5e40e40f97a692.zip | |
feat(search): offer Exclude from search in both menus
Third entry in the message pane's submenus and in each details row,
greyed rather than hidden when the query bar is empty, so the feature
stays visible to someone exploring a fresh window.
requestSearch refuses an Exclude with no query as well, so the guard
does not rest on the menu's enabled state alone. Mutation checked:
disabling that condition fails the new test on the blocked emit.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/messagedetailsdialog.cpp | 15 | ||||
| -rw-r--r-- | src/messagedetailsdialog.h | 5 | ||||
| -rw-r--r-- | src/messageview.cpp | 8 |
3 files changed, 28 insertions, 0 deletions
diff --git a/src/messagedetailsdialog.cpp b/src/messagedetailsdialog.cpp index e862fce..b024989 100644 --- a/src/messagedetailsdialog.cpp +++ b/src/messagedetailsdialog.cpp @@ -98,6 +98,17 @@ MessageDetailsDialog::MessageDetailsDialog(const QList<ThreadRenderItem> &items, requestSearch( row, SearchTerm::SearchMode::Narrow); }); + auto *exclude = + menu.addAction(tr("Exclude from search")); + // Visible but greyed rather than hidden: someone + // exploring a fresh window is exactly who should see + // that the feature exists. + exclude->setEnabled(m_hasQuery); + connect(exclude, &QAction::triggered, this, + [this, row]() { + requestSearch( + row, SearchTerm::SearchMode::Exclude); + }); menu.exec(value->mapToGlobal(pos)); }); } @@ -156,5 +167,9 @@ void MessageDetailsDialog::requestSearch(const HeaderRow &row, { if (row.query.isEmpty()) return; + // Nothing to exclude FROM: the entry is greyed, and this is the second + // layer in case it is reached another way. + if (mode == SearchTerm::SearchMode::Exclude && !m_hasQuery) + return; emit searchRequested(row.query, mode); } diff --git a/src/messagedetailsdialog.h b/src/messagedetailsdialog.h index b62618a..186006f 100644 --- a/src/messagedetailsdialog.h +++ b/src/messagedetailsdialog.h @@ -75,6 +75,11 @@ public: /// The rows on display, in order. Exposed for testing without rendering. QList<HeaderRow> rows() const { return m_rows; } + /// Whether "Exclude from search" is offered. False with an empty query + /// bar: there would be nothing to exclude FROM. Exposed for testing + /// without popping a context menu. + bool canExcludeFromSearch() const { return m_hasQuery; } + /// Emits searchRequested for `row`, or nothing when the row carries no /// searchable query. The menu entries call this; a test can too, without /// popping a menu. diff --git a/src/messageview.cpp b/src/messageview.cpp index 9dc5b36..bdf1b13 100644 --- a/src/messageview.cpp +++ b/src/messageview.cpp @@ -577,6 +577,14 @@ void MessageView::addSearchEntries(QMenu *menu, const QList<SearchOffer> &offers connect(narrow, &QAction::triggered, this, [this, entry]() { emit searchRequested(entry.query, SearchTerm::SearchMode::Narrow); }); + + auto *exclude = sub->addAction(tr("Exclude from search")); + // Visible but greyed rather than hidden, as in the details dialog: + // there must be a query to exclude FROM. + exclude->setEnabled(m_hasQuery); + connect(exclude, &QAction::triggered, this, [this, entry]() { + emit searchRequested(entry.query, SearchTerm::SearchMode::Exclude); + }); } } |
