summaryrefslogtreecommitdiff
path: root/accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml
diff options
context:
space:
mode:
Diffstat (limited to 'accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml')
-rw-r--r--accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml85
1 files changed, 49 insertions, 36 deletions
diff --git a/accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml b/accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml
index 153c56bb..9546abb4 100644
--- a/accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml
+++ b/accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml
@@ -1,5 +1,7 @@
1import Quickshell
1import QtQuick 2import QtQuick
2import qs.Services 3import qs.Services
4import Quickshell.Widgets
3 5
4Row { 6Row {
5 id: workspaces 7 id: workspaces
@@ -11,61 +13,72 @@ Row {
11 spacing: 0 13 spacing: 0
12 14
13 Repeater { 15 Repeater {
14 model: { 16 model: ScriptModel {
15 let currWorkspaces = NiriService.workspaces; 17 values: {
16 const ignoreWorkspaces = Array.from(workspaces.ignoreWorkspaces); 18 let currWorkspaces = NiriService.workspaces;
17 currWorkspaces = currWorkspaces.filter(ws => ws.is_active || ignoreWorkspaces.every(iws => iws !== ws.name)); 19 const ignoreWorkspaces = Array.from(workspaces.ignoreWorkspaces);
18 currWorkspaces.sort((a, b) => { 20 currWorkspaces = currWorkspaces.filter(ws => ws.is_active || ignoreWorkspaces.every(iws => iws !== ws.name));
19 if (NiriService.outputs?.[a.output]?.logical?.x !== NiriService.outputs?.[b.output]?.logical?.x) 21 currWorkspaces.sort((a, b) => {
20 return NiriService.outputs?.[a.output]?.logical?.x - NiriService.outputs?.[b.output]?.logical?.x 22 if (NiriService.outputs?.[a.output]?.logical?.x !== NiriService.outputs?.[b.output]?.logical?.x)
21 if (NiriService.outputs?.[a.output]?.logical?.y !== NiriService.outputs?.[b.output]?.logical?.y) 23 return NiriService.outputs?.[a.output]?.logical?.x - NiriService.outputs?.[b.output]?.logical?.x
22 return NiriService.outputs?.[a.output]?.logical?.y - NiriService.outputs?.[b.output]?.logical?.y 24 if (NiriService.outputs?.[a.output]?.logical?.y !== NiriService.outputs?.[b.output]?.logical?.y)
23 return a.idx - b.idx; 25 return NiriService.outputs?.[a.output]?.logical?.y - NiriService.outputs?.[b.output]?.logical?.y
24 }); 26 return a.idx - b.idx;
25 return currWorkspaces; 27 });
28 return currWorkspaces;
29 }
26 } 30 }
27 31
28 Rectangle { 32 Item {
33 id: wsItem
34
29 property var workspaceData: modelData 35 property var workspaceData: modelData
30 36
31 width: wsLabel.contentWidth + 8 37 width: wsLabel.contentWidth + 8
32 color: {
33 if (mouseArea.containsMouse) {
34 return "#33808080";
35 }
36 return "transparent";
37 }
38 height: parent.height 38 height: parent.height
39 anchors.verticalCenter: parent.verticalCenter 39 anchors.verticalCenter: parent.verticalCenter
40 40
41 MouseArea { 41 WrapperMouseArea {
42 id: mouseArea 42 id: mouseArea
43 43
44 anchors.fill: parent 44 anchors.fill: parent
45
45 hoverEnabled: true 46 hoverEnabled: true
46 cursorShape: Qt.PointingHandCursor 47 cursorShape: Qt.PointingHandCursor
47 enabled: true 48 enabled: true
48 onClicked: { 49 onClicked: {
49 NiriService.sendCommand({ "Action": { "FocusWorkspace": { "reference": { "Id": workspaceData.id } } } }, _ => {}) 50 NiriService.sendCommand({ "Action": { "FocusWorkspace": { "reference": { "Id": workspaceData.id } } } }, _ => {})
50 } 51 }
51 }
52 52
53 Text { 53 Rectangle {
54 id: wsLabel 54 anchors.fill: parent
55 55
56 font.pointSize: 10 56 color: {
57 font.family: "Fira Sans" 57 if (mouseArea.containsMouse) {
58 color: { 58 return "#33808080";
59 if (workspaceData.is_active) 59 }
60 return "#23fd00"; 60 return "transparent";
61 if (workspaceData.active_window_id === null) 61 }
62 return "#555"; 62
63 return "white"; 63 Text {
64 } 64 id: wsLabel
65 anchors.centerIn: parent
66 65
67 text: workspaceData.name ? workspaceData.name : workspaceData.idx 66 anchors.centerIn: parent
67
68 font.pointSize: 10
69 font.family: "Fira Sans"
70 color: {
71 if (workspaceData.is_active)
72 return "#23fd00";
73 if (workspaceData.active_window_id === null)
74 return "#555";
75 return "white";
76 }
77
78 text: workspaceData.name ? workspaceData.name : workspaceData.idx
79 }
80 }
68 } 81 }
69 } 82 }
70 } 83 }
71} \ No newline at end of file 84}