Added date when you click on clock
This commit is contained in:
@@ -4,16 +4,47 @@ 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 {
|
||||||
|
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 {
|
Text {
|
||||||
id: timeDisplay
|
id: timeDisplay
|
||||||
|
|
||||||
property string currentTime: ""
|
property string currentTime: ""
|
||||||
|
|
||||||
text: currentTime
|
text: currentTime
|
||||||
@@ -21,9 +52,11 @@ Rectangle { //workspace
|
|||||||
font.pixelSize: 18
|
font.pixelSize: 18
|
||||||
font.family: "Inter, sans-serif"
|
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 {
|
Timer {
|
||||||
interval: 1000
|
interval: 1000
|
||||||
running: true
|
running: true
|
||||||
@@ -35,3 +68,9 @@ Rectangle { //workspace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
onClicked: {
|
||||||
|
dateDisplay.currentDate = "";
|
||||||
|
dateTimer.running = !dateTimer.running;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user