Added date when you click on clock
This commit is contained in:
@@ -4,16 +4,47 @@ 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: dateDisplay
|
||||
property string currentDate: ""
|
||||
|
||||
text: currentDate
|
||||
color: Colors.primary
|
||||
font.pixelSize: 18
|
||||
font.family: "Inter, sans-serif"
|
||||
|
||||
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
|
||||
@@ -21,9 +52,11 @@ Rectangle { //workspace
|
||||
font.pixelSize: 18
|
||||
font.family: "Inter, sans-serif"
|
||||
|
||||
anchors.centerIn: parent
|
||||
Component.onCompleted: {
|
||||
var now = new Date()
|
||||
currentTime = Qt.formatTime(now, "hh:mm:ss")
|
||||
}
|
||||
|
||||
//Update time every second
|
||||
Timer {
|
||||
interval: 1000
|
||||
running: true
|
||||
@@ -34,4 +67,10 @@ Rectangle { //workspace
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
onClicked: {
|
||||
dateDisplay.currentDate = "";
|
||||
dateTimer.running = !dateTimer.running;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user