added beta of hover texts

This commit is contained in:
Hannes
2026-06-15 23:19:07 +02:00
parent 256c8360f5
commit c4a018e39c
7 changed files with 541 additions and 37 deletions
+37 -32
View File
@@ -2,10 +2,11 @@ import QtQuick
import Quickshell
import Quickshell.Hyprland
import "../../../config"
import "../states/Clock"
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)
width: ClockState.expanded ? Math.max(dateText.width + timeText.width + Config.spacing_fun(height)*3, bar.height) : Math.max(timeText.width + Config.spacing_fun(height)*2, bar.height)
height: bar.height
radius: Config.radius_fun(height)
color: clockArea.containsMouse ? Colors.tertiaryContainer : Colors.primaryContainer
@@ -22,9 +23,8 @@ Rectangle { //workspace
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)
ClockState.expanded = !ClockState.expanded
console.log("[Clock] Date visible: " + ClockState.expanded)
}
Row {
@@ -32,54 +32,59 @@ Rectangle { //workspace
Text {
id: dateText
property string currentDate: ""
text: currentDate
text: ClockState.shortDate
visible: ClockState.expanded
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
text: ClockState.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")
}
BarPopup {
id: clockPopup
anchorItem: clockRect
anchorHovered: clockArea.containsMouse
width: Math.max(text1.width, text2.width) + (Config.spacing_fun(clockRect.height) * 3)
height: text1.height*3+(Config.spacing_fun(clockRect.height) * 5)
Timer {
interval: 1000
running: true
repeat: true
onTriggered: {
var now = new Date()
timeText.currentTime = Qt.formatTime(now, "hh:mm:ss")
}
}
Column {
width: parent.width
spacing: Config.spacing_fun(clockRect.height)
Text {
id: text1
text: ClockState.fullDate
wrapMode: Text.WordWrap
color: Colors.primary
anchors.horizontalCenter: parent.horizontalCenter
font.pixelSize: Config.font_size_tiny(bar.height)
font.family: Config.font
}
Text {
id: text2
text: ClockState.uptime
wrapMode: Text.WordWrap
color: Colors.primary
anchors.horizontalCenter: parent.horizontalCenter
font.pixelSize: Config.font_size_tiny(bar.height)
font.family: Config.font
}
}
}