import QtQml import Quickshell import Quickshell.Io import QtQuick import Quickshell.Widgets Item { id: root required property string command property var state: null height: parent.height width: label.contentWidth + 8 anchors.verticalCenter: parent.verticalCenter Process { id: process running: true command: [ @worktime@, root.command, "--waybar" ] stdout: StdioCollector { id: processCollector onStreamFinished: { try { root.state = JSON.parse(processCollector.text); } catch (e) { console.warn("Worktime: Failed to parse output:", processCollector.text, e); } } } } Timer { running: true interval: 60 repeat: true onTriggered: process.running = true } WrapperMouseArea { id: mouseArea anchors.fill: parent enabled: true hoverEnabled: true Item { anchors.fill: parent Text { id: label anchors.centerIn: parent visible: root.state?.text ?? false text: root.state?.text ?? "" font.pointSize: 10 font.family: "Fira Sans" color: { if (root.state?.class == "running") return "white"; if (root.state?.class == "over") return "#f28a21"; return "#555"; } } } } PopupWindow { id: tooltip property bool nextVisible: Boolean(root.state?.tooltip ?? false) && (mouseArea.containsMouse || tooltipMouseArea.containsMouse) anchor { item: mouseArea edges: Edges.Bottom | Edges.Left } visible: false onNextVisibleChanged: hangTimer.restart() Timer { id: hangTimer interval: 100 onTriggered: tooltip.visible = tooltip.nextVisible } implicitWidth: tooltipText.contentWidth + 16 implicitHeight: tooltipText.contentHeight + 16 color: "black" WrapperMouseArea { id: tooltipMouseArea enabled: true hoverEnabled: true anchors.fill: parent Item { anchors.fill: parent Text { id: tooltipText anchors.centerIn: parent font.pointSize: 10 font.family: "Fira Sans" color: "white" text: root.state?.tooltip ?? "" } } } } }