78 lines
2.4 KiB
QML
78 lines
2.4 KiB
QML
import QtQuick
|
|
import Quickshell
|
|
import Quickshell.Hyprland
|
|
import "../../../colors"
|
|
import "../../../config"
|
|
|
|
Rectangle { //workspace
|
|
id: timeAnchore
|
|
width: dateTimer.running ? Math.max(dateDisplay.width + timeDisplay.width + Config.spacing*3, bar.height) : Math.max(dateDisplay.width + timeDisplay.width + Config.spacing*2, bar.height)
|
|
height: bar.height
|
|
radius: Config.radius
|
|
color: Colors.primaryContainer
|
|
border.color: Colors.primaryContainer_fg
|
|
border.width: Config.border_width
|
|
MouseArea {
|
|
hoverEnabled: true
|
|
cursorShape: Qt.PointingHandCursor
|
|
anchors.fill: parent
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
|
|
|
|
Row {
|
|
id: row
|
|
spacing: Config.spacing
|
|
anchors.centerIn: parent
|
|
|
|
Text {
|
|
id: dateDisplay
|
|
property string currentDate: ""
|
|
|
|
text: currentDate
|
|
color: Colors.primary
|
|
font.pixelSize: Math.floor(bar.height/2)
|
|
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, "ddd, dd.MM.yyyy -")
|
|
}
|
|
}
|
|
}
|
|
|
|
Text {
|
|
id: timeDisplay
|
|
property string currentTime: ""
|
|
|
|
text: currentTime
|
|
color: Colors.primary
|
|
font.pixelSize: Math.floor(bar.height/2)
|
|
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;
|
|
}
|
|
}
|
|
} |