diff options
| author | Danilo M. <danix@danix.xyz> | 2026-08-11 10:56:40 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-08-11 10:56:40 +0200 |
| commit | 00c029a819eca601e9ac58e5c236d667505ac566 (patch) | |
| tree | 52513f0f57129b95e1533863f82be00f5eff404b /src/config.h | |
| parent | a8844303aeb9295a6f94408cd809e521483a8b9a (diff) | |
| download | qtmaildir-00c029a819eca601e9ac58e5c236d667505ac566.tar.gz qtmaildir-00c029a819eca601e9ac58e5c236d667505ac566.zip | |
feat(config): let the date format on a card be configured
Adds [general] date_format, a QDateTime pattern for the date a thread card
shows. Absent or empty means the system locale's short format, which is what
every other application on the desktop uses and stays the default.
The format reaches the LAYOUT, not only the painter. CardLayout::compute()
reserves the date's width from widestDateSample(), so a pattern that arrived
only at the drawText call would be elided into a rect sized for the old
format, which is the clipping the bold-font fault already produced once. It
rides on CardLayout::Input and defaults to an empty string, leaving every
existing call site unchanged. Confirmed by mutation: making the width ignore
the format fails the test.
widestDateSample() memoised its result in a static, which would have sized
every format after the first from whichever arrived first. It is a plain call
now, costing one QLocale lookup per row, the same as formatting the date.
Validation rejects only a pattern whose output is CONSTANT, found by
formatting two different instants and comparing. QDateTime::toString() treats
nearly every letter as a field, so "banana" formats as "bpmnpmnpm" and
"hello" as "22ello": nonsense, but they vary with the instant, and a check
claiming to find "no date field" cannot reject them. What harms the user is
the pattern that prints the same text on every card, and that is what is
refused, with the value named in the message.
The model supplies the pattern through DateFormatRole for the same reason it
supplies the tag colours: it is the one object here holding config, and a
delegate reading config itself would be a second source of truth.
Backlog item 62.
Diffstat (limited to 'src/config.h')
| -rw-r--r-- | src/config.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/config.h b/src/config.h index 3dd9011..bcbfb34 100644 --- a/src/config.h +++ b/src/config.h @@ -114,6 +114,16 @@ public: /// Optional alternate notmuch config file. Empty means "let notmuch decide". QString notmuchConfig() const { return m_notmuchConfig; } + /// A QDateTime::toString() pattern for the date on a card, or empty for the + /// system locale's short format. + /// + /// Empty is both the default and what an unusable pattern falls back to, so + /// a caller never has to distinguish "unset" from "rejected": either way + /// the locale decides. Validated at load, because toString() with a pattern + /// carrying no date field returns the pattern verbatim, which would print + /// the same fixed string on every card rather than failing visibly. + QString dateFormat() const { return m_dateFormat; } + /// The saved query to open at startup, by name. Falls back to "Unread" /// when unset, and to the first saved query when no query by that name /// exists: [queries] is read through childKeys(), which sorts @@ -185,6 +195,7 @@ private: QString m_syncLog; int m_toolbarIconSize = 24; QString m_notmuchConfig; + QString m_dateFormat; qreal m_messageZoom = 1.0; bool m_completionOnFocus = false; int m_markReadDelayMs = 2000; |
