diff options
| author | Gregor Kleen <gkleen@yggdrasil.li> | 2025-08-31 12:12:23 +0200 |
|---|---|---|
| committer | Gregor Kleen <gkleen@yggdrasil.li> | 2025-08-31 12:12:23 +0200 |
| commit | 9fc966ff7726d01267a6220483fb005c0efaa9c0 (patch) | |
| tree | 9e66f32774a55a7f51314883648bd40751250091 /accounts/gkleen@sif/shell/quickshell/Clock.qml | |
| parent | 97423da1a1e58a2820d12bed5b36f0896fd3cccc (diff) | |
| download | nixos-9fc966ff7726d01267a6220483fb005c0efaa9c0.tar nixos-9fc966ff7726d01267a6220483fb005c0efaa9c0.tar.gz nixos-9fc966ff7726d01267a6220483fb005c0efaa9c0.tar.bz2 nixos-9fc966ff7726d01267a6220483fb005c0efaa9c0.tar.xz nixos-9fc966ff7726d01267a6220483fb005c0efaa9c0.zip | |
...
Diffstat (limited to 'accounts/gkleen@sif/shell/quickshell/Clock.qml')
| -rw-r--r-- | accounts/gkleen@sif/shell/quickshell/Clock.qml | 186 |
1 files changed, 186 insertions, 0 deletions
diff --git a/accounts/gkleen@sif/shell/quickshell/Clock.qml b/accounts/gkleen@sif/shell/quickshell/Clock.qml new file mode 100644 index 00000000..56f8d41f --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/Clock.qml | |||
| @@ -0,0 +1,186 @@ | |||
| 1 | import QtQml | ||
| 2 | import QtQuick | ||
| 3 | import Quickshell | ||
| 4 | import Custom as Custom | ||
| 5 | import QtQuick.Controls | ||
| 6 | import QtQuick.Layouts | ||
| 7 | |||
| 8 | Item { | ||
| 9 | width: clock.contentWidth | ||
| 10 | height: parent.height | ||
| 11 | anchors.verticalCenter: parent.verticalCenter | ||
| 12 | |||
| 13 | MouseArea { | ||
| 14 | id: clockMouseArea | ||
| 15 | |||
| 16 | anchors.fill: parent | ||
| 17 | hoverEnabled: true | ||
| 18 | enabled: true | ||
| 19 | } | ||
| 20 | |||
| 21 | Text { | ||
| 22 | id: clock | ||
| 23 | color: "white" | ||
| 24 | |||
| 25 | anchors.verticalCenter: parent.verticalCenter | ||
| 26 | |||
| 27 | Custom.Chrono { | ||
| 28 | id: chrono | ||
| 29 | format: "W{0:%V-%u} {0:%F} {0:%H:%M:%S%Ez}" | ||
| 30 | } | ||
| 31 | |||
| 32 | text: chrono.date | ||
| 33 | |||
| 34 | font.pointSize: 10 | ||
| 35 | font.family: "Fira Sans" | ||
| 36 | font.features: { "tnum": 1 } | ||
| 37 | } | ||
| 38 | |||
| 39 | PopupWindow { | ||
| 40 | anchor { | ||
| 41 | item: clockMouseArea | ||
| 42 | edges: Edges.Bottom | ||
| 43 | } | ||
| 44 | visible: clockMouseArea.containsMouse | ||
| 45 | |||
| 46 | implicitWidth: yearCalendar.implicitWidth + 16 | ||
| 47 | implicitHeight: yearCalendar.implicitHeight + 16 | ||
| 48 | color: "black" | ||
| 49 | |||
| 50 | GridLayout { | ||
| 51 | property int year: { const d = new Date(); return d.getFullYear(); } | ||
| 52 | |||
| 53 | id: yearCalendar | ||
| 54 | |||
| 55 | columns: 3 | ||
| 56 | columnSpacing: 16 | ||
| 57 | rowSpacing: 16 | ||
| 58 | |||
| 59 | anchors.centerIn: parent | ||
| 60 | |||
| 61 | Repeater { | ||
| 62 | model: 12 | ||
| 63 | |||
| 64 | Column { | ||
| 65 | required property int index | ||
| 66 | property int month: index | ||
| 67 | |||
| 68 | id: monthCalendar | ||
| 69 | |||
| 70 | width: parent.width | ||
| 71 | |||
| 72 | Layout.alignment: Qt.AlignTop | Qt.AlignRight | ||
| 73 | |||
| 74 | Text { | ||
| 75 | width: parent.width | ||
| 76 | |||
| 77 | horizontalAlignment: Text.AlignHCenter | ||
| 78 | |||
| 79 | font.pointSize: 10 | ||
| 80 | font.family: "Fira Sans" | ||
| 81 | |||
| 82 | text: { | ||
| 83 | const date = Date.fromLocaleDateString(Qt.locale(), `${yearCalendar.year}-${monthCalendar.month + 1}-01`, "yyyy-M-dd"); | ||
| 84 | return date.toLocaleString(Qt.locale("en_DK"), "MMMM") | ||
| 85 | } | ||
| 86 | |||
| 87 | color: "#ffead3" | ||
| 88 | } | ||
| 89 | |||
| 90 | GridLayout { | ||
| 91 | columns: 2 | ||
| 92 | |||
| 93 | DayOfWeekRow { | ||
| 94 | locale: grid.locale | ||
| 95 | |||
| 96 | Layout.column: 1 | ||
| 97 | Layout.fillWidth: true | ||
| 98 | |||
| 99 | delegate: Text { | ||
| 100 | required property string shortName | ||
| 101 | |||
| 102 | font.pointSize: 10 | ||
| 103 | font.family: "Fira Mono" | ||
| 104 | |||
| 105 | text: shortName | ||
| 106 | color: "#ffcc66" | ||
| 107 | |||
| 108 | horizontalAlignment: Text.AlignRight | ||
| 109 | verticalAlignment: Text.AlignVCenter | ||
| 110 | } | ||
| 111 | } | ||
| 112 | |||
| 113 | WeekNumberColumn { | ||
| 114 | month: grid.month | ||
| 115 | year: grid.year | ||
| 116 | locale: grid.locale | ||
| 117 | |||
| 118 | Layout.fillHeight: true | ||
| 119 | |||
| 120 | delegate: Text { | ||
| 121 | required property int weekNumber | ||
| 122 | |||
| 123 | opacity: { | ||
| 124 | const simple = new Date(weekNumber == 1 && monthCalendar.month == 12 ? yearCalendar.year + 1 : yearCalendar.year, 0, 1 + (weekNumber - 1) * 7); | ||
| 125 | const dayOfWeek = simple.getDay(); | ||
| 126 | const isoWeekStart = simple; | ||
| 127 | |||
| 128 | isoWeekStart.setDate(simple.getDate() - dayOfWeek + 1); | ||
| 129 | if (dayOfWeek > 4) { | ||
| 130 | isoWeekStart.setDate(isoWeekStart.getDate() + 7); | ||
| 131 | } | ||
| 132 | |||
| 133 | for (let i = 0; i < 7; i++) { | ||
| 134 | const dayInWeek = isoWeekStart; | ||
| 135 | dayInWeek.setDate(dayInWeek.getDate() + i); | ||
| 136 | if (dayInWeek.getMonth() == monthCalendar.month) | ||
| 137 | return 1; | ||
| 138 | } | ||
| 139 | |||
| 140 | return 0; | ||
| 141 | } | ||
| 142 | |||
| 143 | font.pointSize: 10 | ||
| 144 | font.family: "Fira Sans" | ||
| 145 | font.features: { "tnum": 1 } | ||
| 146 | |||
| 147 | text: weekNumber | ||
| 148 | color: "#99ffdd" | ||
| 149 | |||
| 150 | horizontalAlignment: Text.AlignRight | ||
| 151 | verticalAlignment: Text.AlignVCenter | ||
| 152 | } | ||
| 153 | } | ||
| 154 | |||
| 155 | MonthGrid { | ||
| 156 | id: grid | ||
| 157 | |||
| 158 | year: yearCalendar.year | ||
| 159 | month: monthCalendar.month | ||
| 160 | locale: Qt.locale("en_DK") | ||
| 161 | |||
| 162 | Layout.fillWidth: true | ||
| 163 | Layout.fillHeight: true | ||
| 164 | |||
| 165 | delegate: Text { | ||
| 166 | required property var model | ||
| 167 | |||
| 168 | opacity: model.month === monthCalendar.month ? 1 : 0 | ||
| 169 | |||
| 170 | font.pointSize: 10 | ||
| 171 | font.family: "Fira Sans" | ||
| 172 | font.features: { "tnum": 1 } | ||
| 173 | |||
| 174 | text: model.day | ||
| 175 | color: model.today ? "#ff6699" : "white" | ||
| 176 | |||
| 177 | horizontalAlignment: Text.AlignRight | ||
| 178 | verticalAlignment: Text.AlignVCenter | ||
| 179 | } | ||
| 180 | } | ||
| 181 | } | ||
| 182 | } | ||
| 183 | } | ||
| 184 | } | ||
| 185 | } | ||
| 186 | } \ No newline at end of file | ||
