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
+58 -19
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
Row {
id: row
spacing: 8
anchors.centerIn: parent
Text { Text {
id: timeDisplay id: dateDisplay
property string currentDate: ""
property string currentTime: "" text: currentDate
color: Colors.primary
font.pixelSize: 18
font.family: "Inter, sans-serif"
text: currentTime Timer {
color: Colors.primary id: dateTimer
font.pixelSize: 18 interval: 60000
font.family: "Inter, sans-serif" running: false
repeat: true
anchors.centerIn: parent triggeredOnStart: true
onTriggered: {
//Update time every second var now = new Date()
Timer { dateDisplay.currentDate = Qt.formatDate(now, "dd.MM.yyyy")
interval: 1000 }
running: true }
repeat: true
onTriggered: {
var now = new Date()
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;
} }
} }
} }