From 309a0d12194fbeb8f469dc9086616a4fed024629 Mon Sep 17 00:00:00 2001 From: Hannes Date: Sun, 1 Mar 2026 18:45:13 +0100 Subject: [PATCH] Added date when you click on clock --- modules/bar/widgets/Clock.qml | 77 ++++++++++++++++++++++++++--------- 1 file changed, 58 insertions(+), 19 deletions(-) diff --git a/modules/bar/widgets/Clock.qml b/modules/bar/widgets/Clock.qml index 530ff9d..12d9d10 100644 --- a/modules/bar/widgets/Clock.qml +++ b/modules/bar/widgets/Clock.qml @@ -4,34 +4,73 @@ import Quickshell.Hyprland import "../../../colors" Rectangle { //workspace - width: timeDisplay.width + 16 + width: timeDisplay.width + 8 + dateDisplay.width + 16 height: timeDisplay.height + 16 radius: 4 color: Colors.primaryContainer border.color: Colors.primaryContainer_fg border.width: 2 + MouseArea { + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton + + Row { + id: row + spacing: 8 + anchors.centerIn: parent - Text { - id: timeDisplay + Text { + id: dateDisplay + property string currentDate: "" - property string currentTime: "" + text: currentDate + color: Colors.primary + font.pixelSize: 18 + font.family: "Inter, sans-serif" - text: currentTime - color: Colors.primary - font.pixelSize: 18 - font.family: "Inter, sans-serif" - - anchors.centerIn: parent - - //Update time every second - Timer { - interval: 1000 - running: true - repeat: true - onTriggered: { - var now = new Date() - timeDisplay.currentTime = Qt.formatTime(now, "hh:mm:ss") + Timer { + id: dateTimer + interval: 60000 + running: false + repeat: true + triggeredOnStart: true + onTriggered: { + var now = new Date() + dateDisplay.currentDate = Qt.formatDate(now, "dd.MM.yyyy") + } + } } + + Text { + id: timeDisplay + property string currentTime: "" + + text: currentTime + color: Colors.primary + font.pixelSize: 18 + font.family: "Inter, sans-serif" + + Component.onCompleted: { + var now = new Date() + currentTime = Qt.formatTime(now, "hh:mm:ss") + } + + Timer { + interval: 1000 + running: true + repeat: true + onTriggered: { + var now = new Date() + timeDisplay.currentTime = Qt.formatTime(now, "hh:mm:ss") + } + } + } + } + onClicked: { + dateDisplay.currentDate = ""; + dateTimer.running = !dateTimer.running; } } } \ No newline at end of file