From 48e4709eb5efd0def042fa719ca7f7cc8e2a1176 Mon Sep 17 00:00:00 2001 From: bbedward Date: Thu, 27 Aug 2026 14:57:16 -0400 Subject: [PATCH] calendar: add default task list setting for dash quick-add fixes #3134 --- quickshell/Common/SettingsData.qml | 1 + quickshell/Common/settings/SettingsSpec.js | 1 + .../Modules/Settings/TimeWeatherTab.qml | 20 ++++++++++++++ quickshell/Services/CalendarDankBackend.qml | 11 +++++++- .../translations/settings_search_index.json | 26 +++++++++++++++++++ 5 files changed, 58 insertions(+), 1 deletion(-) diff --git a/quickshell/Common/SettingsData.qml b/quickshell/Common/SettingsData.qml index 33cbf53db..8b7516362 100644 --- a/quickshell/Common/SettingsData.qml +++ b/quickshell/Common/SettingsData.qml @@ -228,6 +228,7 @@ Singleton { property int firstDayOfWeek: -1 property bool showWeekNumber: false property string calendarBackend: "auto" + property string defaultTaskCalendarId: "" property string clockFormat: "auto" readonly property bool localeUses24Hour: { const fmt = Qt.locale().timeFormat(Locale.ShortFormat).replace(/'[^']*'/g, ""); diff --git a/quickshell/Common/settings/SettingsSpec.js b/quickshell/Common/settings/SettingsSpec.js index 00be17950..47fe985b3 100644 --- a/quickshell/Common/settings/SettingsSpec.js +++ b/quickshell/Common/settings/SettingsSpec.js @@ -78,6 +78,7 @@ var SPEC = { firstDayOfWeek: { def: -1 }, showWeekNumber: { def: false }, calendarBackend: { def: "auto" }, + defaultTaskCalendarId: { def: "" }, clockFormat: { def: "auto", onChange: "markGreeterSyncPending" }, showSeconds: { def: false, onChange: "markGreeterSyncPending" }, padHours12Hour: { def: false, onChange: "markGreeterSyncPending" }, diff --git a/quickshell/Modules/Settings/TimeWeatherTab.qml b/quickshell/Modules/Settings/TimeWeatherTab.qml index 93f248dfe..a008c4ad1 100644 --- a/quickshell/Modules/Settings/TimeWeatherTab.qml +++ b/quickshell/Modules/Settings/TimeWeatherTab.qml @@ -166,6 +166,26 @@ Item { } } + SettingsDropdownRow { + tab: "time" + tags: ["calendar", "tasks", "list", "default", "caldav", "todo"] + settingKey: "defaultTaskCalendarId" + visible: CalendarService.isDankActive && _taskLists.length > 0 + text: I18n.tr("Default Task List") + description: I18n.tr("Task list used when adding tasks from the dash calendar") + readonly property var _taskLists: (CalendarService.calendars || []).filter(c => c.holdsTasks && !c.readOnly && !c.hidden) + readonly property var _labels: [I18n.tr("Auto")].concat(_taskLists.map(c => c.name)) + options: _labels + currentValue: { + const idx = _taskLists.findIndex(c => c.id === SettingsData.defaultTaskCalendarId); + return idx >= 0 ? _labels[idx + 1] : I18n.tr("Auto"); + } + onValueChanged: value => { + const idx = _labels.indexOf(value); + SettingsData.set("defaultTaskCalendarId", idx > 0 ? _taskLists[idx - 1].id : ""); + } + } + Rectangle { width: parent.width height: 1 diff --git a/quickshell/Services/CalendarDankBackend.qml b/quickshell/Services/CalendarDankBackend.qml index e2ea9b392..f4049ea8e 100644 --- a/quickshell/Services/CalendarDankBackend.qml +++ b/quickshell/Services/CalendarDankBackend.qml @@ -573,7 +573,16 @@ Item { function defaultTaskCalendar() { const writable = taskCalendars().filter(c => !c.hidden); - return writable.length > 0 ? writable[0] : null; + if (writable.length === 0) + return null; + const preferred = SettingsData.defaultTaskCalendarId; + if (preferred) { + for (let i = 0; i < writable.length; i++) { + if (writable[i].id === preferred) + return writable[i]; + } + } + return writable[0]; } function _taskAsEvent(t) { diff --git a/quickshell/translations/settings_search_index.json b/quickshell/translations/settings_search_index.json index 28d1345d2..3ca29ca76 100644 --- a/quickshell/translations/settings_search_index.json +++ b/quickshell/translations/settings_search_index.json @@ -494,6 +494,32 @@ ], "icon": "calendar_today" }, + { + "section": "defaultTaskCalendarId", + "label": "Default Task List", + "tabIndex": 1, + "category": "Time & Weather", + "keywords": [ + "adding", + "caldav", + "calendar", + "clock", + "dash", + "date", + "day", + "default", + "forecast", + "list", + "month", + "task", + "tasks", + "time", + "todo", + "weather", + "year" + ], + "description": "Task list used when adding tasks from the dash calendar" + }, { "section": "weatherEnabled", "label": "Enable Weather",