48 lines
1.2 KiB
QML
48 lines
1.2 KiB
QML
import QtQuick
|
|
import "../components"
|
|
|
|
Item {
|
|
id: root
|
|
|
|
signal clicked
|
|
|
|
implicitWidth: timeLabel.implicitWidth + 16
|
|
implicitHeight: 24
|
|
|
|
property var now: new Date()
|
|
|
|
Timer {
|
|
interval: 1000
|
|
running: true
|
|
repeat: true
|
|
onTriggered: root.now = new Date()
|
|
}
|
|
|
|
readonly property string display: {
|
|
const d = now
|
|
const days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
|
|
const dd = String(d.getDate()).padStart(2, "0")
|
|
const mm = String(d.getMonth() + 1).padStart(2, "0")
|
|
const yyyy = d.getFullYear()
|
|
const h = String(d.getHours()).padStart(2, "0")
|
|
const m = String(d.getMinutes()).padStart(2, "0")
|
|
const s = String(d.getSeconds()).padStart(2, "0")
|
|
return days[d.getDay()] + " " + dd + "." + mm + "." + yyyy + " " + h + ":" + m + ":" + s
|
|
}
|
|
|
|
Text {
|
|
id: timeLabel
|
|
anchors.centerIn: parent
|
|
text: root.display
|
|
color: Theme.text
|
|
font.pixelSize: 12
|
|
font.family: "JetBrainsMono Nerd Font Mono"
|
|
}
|
|
|
|
MouseArea {
|
|
anchors.fill: parent
|
|
cursorShape: Qt.PointingHandCursor
|
|
onClicked: root.clicked()
|
|
}
|
|
}
|