aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/mainwindow.cpp13
-rw-r--r--src/messagedetailsdialog.cpp4
-rw-r--r--src/messagedetailsdialog.h6
-rw-r--r--src/messageview.cpp2
-rw-r--r--src/messageview.h12
5 files changed, 30 insertions, 7 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index e82e61d..bf6fc79 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -367,11 +367,16 @@ MainWindow::MainWindow(const Config &config, QWidget *parent)
// action keeps both for the menu it lives in.
m_saveQueryButton->setText(tr("Save"));
- auto updateSaveState = [this, save]() {
- save->setEnabled(!m_queryEdit->text().trimmed().isEmpty());
+ auto updateQueryState = [this, save]() {
+ const bool hasQuery = !m_queryEdit->text().trimmed().isEmpty();
+ save->setEnabled(hasQuery);
+ // The message pane greys "Exclude from search" without it: there
+ // would be nothing to exclude FROM. Both widgets exist by now,
+ // buildUi() having run before registerActions().
+ m_messageView->setHasQuery(hasQuery);
};
- connect(m_queryEdit, &QLineEdit::textChanged, this, updateSaveState);
- updateSaveState();
+ connect(m_queryEdit, &QLineEdit::textChanged, this, updateQueryState);
+ updateQueryState();
}
buildMenus();
diff --git a/src/messagedetailsdialog.cpp b/src/messagedetailsdialog.cpp
index e487270..e862fce 100644
--- a/src/messagedetailsdialog.cpp
+++ b/src/messagedetailsdialog.cpp
@@ -30,8 +30,8 @@
#include "searchterm.h"
MessageDetailsDialog::MessageDetailsDialog(const QList<ThreadRenderItem> &items,
- QWidget *parent)
- : QDialog(parent)
+ bool hasQuery, QWidget *parent)
+ : QDialog(parent), m_hasQuery(hasQuery)
{
setWindowTitle(tr("Message details"));
setObjectName(QStringLiteral("messageDetailsDialog"));
diff --git a/src/messagedetailsdialog.h b/src/messagedetailsdialog.h
index b141c39..b62618a 100644
--- a/src/messagedetailsdialog.h
+++ b/src/messagedetailsdialog.h
@@ -64,7 +64,12 @@ class MessageDetailsDialog : public QDialog
{
Q_OBJECT
public:
+ /// `hasQuery` says whether the query bar holds anything, which decides
+ /// whether "Exclude from search" is offered: there must be something to
+ /// exclude FROM. Taken at construction rather than set later, since the
+ /// dialog is built fresh per invocation and so cannot go stale.
explicit MessageDetailsDialog(const QList<ThreadRenderItem> &items,
+ bool hasQuery = false,
QWidget *parent = nullptr);
/// The rows on display, in order. Exposed for testing without rendering.
@@ -86,4 +91,5 @@ private:
void buildRows(const QList<ThreadRenderItem> &items);
QList<HeaderRow> m_rows;
+ bool m_hasQuery = false;
};
diff --git a/src/messageview.cpp b/src/messageview.cpp
index 26ef7e3..9dc5b36 100644
--- a/src/messageview.cpp
+++ b/src/messageview.cpp
@@ -631,7 +631,7 @@ void MessageView::showDetailsDialog()
if (m_items.isEmpty())
return;
- MessageDetailsDialog dialog(m_items, this);
+ MessageDetailsDialog dialog(m_items, m_hasQuery, this);
// The dialog's searches are the pane's searches: one signal reaches the
// window whichever surface the user used.
diff --git a/src/messageview.h b/src/messageview.h
index 877064e..56925b2 100644
--- a/src/messageview.h
+++ b/src/messageview.h
@@ -149,6 +149,15 @@ public:
/// of which notmuch reports as an error.
SearchOffer selectionSearchOffer(const QString &selectedText) const;
+ /// Tells the pane whether the query bar currently holds anything.
+ ///
+ /// The menus need it to grey out "Exclude from search": excluding from an
+ /// empty query would mean the whole Maildir minus one value. The pane
+ /// cannot read the query bar and must not, so the window pushes the fact
+ /// down as it changes. Passed on to the details dialog at construction,
+ /// which is built fresh per invocation and so cannot go stale.
+ void setHasQuery(bool hasQuery) { m_hasQuery = hasQuery; }
+
public slots:
void toggleHtml();
void loadRemoteContent();
@@ -282,4 +291,7 @@ private:
/// Populated by updateHeader(), consumed by the header's context menu.
QList<SearchOffer> m_headerOffers;
+
+ /// Whether the query bar holds anything. See setHasQuery().
+ bool m_hasQuery = false;
};