aboutsummaryrefslogtreecommitdiffstats
path: root/src/config.cpp
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-08-15 11:00:58 +0200
committerDanilo M. <danix@danix.xyz>2026-08-15 11:00:58 +0200
commit51f04ffc3c17da59b6072c4362029c45b780de82 (patch)
tree58b9d569ecd8c1f3f4781165b4bd6f1045c44c6f /src/config.cpp
parentde0d3aaa63be2867d127304d55d34259eb6e30d6 (diff)
downloadqtmaildir-51f04ffc3c17da59b6072c4362029c45b780de82.tar.gz
qtmaildir-51f04ffc3c17da59b6072c4362029c45b780de82.zip
feat(filters): put the four built-in filters on the query row
Item 93, the UI half. Unread, Inbox, Flagged and Sent are buttons the application ships, sitting first on the row, ahead of the user's pinned saved queries. runFilter() is runSavedQuery()'s opposite in the one way that matters: it READS the account box and never writes it. That is item 90's defect. A filter narrows what the user is already looking at, so the dropdown is its input rather than something it resets on the way past. A saved query keeps setting the account from what it stored, because it is a destination and states its own scope. runQuery() gains an AccountScope parameter. A filter's text arrives already resolved in the selected account's scope, and scoping it again would put path:"work/Sent/**" inside path:"work/**". Two migration changes, both of which unpin rather than delete: - Sent is no longer migrated from the INI into queries.json. The built-in filter covers it, and migrating one too would put two Sent buttons on the row, one editable and one not. - A stored entry naming a known generator is unpinned on load, which is what every install upgraded through 0.19.0 carries. It keeps its name and its generator and moves to the menu. Deleting it would be data loss on a file whose readers are supposed to preserve what they do not own. The test suite needed the same distinction the design makes. savedQueryButtonLabels() now skips the filters, and savedQueryButton(window, label) replaces five positional row->findChild<QPushButton *>() lookups that were silently returning Unread. One rendering probe had to be fixed rather than adapted. replyRowsKeepTheirTextUnderTheThreadLine resized the window to 300px, and four more buttons pushed the reply row below the viewport: the pixel loop then ran zero times and reported "0 pixels, the row was painted over", which is a different defect from the one it exists to catch. It gets 600px and a guard asserting the row is really inside the viewport, so the next person to shrink it gets told the truth. Verified by putting 300 back: the guard names the row at 83..165 in an 82px viewport.
Diffstat (limited to 'src/config.cpp')
-rw-r--r--src/config.cpp36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/config.cpp b/src/config.cpp
index 0b65053..ece1fb9 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -482,22 +482,16 @@ void Config::loadSavedQueries(const QString &configPath, QSettings &settings)
}
settings.endGroup();
- // Sent was a hardcoded button beside the saved queries and becomes an
- // ordinary row here, so it can be reordered, renamed, unpinned or
- // removed like any other. It stays GENERATED, so it still follows the
- // accounts. Appended last, where the button already sat.
+ // Sent is NOT migrated into queries.json any more. It used to become an
+ // ordinary saved query here, so the hardcoded button could be
+ // reordered, renamed or removed; item 93 makes it one of four built-in
+ // filters instead, which are shipped rather than stored. Migrating it
+ // as well would put two Sent buttons on the row, one of them the user's
+ // to edit and one not.
//
- // Only when an account actually configures a sent folder: the button
- // was hidden entirely otherwise, and migrating a row that always finds
- // nothing would be worse than what it replaces.
- if (!allSentQuery().isEmpty()) {
- SavedQuery sent;
- sent.name = QStringLiteral("Sent");
- sent.generated = QStringLiteral("sent");
- sent.pinned = true;
- sent.flat = true;
- m_savedQueries.append(sent);
- }
+ // Nothing is lost: the built-in Sent resolves through the same
+ // generator, so it still follows the accounts, and it now composes with
+ // the account dropdown rather than resetting it.
// Order is alphabetical here because childKeys() is genuinely all the
// INI knows. The user reorders once and it sticks from then on.
@@ -585,6 +579,18 @@ void Config::loadSavedQueries(const QString &configPath, QSettings &settings)
continue;
}
+ // A stored entry naming a generator now duplicates a BUILT-IN filter of
+ // the same name, since item 93 ships all four rather than storing them.
+ // 0.19.0 migrated the hardcoded Sent button into exactly such an entry,
+ // so every existing install has one.
+ //
+ // Unpinned, never dropped: the row would otherwise carry two Sent
+ // buttons, one the user's to edit and one not. Deleting it would be
+ // data loss on a file whose readers are supposed to preserve what they
+ // do not own, and an unpin is reversible from the UI.
+ if (query.isGenerated() && isKnownGenerator(query.generated))
+ query.pinned = false;
+
for (auto it = object.begin(); it != object.end(); ++it) {
static const QStringList known = {
QStringLiteral("name"), QStringLiteral("query"),