blob: 04bcc581174186af4c6b3aed67ca7c512b2fc5bf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
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 ?? ""
}
}
}
}
}
|