From 9fc966ff7726d01267a6220483fb005c0efaa9c0 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 31 Aug 2025 12:12:23 +0200 Subject: ... --- accounts/gkleen@sif/shell/quickshell/Clock.qml | 186 +++++++++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100644 accounts/gkleen@sif/shell/quickshell/Clock.qml (limited to 'accounts/gkleen@sif/shell/quickshell/Clock.qml') 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 @@ +import QtQml +import QtQuick +import Quickshell +import Custom as Custom +import QtQuick.Controls +import QtQuick.Layouts + +Item { + width: clock.contentWidth + height: parent.height + anchors.verticalCenter: parent.verticalCenter + + MouseArea { + id: clockMouseArea + + anchors.fill: parent + hoverEnabled: true + enabled: true + } + + Text { + id: clock + color: "white" + + anchors.verticalCenter: parent.verticalCenter + + Custom.Chrono { + id: chrono + format: "W{0:%V-%u} {0:%F} {0:%H:%M:%S%Ez}" + } + + text: chrono.date + + font.pointSize: 10 + font.family: "Fira Sans" + font.features: { "tnum": 1 } + } + + PopupWindow { + anchor { + item: clockMouseArea + edges: Edges.Bottom + } + visible: clockMouseArea.containsMouse + + implicitWidth: yearCalendar.implicitWidth + 16 + implicitHeight: yearCalendar.implicitHeight + 16 + color: "black" + + GridLayout { + property int year: { const d = new Date(); return d.getFullYear(); } + + id: yearCalendar + + columns: 3 + columnSpacing: 16 + rowSpacing: 16 + + anchors.centerIn: parent + + Repeater { + model: 12 + + Column { + required property int index + property int month: index + + id: monthCalendar + + width: parent.width + + Layout.alignment: Qt.AlignTop | Qt.AlignRight + + Text { + width: parent.width + + horizontalAlignment: Text.AlignHCenter + + font.pointSize: 10 + font.family: "Fira Sans" + + text: { + const date = Date.fromLocaleDateString(Qt.locale(), `${yearCalendar.year}-${monthCalendar.month + 1}-01`, "yyyy-M-dd"); + return date.toLocaleString(Qt.locale("en_DK"), "MMMM") + } + + color: "#ffead3" + } + + GridLayout { + columns: 2 + + DayOfWeekRow { + locale: grid.locale + + Layout.column: 1 + Layout.fillWidth: true + + delegate: Text { + required property string shortName + + font.pointSize: 10 + font.family: "Fira Mono" + + text: shortName + color: "#ffcc66" + + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + } + } + + WeekNumberColumn { + month: grid.month + year: grid.year + locale: grid.locale + + Layout.fillHeight: true + + delegate: Text { + required property int weekNumber + + opacity: { + const simple = new Date(weekNumber == 1 && monthCalendar.month == 12 ? yearCalendar.year + 1 : yearCalendar.year, 0, 1 + (weekNumber - 1) * 7); + const dayOfWeek = simple.getDay(); + const isoWeekStart = simple; + + isoWeekStart.setDate(simple.getDate() - dayOfWeek + 1); + if (dayOfWeek > 4) { + isoWeekStart.setDate(isoWeekStart.getDate() + 7); + } + + for (let i = 0; i < 7; i++) { + const dayInWeek = isoWeekStart; + dayInWeek.setDate(dayInWeek.getDate() + i); + if (dayInWeek.getMonth() == monthCalendar.month) + return 1; + } + + return 0; + } + + font.pointSize: 10 + font.family: "Fira Sans" + font.features: { "tnum": 1 } + + text: weekNumber + color: "#99ffdd" + + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + } + } + + MonthGrid { + id: grid + + year: yearCalendar.year + month: monthCalendar.month + locale: Qt.locale("en_DK") + + Layout.fillWidth: true + Layout.fillHeight: true + + delegate: Text { + required property var model + + opacity: model.month === monthCalendar.month ? 1 : 0 + + font.pointSize: 10 + font.family: "Fira Sans" + font.features: { "tnum": 1 } + + text: model.day + color: model.today ? "#ff6699" : "white" + + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + } + } + } + } + } + } + } +} \ No newline at end of file -- cgit v1.2.3