aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules/island/IslandCalendarModule.qml
blob: 6525d11e9e08e74877f42430a8bc31fa3b49041b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

import QtQuick
import "../.."
import "../appearance"

// The island bar's settings group, starting with the calendar's.
Module {
    id: mod
    name: "island-calendar"
    label: "Calendar"
    // nf-md-calendar, present in Inconsolata Nerd Font.
    icon: "\u{f00ed}"
    settings: true
    group: "Island bar"
    keywords: ["island", "calendar", "event", "length", "duration", "end time"]
    searchItems: [{ text: "Default event length", key: "eventMinutes" }]

    // The draft, as typed; dirty while it differs from what is saved.
    property string draft: String(Prefs.island.eventMinutes)
    readonly property bool valid: /^\d+$/.test(draft) && +draft >= 5 && +draft <= 1440
    dirty: draft !== String(Prefs.island.eventMinutes)
    function refresh() { if (!mod.dirty) mod.draft = String(Prefs.island.eventMinutes); }

    page: Component {
        Page {
            title: "Calendar"
            actions: Component {
                SaveBar {
                    dirty: mod.dirty; valid: mod.valid
                    error: mod.valid ? "" : "Length is 5 to 1440 minutes."
                    onSave: Prefs.setIsland({ eventMinutes: +mod.draft })
                    onDiscard: mod.draft = String(Prefs.island.eventMinutes)
                }
            }
            Column {
                objectName: "eventMinutes"
                width: parent.width
                spacing: 8
                Row {
                    spacing: 8
                    Text {
                        anchors.verticalCenter: parent.verticalCenter
                        text: "Default event length"
                        color: Theme.subtext
                        font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 3 }
                    }
                    // Read on every change: a click on Save ends no editing.
                    Field { width: 60; value: mod.draft; onValueChanged: mod.draft = value }
                    Text {
                        anchors.verticalCenter: parent.verticalCenter
                        text: "minutes"
                        color: Theme.subtext
                        font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 3 }
                    }
                }
                Text {
                    width: parent.width
                    wrapMode: Text.WordWrap
                    text: "A new event gets this length, and its end keeps it when the start moves."
                    color: Theme.overlay
                    font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
                }
            }
        }
    }
}