From d4e4cebbefdce5f575954594461dc707492b2dd8 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Sat, 15 Aug 2026 11:46:58 +0200 Subject: feat(startup): add startup_account, the account the dropdown opens on Answers "start me in work - Inbox rather than All accounts - Inbox". The key names an account by its [account.] suffix and the dropdown is set to it before the startup query runs; because a built-in filter composes with the dropdown, that is the whole mechanism and the key never reaches a query builder. Validated on load: a name matching no account is reported and cleared, since the dropdown has no entry for it and would sit on All accounts without saying why. Which side applies the scope depends on what the startup entry is, and getting it wrong is silent in both directions. A generated filter comes back from resolvedQuery() already scoped, so letting runQuery() apply the dropdown again gives path:"work/**" and (path:"work/**" and (tag:inbox)). A saved query does not, because resolvedQuery() ignores the account key for one, so claiming it was already scoped leaves it unscoped with the dropdown pointing at Work. The first of those shipped in this session's working tree and passed its test, because the assertion used contains() and the double-scoped string contains the scope too. It asserts the exact query now. The second was found by writing the test for the case rather than by reading, and is covered by aStartupAccountAlsoScopesASavedStartupQuery. The README's startup_query documentation was wrong on two counts after the previous commit: the fallback is the Unread filter rather than the first query in the file, and the name can now match a built-in filter. --- src/config.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/config.h') diff --git a/src/config.h b/src/config.h index 3946b40..d1f8e65 100644 --- a/src/config.h +++ b/src/config.h @@ -299,6 +299,17 @@ public: /// sort first rather than anything the user chose. QString startupQuery() const { return m_startupQuery; } + /// Account key the dropdown starts on, or empty for "All accounts". + /// + /// Scoping happens because the built-in filters COMPOSE with the dropdown, + /// so setting it before the startup query runs is the whole mechanism: this + /// key does not need to reach the query builders at all. + /// + /// Validated on load. A name matching no account is reported and left + /// empty, rather than passed on to a dropdown that has no such entry and + /// would silently stay on "All accounts". + QString startupAccount() const { return m_startupAccount; } + /// The saved query startupQuery() names, or the first one when it names /// nothing that exists. A default-constructed SavedQuery when there are /// none at all. @@ -401,6 +412,10 @@ private: QList m_extraMimetypes; QString m_startupQuery = QStringLiteral("Unread"); + /// Empty means "All accounts", which is the same convention every other + /// account key here follows. + QString m_startupAccount; + /// Whether startup_query came from the config rather than being the /// built-in default. Only a name the user wrote is worth reporting when /// it matches no saved query. -- cgit v1.2.3