summaryrefslogtreecommitdiffstats
path: root/src/config.cpp
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-08-03 16:33:13 +0200
committerDanilo M. <danix@danix.xyz>2026-08-03 16:33:13 +0200
commitea90e69d5e974960c653e65a5bb9ca1359f2d52c (patch)
tree87410a035212f0e8e5997722662803c17a3320d8 /src/config.cpp
parentec390fb46e1a36d8406dde487228bbb0f348a20a (diff)
parent2c33529fb665cb54c31e54230fcb7b2491cf8565 (diff)
downloadqtmaildir-ea90e69d5e974960c653e65a5bb9ca1359f2d52c.tar.gz
qtmaildir-ea90e69d5e974960c653e65a5bb9ca1359f2d52c.zip
Merge branch 'feature/ui-state-persistence'
Persistence cluster from the post-0.1.0 usability backlog: window, splitter and column geometry survive restart, the message pane owns its zoom and remembers it, and the startup query is chosen by name instead of by alphabetical accident. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'src/config.cpp')
-rw-r--r--src/config.cpp62
1 files changed, 61 insertions, 1 deletions
diff --git a/src/config.cpp b/src/config.cpp
index f21bba9..e92c7f3 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -52,8 +52,40 @@ void Config::load(const QString &path)
{
QSettings settings(path, QSettings::IniFormat);
+ // Keys of [general] are read WITHOUT the "general/" prefix. QSettings'
+ // INI backend treats a section literally named [general] as its own
+ // fallback section and strips the prefix, so "general/notmuch_config"
+ // never matches anything, in any section arrangement (verified on
+ // Qt 6.11). The file still reads as [general] to the user; only the
+ // lookup differs. Same family of trap as the [account.work] dot and the
+ // childKeys() ordering already documented in CLAUDE.md.
m_notmuchConfig =
- settings.value(QStringLiteral("general/notmuch_config")).toString();
+ settings.value(QStringLiteral("notmuch_config")).toString();
+
+ // Absent is fine and silent: the default is 1.0. Present but unparseable
+ // is a problem, since the user asked for something and is not getting it.
+ // The range check lives in MessageView::clampZoom(), the one place that
+ // knows what the web view can render.
+ // Empty is treated as unset rather than as "a query named nothing".
+ const QString startup =
+ settings.value(QStringLiteral("startup_query")).toString().trimmed();
+ if (!startup.isEmpty()) {
+ m_startupQuery = startup;
+ m_startupQueryWasSet = true;
+ }
+
+ const QVariant zoom = settings.value(QStringLiteral("message_zoom"));
+ if (zoom.isValid()) {
+ bool ok = false;
+ const double value = zoom.toString().toDouble(&ok);
+ if (ok) {
+ m_messageZoom = value;
+ } else {
+ addProblem(QStringLiteral("Message zoom '%1' is not a number; "
+ "using the default.")
+ .arg(zoom.toString()));
+ }
+ }
m_syncCommand = settings.value(QStringLiteral("sync/command")).toString();
if (m_syncCommand.isEmpty()) {
@@ -125,6 +157,34 @@ void Config::load(const QString &path)
for (const QString &name : settings.childKeys())
m_savedQueries.append({ name, settings.value(name).toString() });
settings.endGroup();
+
+ // Checked here rather than where startup_query is read: [queries] is not
+ // parsed until now. Only a name the user actually wrote is worth a
+ // problem; the built-in default naming a query they never created is not
+ // something they got wrong.
+ if (m_startupQueryWasSet && !m_savedQueries.isEmpty()
+ && startupSavedQuery().name.compare(m_startupQuery,
+ Qt::CaseInsensitive) != 0) {
+ addProblem(QStringLiteral("Startup query '%1' is not a saved query; "
+ "opening '%2' instead.")
+ .arg(m_startupQuery, startupSavedQuery().name));
+ }
+}
+
+SavedQuery Config::startupSavedQuery() const
+{
+ if (m_savedQueries.isEmpty())
+ return {};
+
+ for (const SavedQuery &query : m_savedQueries) {
+ if (query.name.compare(m_startupQuery, Qt::CaseInsensitive) == 0)
+ return query;
+ }
+
+ // Named a query that does not exist. Not worth a warning: the default is
+ // a name the user never wrote, so an install with no [queries] Unread
+ // entry would warn on every launch about a key it never set.
+ return m_savedQueries.first();
}
Account Config::account(const QString &key) const