diff options
| author | Danilo M. <danix@danix.xyz> | 2026-08-15 12:56:54 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-08-15 12:56:54 +0200 |
| commit | 854134ef967568f1441093774cf7497e8c5d6b11 (patch) | |
| tree | 2eafe37300fbedcaa6cdf028dc8531ad42e026fb /src/mainwindow.h | |
| parent | c9392961aa3554a17ab88bfe3ad4e6b76b9a60bc (diff) | |
| download | qtmaildir-854134ef967568f1441093774cf7497e8c5d6b11.tar.gz qtmaildir-854134ef967568f1441093774cf7497e8c5d6b11.zip | |
feat(ui): highlight the built-in filter matching the current view
The four filter buttons gave no sign of which one you were looking at, so
the row said what you could do and never where you were.
The active filter is drawn as a checked QToolButton, which lets the style
paint its own pressed look: a hand-picked highlight colour would have to be
picked once per theme and would still be wrong under a third.
The check state is derived from the query TEXT rather than from the last
button clicked, which is the whole design decision. A record of what was
pressed goes on lying the moment the query is edited into something else,
where a highlight that follows the query clears itself and lights again
when a filter's query is typed by hand. It is resolved against the account
box, so changing account recomputes it rather than dropping it: the same
filter under two accounts is two different query strings and both are
still "Inbox".
Buttons are held in a hash keyed by generator, cleared at the top of the
row build because the row is rebuilt wholesale on every saved-query edit
and stale entries would dangle. The connections are owned by the row
widget, so a rebuild takes them with it rather than leaving a second copy
firing at deleted buttons.
Unread opens already highlighted, which is correct rather than incidental:
startup_query defaults to it, so the window opens on that view. The test
asserts it, so the assertions that follow are known to be a change of
state rather than a button that happened to start unchecked.
Mutation checked against the design that was rejected: deriving the state
from the click instead of the query fails all three tests, each naming the
behaviour it protects.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'src/mainwindow.h')
| -rw-r--r-- | src/mainwindow.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/mainwindow.h b/src/mainwindow.h index 03f21bb..e2d1861 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -327,6 +327,16 @@ private: /// path: being hierarchical. See Config::resolvedQuery(query, accountKey). void runFilter(const SavedQuery &filter); + /// Checks the filter button whose query is what the bar currently holds, + /// and unchecks the rest. + /// + /// Derived from the query TEXT rather than from the last button pressed, so + /// editing the query by hand clears the highlight and typing a filter's + /// query lights it. Resolved against the account box, which is why changing + /// the account keeps the highlight: the same filter resolves to a different + /// query and both are still "Inbox". + void updateFilterButtons(); + /// Names the current query and stores it in queries.json. void saveCurrentQuery(); @@ -736,6 +746,10 @@ private: QLineEdit *m_queryEdit = nullptr; /// Save query, beside the field. Driven by the save_query action. QToolButton *m_saveQueryButton = nullptr; + /// The built-in filter buttons, by generator, so the one matching the + /// current view can be shown as checked. Kept because the buttons are built + /// in a loop and are otherwise unreachable without findChild() on a name. + QHash<QString, QToolButton *> m_filterButtons; /// Whether deleting a saved query asks first. Always true outside tests. bool m_confirmDelete = true; QueryCompleter *m_queryCompleter = nullptr; |
