refaktor
This commit is contained in:
@@ -1,68 +1,70 @@
|
||||
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)
|
||||
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
|
||||
color: timeAnchoreMouseArea.containsMouse ? Colors.tertiaryContainer : Colors.primaryContainer
|
||||
radius: Config.radius_fun(height)
|
||||
color: clockArea.containsMouse ? Colors.tertiaryContainer : Colors.primaryContainer
|
||||
border.color: (
|
||||
timeAnchoreMouseArea.containsMouse ? Colors.tertiaryContainer_fg :
|
||||
clockArea.containsMouse ? Colors.tertiaryContainer_fg :
|
||||
Colors.primaryContainer_fg
|
||||
)
|
||||
border.width: Config.border_width
|
||||
|
||||
MouseArea {
|
||||
id: timeAnchoreMouseArea
|
||||
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 {
|
||||
id: row
|
||||
spacing: Config.spacing
|
||||
anchors.centerIn: parent
|
||||
|
||||
Text {
|
||||
id: dateDisplay
|
||||
id: dateText
|
||||
property string currentDate: ""
|
||||
|
||||
text: currentDate
|
||||
color: (
|
||||
timeAnchoreMouseArea.containsMouse ? Colors.tertiary :
|
||||
clockArea.containsMouse ? Colors.tertiary :
|
||||
Colors.primary
|
||||
)
|
||||
font.pixelSize: Math.floor(bar.height/2)
|
||||
font.family: "Inter, sans-serif"
|
||||
font.pixelSize: Config.font_size_small(clockRect.height)
|
||||
font.family: Config.font
|
||||
|
||||
Timer {
|
||||
id: dateTimer
|
||||
interval: 60000
|
||||
interval: Config.reload_interval
|
||||
running: false
|
||||
repeat: true
|
||||
triggeredOnStart: true
|
||||
onTriggered: {
|
||||
var now = new Date()
|
||||
dateDisplay.currentDate = Qt.formatDate(now, "ddd, dd.MM.yyyy -")
|
||||
dateText.currentDate = Qt.formatDate(now, "ddd, dd.MM.yyyy - ")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
id: timeDisplay
|
||||
id: timeText
|
||||
property string currentTime: ""
|
||||
|
||||
text: currentTime
|
||||
color: (
|
||||
timeAnchoreMouseArea.containsMouse ? Colors.tertiary :
|
||||
clockArea.containsMouse ? Colors.tertiary :
|
||||
Colors.primary
|
||||
)
|
||||
font.pixelSize: Math.floor(bar.height/2)
|
||||
font.family: "Inter, sans-serif"
|
||||
font.pixelSize: Config.font_size_small(clockRect.height)
|
||||
font.family: Config.font
|
||||
|
||||
Component.onCompleted: {
|
||||
var now = new Date()
|
||||
@@ -75,14 +77,10 @@ Rectangle { //workspace
|
||||
repeat: true
|
||||
onTriggered: {
|
||||
var now = new Date()
|
||||
timeDisplay.currentTime = Qt.formatTime(now, "hh:mm:ss")
|
||||
timeText.currentTime = Qt.formatTime(now, "hh:mm:ss")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
onClicked: {
|
||||
dateDisplay.currentDate = "";
|
||||
dateTimer.running = !dateTimer.running;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user