diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-13 19:16:33 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-13 19:16:33 +0200 |
| commit | 2623b762a90b04c57491a5d58ab72c8807c65c80 (patch) | |
| tree | 1f968dec0965300173aec0216d76330d870f6513 /src/config.cpp | |
| parent | b79b5e30efcd8de95fa42d84c6ed319a0347941c (diff) | |
| download | qtmaildir-2623b762a90b04c57491a5d58ab72c8807c65c80.tar.gz qtmaildir-2623b762a90b04c57491a5d58ab72c8807c65c80.zip | |
feat(config): per-account spam folder and queries
Diffstat (limited to 'src/config.cpp')
| -rw-r--r-- | src/config.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/config.cpp b/src/config.cpp index 0f0caf1..0fa3c85 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -158,6 +158,11 @@ QString Account::trashQuery() const return folderQuery(maildir, trash); } +QString Account::spamQuery() const +{ + return folderQuery(maildir, spam); +} + QString Account::inboxFolder() const { // Never empty: Restore needs a folder to name, and "Inbox" is both the @@ -192,6 +197,11 @@ QString Config::allTrashQuery() const return joinAccountQueries(m_accounts, &Account::trashQuery); } +QString Config::allSpamQuery() const +{ + return joinAccountQueries(m_accounts, &Account::spamQuery); +} + QString Config::defaultPath() { const QString base = @@ -528,6 +538,12 @@ void Config::load(const QString &path) account.trash = settings.value(QStringLiteral("trash")).toString().trimmed(); + // Mandatory, unlike sent: Mark spam moves a file into this folder, so + // an account without one cannot mark spam at all. Trimmed for the same + // reason as sent, above. + account.spam = + settings.value(QStringLiteral("spam")).toString().trimmed(); + // Optional, unlike trash: inboxFolder() defaults it to "Inbox", which // is right for any ordinary Maildir. Read so an account whose inbox is // named otherwise can say so, rather than having Restore create a @@ -585,6 +601,19 @@ void Config::load(const QString &path) .arg(account.key)); } + // Mandatory, unlike sent: Mark spam moves a file into this folder, so + // an account without one cannot mark spam at all. Reported rather than + // silently disabled, so the user finds out from a warning rather than + // from a Mark spam that quietly does nothing. The account still loads; + // only Mark spam is unusable. + if (account.spam.isEmpty()) { + addProblem( + tr("Account '%1' has no spam folder configured; add a " + "'spam' key to its section. Mark spam will not work for " + "this account until it does.") + .arg(account.key)); + } + m_accounts.append(account); } |
