aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/island/calendar/EventEditor.qml
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-13 09:17:23 +0100
committerDanilo M. <danix@danix.xyz>2026-11-13 09:17:23 +0100
commit9c47ad7c10aa5a04de738a5d41acc01cc0e5e059 (patch)
tree98ad93b89243f776aab782e35419a2ad7b8ee736 /desktop/island/calendar/EventEditor.qml
parentfda4e7847bb5dc985404269c81400eead52b0181 (diff)
downloadquickshell-9c47ad7c10aa5a04de738a5d41acc01cc0e5e059.tar.gz
quickshell-9c47ad7c10aa5a04de738a5d41acc01cc0e5e059.zip
feat(calendar): click-to-pick event times, loose time typing
The month grid was already the editor's date picker, but times could only be typed or wheeled. While a time field has focus the month now gives way to an hour grid and a :00/:15/:30/:45 row: an hour keeps the minutes, a minute moves on from start to end, then out of the fields. The picker replaces the grid rather than growing the editor, because the island's layer surface is a fixed 480px and the editor nearly fills it. The field keeps focus throughout, so typing and the wheel still work. Typed times are normalised: "9.30", "9:30", "930", "9" and "14h15" become HH:MM on leaving the field and again in toPayload, instead of failing with "Times are HH:MM". Impossible values still fail, unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'desktop/island/calendar/EventEditor.qml')
-rw-r--r--desktop/island/calendar/EventEditor.qml28
1 files changed, 24 insertions, 4 deletions
diff --git a/desktop/island/calendar/EventEditor.qml b/desktop/island/calendar/EventEditor.qml
index 510c844..41815e3 100644
--- a/desktop/island/calendar/EventEditor.qml
+++ b/desktop/island/calendar/EventEditor.qml
@@ -24,6 +24,10 @@ Column {
property bool confirmDelete: false
property bool busy: false
property string err: ""
+ // The time field with focus, if any: the panel swaps the month for an
+ // hour and minute picker while one has it.
+ readonly property string timeField: startTime.input.activeFocus ? "startTime"
+ : endTime.input.activeFocus ? "endTime" : ""
signal done()
@@ -49,6 +53,22 @@ Column {
ed.draft = d;
}
+ function setTime(key, value) {
+ (key === "startTime" ? startTime : endTime).input.text = value;
+ ed.set(key, value);
+ }
+
+ // A click in the time picker: an hour keeps the minutes, a minute keeps
+ // the hour and moves on, start to end, end out of the fields.
+ function pickTime(h, m) {
+ const key = ed.timeField;
+ if (!key) return;
+ const cur = Cal.normTime(ed.draft[key]);
+ const old = Cal.validTime(cur) ? cur : "09:00";
+ ed.setTime(key, (h !== null ? Cal.pad(h) : old.slice(0, 2)) + ":" + (m !== null ? m : old.slice(3, 5)));
+ if (m !== null) (key === "startTime" ? endTime.input : ed).forceActiveFocus();
+ }
+
function pick(day, shift) {
if (ed.pickUntil) {
ed.set("until", day);
@@ -176,6 +196,7 @@ Column {
width: 62
visible: !ed.draft.allDay
input.onTextEdited: ed.set("startTime", input.text)
+ input.onEditingFinished: if (Cal.normTime(input.text) !== input.text) ed.setTime("startTime", Cal.normTime(input.text))
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.NoButton
@@ -183,8 +204,7 @@ Column {
onWheel: wheel => {
acc += wheel.angleDelta.y;
if (Math.abs(acc) < 120) return;
- parent.input.text = Cal.stepTime(parent.input.text, acc > 0 ? 15 : -15);
- ed.set("startTime", parent.input.text);
+ ed.setTime("startTime", Cal.stepTime(parent.input.text, acc > 0 ? 15 : -15));
acc = 0;
}
}
@@ -200,6 +220,7 @@ Column {
width: 62
visible: !ed.draft.allDay
input.onTextEdited: ed.set("endTime", input.text)
+ input.onEditingFinished: if (Cal.normTime(input.text) !== input.text) ed.setTime("endTime", Cal.normTime(input.text))
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.NoButton
@@ -207,8 +228,7 @@ Column {
onWheel: wheel => {
acc += wheel.angleDelta.y;
if (Math.abs(acc) < 120) return;
- parent.input.text = Cal.stepTime(parent.input.text, acc > 0 ? 15 : -15);
- ed.set("endTime", parent.input.text);
+ ed.setTime("endTime", Cal.stepTime(parent.input.text, acc > 0 ? 15 : -15));
acc = 0;
}
}