blob: d9e1c0aebaf4f449d3e5b01adc390024db5d01f3 (
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
|
import QtQuick.Layouts
import QtQuick
import Quickshell
import Quickshell.Hyprland
import Quickshell.Wayland
import qs.config as Config
import qs.components
Item {
id: root
// required property ShellScreen screen // multi monitor
// readonly property HyprlandMonitor monitor: Hyprland.monitorFor(screen) // multi monitor
property list<bool> workspaceOccupied: []
function updateWorkspaceOccupied() {
// workspaceOccupied = Array.from({ length: Config.options.bar.workspaces.shown }, (_, i) => {
// return Hyprland.workspaces.values.some(ws => ws.id === workspaceGroup * Config.options.bar.workspaces.shown + i + 1);
// })
workspaceOccupied = Array.from({
length: Config.Bar.workspaces
}, (_, i) => {
return Hyprland.workspaces.values.some(ws => ws?.id === (i + 1));
});
}
// dont work no more for some reason
function isActive(index: int): bool {
return Hyprland.focusedWorkspace?.id === (index + 1);
// return monitor.activeWorkspace.id === (index + 1); // multi monitor
}
function isOccupied(index: int): bool {
return workspaceOccupied[index] === true;
}
// TODO: allow specific index after tl can do that
// function isEmpty(): bool {
// for (let i of ToplevelManager.toplevels.values)
// if (i.activated)
// return false;
// return true;
// }
Connections {
target: Hyprland.workspaces
function onValuesChanged() {
updateWorkspaceOccupied();
}
}
Component.onCompleted: updateWorkspaceOccupied()
implicitWidth: layout.implicitWidth
RowLayout {
id: layout
implicitWidth: childrenRect.width
anchors.verticalCenter: parent.verticalCenter
spacing: Config.Bar.workspaceSpacing
Repeater {
model: Config.Bar.workspaces
Rectangle {
id: workspaceRect
// text: Hyprland.focusedWorkspace?.id.toString() == (index + 1).toString()
// text: isActive(index)
implicitWidth: !isActive(index) ? Config.Bar.workspaceIconSize : Config.Bar.workspaceActiveIconSize
implicitHeight: Config.Bar.workspaceIconSize - Config.Bar.workspaceHorizontalSpacing
radius: Config.Bar.workspaceRounding
Icons {
anchors.centerIn: parent
text: Config.Icons.ws[index + 1]
font.pixelSize: Config.Bar.workspaceIconSize / 2
color: Config.Colors.foreground // TODO make IText w/ ts default color
opacity: !isOccupied(index) ? 0 : 1 // less contrast
// opacity: isActive(index) ? Config.Bar.workspaceActiveOpacity : isOccupied(index) ? Config.Bar.workspaceOpacity : Config.Bar.workspaceEmptyOpacity
}
color: isOccupied(index) ? Config.Colors.alt : Config.Colors.foreground
opacity: isActive(index) ? Config.Bar.workspaceActiveOpacity : isOccupied(index) ? Config.Bar.workspaceOpacity : Config.Bar.workspaceEmptyOpacity
}
}
}
}
|