Added date when you click on clock

This commit is contained in:
Hannes
2026-03-01 18:45:13 +01:00
parent 0bfc7161d8
commit 309a0d1219
+57 -18
View File
@@ -4,34 +4,73 @@ import Quickshell.Hyprland
import "../../../colors" import "../../../colors"
Rectangle { //workspace Rectangle { //workspace
width: timeDisplay.width + 16 width: timeDisplay.width + 8 + dateDisplay.width + 16
height: timeDisplay.height + 16 height: timeDisplay.height + 16
radius: 4 radius: 4
color: Colors.primaryContainer color: Colors.primaryContainer
border.color: Colors.primaryContainer_fg border.color: Colors.primaryContainer_fg
border.width: 2 border.width: 2
MouseArea {
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
Text { Row {
id: timeDisplay id: row
spacing: 8
anchors.centerIn: parent
property string currentTime: "" Text {
id: dateDisplay
property string currentDate: ""
text: currentTime text: currentDate
color: Colors.primary color: Colors.primary
font.pixelSize: 18 font.pixelSize: 18
font.family: "Inter, sans-serif" font.family: "Inter, sans-serif"
anchors.centerIn: parent Timer {
id: dateTimer
//Update time every second interval: 60000
Timer { running: false
interval: 1000 repeat: true
running: true triggeredOnStart: true
repeat: true onTriggered: {
onTriggered: { var now = new Date()
var now = new Date() dateDisplay.currentDate = Qt.formatDate(now, "dd.MM.yyyy")
timeDisplay.currentTime = Qt.formatTime(now, "hh:mm:ss") }
}
} }
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;
} }
} }
} }