aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/island/calendar/CalendarPanel.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/CalendarPanel.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/CalendarPanel.qml')
-rw-r--r--desktop/island/calendar/CalendarPanel.qml66
1 files changed, 65 insertions, 1 deletions
diff --git a/desktop/island/calendar/CalendarPanel.qml b/desktop/island/calendar/CalendarPanel.qml
index 7d42f7d..4a0a011 100644
--- a/desktop/island/calendar/CalendarPanel.qml
+++ b/desktop/island/calendar/CalendarPanel.qml
@@ -31,6 +31,7 @@ Item {
readonly property var cells: Cal.monthCells(viewY, viewM0)
readonly property real gridWidth: 252
+ readonly property bool pickingTime: panel.editing && editor.timeField !== ""
implicitHeight: Math.max(left.implicitHeight, right.implicitHeight)
@@ -113,12 +114,14 @@ Item {
Text {
anchors.verticalCenter: parent.verticalCenter
- text: Qt.locale().standaloneMonthName(panel.viewM0) + " " + panel.viewY
+ text: panel.pickingTime ? (editor.timeField === "startTime" ? "Start" : "End") + " time"
+ : Qt.locale().standaloneMonthName(panel.viewM0) + " " + panel.viewY
color: Theme.text
font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2; bold: true }
}
Row {
anchors { right: parent.right; verticalCenter: parent.verticalCenter }
+ visible: !panel.pickingTime
spacing: 12
Repeater {
model: [{ t: "‹", n: -1 }, { t: "›", n: 1 }]
@@ -140,6 +143,7 @@ Item {
Grid {
columns: 7
spacing: 2
+ visible: !panel.pickingTime
Repeater {
model: [0, 1, 2, 3, 4, 5, 6]
@@ -208,6 +212,66 @@ Item {
}
}
}
+ // While a time field has focus: hours, then minutes. Typing still
+ // works, the field keeps the focus.
+ Grid {
+ id: hours
+ readonly property string cur: panel.pickingTime ? Cal.normTime(editor.draft[editor.timeField]) : ""
+ visible: panel.pickingTime
+ columns: 6
+ spacing: 2
+
+ Repeater {
+ model: 24
+ delegate: TimeCell {
+ required property int index
+ width: (panel.gridWidth - 10) / 6
+ label: Cal.pad(index)
+ on: hours.cur.slice(0, 3) === label + ":"
+ onClicked: editor.pickTime(index, null)
+ }
+ }
+ }
+ Row {
+ id: minutes
+ readonly property string cur: panel.pickingTime ? Cal.normTime(editor.draft[editor.timeField]) : ""
+ visible: panel.pickingTime
+ spacing: 2
+
+ Repeater {
+ model: ["00", "15", "30", "45"]
+ delegate: TimeCell {
+ required property string modelData
+ width: (panel.gridWidth - 6) / 4
+ label: ":" + modelData
+ on: minutes.cur.slice(2) === label
+ onClicked: editor.pickTime(null, modelData)
+ }
+ }
+ }
+ }
+
+ component TimeCell: Rectangle {
+ property string label: ""
+ property bool on: false
+ signal clicked()
+ height: 32
+ radius: 8
+ color: on ? Qt.alpha(Theme.accent, 0.35)
+ : cellHover.containsMouse ? Qt.alpha(Theme.surface, 0.8) : "transparent"
+ Text {
+ anchors.centerIn: parent
+ text: parent.label
+ color: Theme.text
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
+ }
+ MouseArea {
+ id: cellHover
+ anchors.fill: parent
+ hoverEnabled: true
+ cursorShape: Qt.PointingHandCursor
+ onClicked: parent.clicked()
+ }
}
// --- right: agenda or editor -------------------------------------------