import QtQuick import Quickshell import Quickshell.Hyprland import "../../../config" Rectangle { //workspace id: clockRect width: dateTimer.running ? Math.max(dateText.width + timeText.width + Config.spacing_fun(height)*3, bar.height) : Math.max(dateText.width + timeText.width + Config.spacing_fun(height)*2, bar.height) height: bar.height radius: Config.radius_fun(height) color: clockArea.containsMouse ? Colors.tertiaryContainer : Colors.primaryContainer border.color: ( clockArea.containsMouse ? Colors.tertiaryContainer_fg : Colors.primaryContainer_fg ) border.width: Config.border_width MouseArea { id: clockArea hoverEnabled: true cursorShape: Qt.PointingHandCursor anchors.fill: parent acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton onClicked: { dateTimer.running = !dateTimer.running if (!dateTimer.running) dateText.currentDate = "" console.log("[Clock] Date visible: " + dateTimer.running) } Row { anchors.centerIn: parent Text { id: dateText property string currentDate: "" text: currentDate color: ( clockArea.containsMouse ? Colors.tertiary : Colors.primary ) font.pixelSize: Config.font_size_small(clockRect.height) font.family: Config.font Timer { id: dateTimer interval: Config.reload_interval running: false repeat: true triggeredOnStart: true onTriggered: { var now = new Date() dateText.currentDate = Qt.formatDate(now, "ddd, dd.MM.yyyy - ") } } } Text { id: timeText property string currentTime: "" text: currentTime color: ( clockArea.containsMouse ? Colors.tertiary : Colors.primary ) font.pixelSize: Config.font_size_small(clockRect.height) font.family: Config.font 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() timeText.currentTime = Qt.formatTime(now, "hh:mm:ss") } } } } } }