aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-09-24 16:38:45 +0200
committerDanilo M. <danix@danix.xyz>2026-09-24 16:38:45 +0200
commit0ac517403ead1135bc5fe0e05c2b8b00382052ae (patch)
tree0112695473880aa173d5eb49928f15e23ce6e8f0 /src
parent4818cf555141d83b0d8414c86c3b7aef26286dd3 (diff)
downloadqtmaildir-0ac517403ead1135bc5fe0e05c2b8b00382052ae.tar.gz
qtmaildir-0ac517403ead1135bc5fe0e05c2b8b00382052ae.zip
feat: read the calendar's config keys
Diffstat (limited to 'src')
-rw-r--r--src/config.cpp36
-rw-r--r--src/config.h14
2 files changed, 50 insertions, 0 deletions
diff --git a/src/config.cpp b/src/config.cpp
index 3cd842b..23c08f7 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -272,6 +272,42 @@ void Config::load(const QString &path)
}
}
+ // Item 206. The same shape as contacts_dir: absent or blank is the feature
+ // off, silently; set and missing is reported and kept, since a vdirsyncer
+ // target may not exist before its first run.
+ const QString calendarsDir =
+ settings.value(QStringLiteral("calendars_dir")).toString().trimmed();
+ if (!calendarsDir.isEmpty()) {
+ m_calendarsDir = expandTilde(calendarsDir);
+ if (!QFileInfo::exists(m_calendarsDir)) {
+ addProblem(tr("Calendars directory '%1' does not exist; the "
+ "calendar will be empty.").arg(m_calendarsDir));
+ }
+ }
+ m_defaultCalendar =
+ settings.value(QStringLiteral("default_calendar")).toString().trimmed();
+
+ // An unquoted value holding a comma reaches here as a QStringList, whose
+ // toString() is empty; join it back rather than silently losing the
+ // command. Absent keeps the default; present and blank disables.
+ const QVariant calSync = settings.value(QStringLiteral("calendar_sync_command"));
+ if (calSync.isValid()) {
+ m_calendarSyncCommand = calSync.typeId() == QMetaType::QStringList
+ ? calSync.toStringList().join(QLatin1Char(','))
+ : calSync.toString();
+ m_calendarSyncCommand = m_calendarSyncCommand.trimmed();
+ }
+ const QVariant calDelay = settings.value(QStringLiteral("calendar_sync_delay_ms"));
+ if (calDelay.isValid()) {
+ bool ok = false;
+ const int value = calDelay.toString().toInt(&ok);
+ if (ok && value >= 0)
+ m_calendarSyncDelayMs = value;
+ else
+ addProblem(tr("Calendar sync delay '%1' is not a number; using the default.")
+ .arg(calDelay.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 is enforced by MessageView::clampZoom(), the one place that
diff --git a/src/config.h b/src/config.h
index c6f1cae..f50ff38 100644
--- a/src/config.h
+++ b/src/config.h
@@ -417,6 +417,15 @@ public:
/// is simply the feature being off rather than a misconfiguration.
QString contactsDir() const { return m_contactsDir; }
+ /// The vdirsyncer calendar root (item 206). Empty: the calendar is off.
+ QString calendarsDir() const { return m_calendarsDir; }
+ /// Directory name of the collection new events go to; empty means the
+ /// first collection by display name.
+ QString defaultCalendar() const { return m_defaultCalendar; }
+ /// Run after calendar writes. Empty: no sync.
+ QString calendarSyncCommand() const { return m_calendarSyncCommand; }
+ int calendarSyncDelayMs() const { return m_calendarSyncDelayMs; }
+
/// Matches every configured account's sent mail, or empty when no account
/// configures one.
///
@@ -592,6 +601,11 @@ private:
int m_toolbarIconSize = 24;
QString m_notmuchConfig;
QString m_contactsDir;
+ QString m_calendarsDir;
+ QString m_defaultCalendar;
+ QString m_calendarSyncCommand =
+ QStringLiteral("flock -w 60 /tmp/vdirsyncer.lock vdirsyncer sync calendars");
+ int m_calendarSyncDelayMs = 2000;
QString m_dateFormat;
QStringList m_forwardPrefixes;
QString m_language;