diff options
Diffstat (limited to 'accounts/gkleen@sif/shell/quickshell')
13 files changed, 1020 insertions, 238 deletions
diff --git a/accounts/gkleen@sif/shell/quickshell/ActiveWindowDisplay.qml b/accounts/gkleen@sif/shell/quickshell/ActiveWindowDisplay.qml index d7e8e7c5..57ade488 100644 --- a/accounts/gkleen@sif/shell/quickshell/ActiveWindowDisplay.qml +++ b/accounts/gkleen@sif/shell/quickshell/ActiveWindowDisplay.qml | |||
@@ -7,10 +7,11 @@ Item { | |||
7 | id: activeWindowDisplay | 7 | id: activeWindowDisplay |
8 | 8 | ||
9 | required property int maxWidth | 9 | required property int maxWidth |
10 | required property var screen | ||
10 | 11 | ||
11 | property var activeWindow: { | 12 | property var activeWindow: { |
12 | let currWindowId = Array.from(NiriService.workspaces).find(ws => { | 13 | let currWindowId = Array.from(NiriService.workspaces).find(ws => { |
13 | return ws.output === bar.screen.name && ws.is_active; | 14 | return ws.output === screen.name && ws.is_active; |
14 | })?.active_window_id; | 15 | })?.active_window_id; |
15 | 16 | ||
16 | return currWindowId ? Array.from(NiriService.windows).find(win => win.id == currWindowId) : null; | 17 | return currWindowId ? Array.from(NiriService.windows).find(win => win.id == currWindowId) : null; |
diff --git a/accounts/gkleen@sif/shell/quickshell/Bar.qml b/accounts/gkleen@sif/shell/quickshell/Bar.qml index accad2a9..38225d74 100644 --- a/accounts/gkleen@sif/shell/quickshell/Bar.qml +++ b/accounts/gkleen@sif/shell/quickshell/Bar.qml | |||
@@ -5,7 +5,7 @@ import QtQuick | |||
5 | PanelWindow { | 5 | PanelWindow { |
6 | id: bar | 6 | id: bar |
7 | 7 | ||
8 | property var modelData | 8 | required property var screen |
9 | 9 | ||
10 | anchors { | 10 | anchors { |
11 | top: true | 11 | top: true |
@@ -17,7 +17,6 @@ PanelWindow { | |||
17 | right: 26 + 8 | 17 | right: 26 + 8 |
18 | } | 18 | } |
19 | 19 | ||
20 | screen: modelData | ||
21 | implicitHeight: 21 | 20 | implicitHeight: 21 |
22 | color: "transparent" | 21 | color: "transparent" |
23 | 22 | ||
@@ -50,6 +49,7 @@ PanelWindow { | |||
50 | spacing: 5 | 49 | spacing: 5 |
51 | 50 | ||
52 | ActiveWindowDisplay { | 51 | ActiveWindowDisplay { |
52 | screen: bar.screen | ||
53 | maxWidth: bar.width - 2*Math.max(left.width, right.width) - 2*8 | 53 | maxWidth: bar.width - 2*Math.max(left.width, right.width) - 2*8 |
54 | } | 54 | } |
55 | } | 55 | } |
diff --git a/accounts/gkleen@sif/shell/quickshell/Clock.qml b/accounts/gkleen@sif/shell/quickshell/Clock.qml index 68efb558..382af168 100644 --- a/accounts/gkleen@sif/shell/quickshell/Clock.qml +++ b/accounts/gkleen@sif/shell/quickshell/Clock.qml | |||
@@ -7,216 +7,271 @@ import QtQuick.Layouts | |||
7 | import Quickshell.Widgets | 7 | import Quickshell.Widgets |
8 | 8 | ||
9 | Item { | 9 | Item { |
10 | id: clockItem | ||
11 | |||
12 | property bool calendarPopup: true | ||
13 | |||
10 | width: clock.contentWidth | 14 | width: clock.contentWidth |
11 | height: parent.height | 15 | height: parent.height |
12 | anchors.verticalCenter: parent.verticalCenter | 16 | anchors.verticalCenter: parent.verticalCenter |
13 | 17 | ||
14 | MouseArea { | 18 | WrapperMouseArea { |
15 | id: clockMouseArea | 19 | id: clockMouseArea |
16 | 20 | ||
17 | anchors.fill: parent | 21 | anchors.fill: parent |
18 | hoverEnabled: true | 22 | hoverEnabled: true |
19 | enabled: true | 23 | enabled: clockItem.calendarPopup |
24 | |||
25 | Item { | ||
26 | anchors.fill: parent | ||
27 | |||
28 | Text { | ||
29 | id: clock | ||
30 | color: "white" | ||
20 | 31 | ||
21 | property real angleRem: 0 | 32 | anchors.verticalCenter: parent.verticalCenter |
22 | property real sensitivity: 1 / 120 | 33 | |
34 | Custom.Chrono { | ||
35 | id: chrono | ||
36 | |||
37 | onDateChanged: clock.text = format("W{0:%V-%u} {0:%F} {0:%H:%M:%S%Ez}") | ||
38 | } | ||
23 | 39 | ||
24 | onWheel: event => { | 40 | font.pointSize: 10 |
25 | angleRem += event.angleDelta.y; | 41 | font.family: "Fira Sans" |
26 | const d = Math.round(angleRem * sensitivity); | 42 | font.features: { "tnum": 1 } |
27 | yearCalendar.year += d; | 43 | } |
28 | angleRem -= d / sensitivity; | ||
29 | } | 44 | } |
30 | } | 45 | } |
31 | 46 | ||
32 | Text { | 47 | Loader { |
33 | id: clock | 48 | id: tooltipLoader |
34 | color: "white" | ||
35 | 49 | ||
36 | anchors.verticalCenter: parent.verticalCenter | 50 | active: false |
37 | 51 | ||
38 | Custom.Chrono { | 52 | Connections { |
39 | id: chrono | 53 | target: clockMouseArea |
40 | format: "W{0:%V-%u} {0:%F} {0:%H:%M:%S%Ez}" | 54 | function onContainsMouseChanged() { |
55 | if (clockMouseArea.containsMouse) | ||
56 | tooltipLoader.active = true; | ||
57 | } | ||
41 | } | 58 | } |
42 | 59 | ||
43 | text: chrono.date | 60 | sourceComponent: PopupWindow { |
61 | id: tooltip | ||
44 | 62 | ||
45 | font.pointSize: 10 | 63 | property bool nextVisible: clockMouseArea.containsMouse || tooltipMouseArea.containsMouse |
46 | font.family: "Fira Sans" | ||
47 | font.features: { "tnum": 1 } | ||
48 | } | ||
49 | 64 | ||
50 | PopupWindow { | 65 | anchor { |
51 | anchor { | 66 | item: clockMouseArea |
52 | item: clockMouseArea | 67 | edges: Edges.Bottom | Edges.Left |
53 | edges: Edges.Bottom | 68 | } |
54 | } | 69 | visible: false |
55 | visible: clockMouseArea.containsMouse | ||
56 | 70 | ||
57 | implicitWidth: clockTooltipContent.width | 71 | onNextVisibleChanged: hangTimer.restart() |
58 | implicitHeight: clockTooltipContent.height | ||
59 | color: "black" | ||
60 | 72 | ||
61 | onVisibleChanged: { | 73 | Timer { |
62 | const d = new Date(); | 74 | id: hangTimer |
63 | yearCalendar.year = d.getFullYear(); | 75 | interval: 100 |
64 | clockMouseArea.angleRem = 0; | 76 | onTriggered: tooltip.visible = tooltip.nextVisible |
65 | } | 77 | } |
66 | 78 | ||
67 | WrapperItem { | 79 | implicitWidth: clockTooltipContent.width |
68 | id: clockTooltipContent | 80 | implicitHeight: clockTooltipContent.height |
81 | color: "black" | ||
69 | 82 | ||
70 | margin: 8 | 83 | onVisibleChanged: { |
71 | leftMargin: 0 | 84 | yearCalendar.year = chrono.date.getFullYear(); |
85 | yearCalendar.angleRem = 0; | ||
86 | } | ||
72 | 87 | ||
73 | ColumnLayout { | 88 | WrapperMouseArea { |
74 | Text { | 89 | id: tooltipMouseArea |
75 | id: yearLabel | ||
76 | 90 | ||
77 | horizontalAlignment: Text.AlignHCenter | 91 | hoverEnabled: true |
92 | enabled: true | ||
78 | 93 | ||
79 | font.pointSize: 14 | 94 | onWheel: event => yearCalendar.scrollYear(event) |
80 | font.family: "Fira Sans" | ||
81 | font.features: { "tnum": 1 } | ||
82 | color: "white" | ||
83 | 95 | ||
84 | text: yearCalendar.year | 96 | anchors.fill: parent |
85 | 97 | ||
86 | Layout.fillWidth: true | 98 | WrapperItem { |
87 | Layout.bottomMargin: 8 | 99 | id: clockTooltipContent |
88 | } | ||
89 | 100 | ||
90 | GridLayout { | 101 | margin: 8 |
91 | property int year: { const d = new Date(); return d.getFullYear(); } | 102 | leftMargin: 0 |
92 | 103 | ||
93 | id: yearCalendar | 104 | ColumnLayout { |
105 | Text { | ||
106 | id: yearLabel | ||
94 | 107 | ||
95 | columns: 3 | 108 | horizontalAlignment: Text.AlignHCenter |
96 | columnSpacing: 16 | ||
97 | rowSpacing: 16 | ||
98 | 109 | ||
99 | Layout.alignment: Qt.AlignHCenter | 110 | font.pointSize: 14 |
100 | Layout.fillWidth: false | 111 | font.family: "Fira Sans" |
112 | font.features: { "tnum": 1 } | ||
113 | color: "white" | ||
101 | 114 | ||
102 | Repeater { | 115 | text: yearCalendar.year |
103 | model: 12 | 116 | |
117 | Layout.fillWidth: true | ||
118 | Layout.bottomMargin: 8 | ||
119 | } | ||
104 | 120 | ||
105 | GridLayout { | 121 | GridLayout { |
106 | columns: 2 | 122 | property int year: chrono.date.getFullYear() |
107 | 123 | ||
108 | required property int index | 124 | id: yearCalendar |
109 | property int month: index | ||
110 | 125 | ||
111 | id: monthCalendar | 126 | columns: 3 |
127 | columnSpacing: 16 | ||
128 | rowSpacing: 16 | ||
112 | 129 | ||
113 | Layout.alignment: Qt.AlignTop | Qt.AlignRight | 130 | Layout.alignment: Qt.AlignHCenter |
114 | Layout.fillWidth: false | 131 | Layout.fillWidth: false |
115 | 132 | ||
116 | Text { | 133 | property real angleRem: 0 |
117 | Layout.column: 1 | 134 | property real sensitivity: 1 / 120 |
118 | Layout.fillWidth: true | ||
119 | 135 | ||
120 | horizontalAlignment: Text.AlignHCenter | 136 | function scrollYear(event) { |
137 | angleRem += event.angleDelta.y; | ||
138 | const d = Math.round(angleRem * sensitivity); | ||
139 | yearCalendar.year += d; | ||
140 | angleRem -= d / sensitivity; | ||
141 | } | ||
121 | 142 | ||
122 | font.pointSize: 10 | 143 | Connections { |
123 | font.family: "Fira Sans" | 144 | target: clockMouseArea |
145 | function onWheel(event) { yearCalendar.scrollYear(event); } | ||
146 | } | ||
124 | 147 | ||
125 | text: { | 148 | Repeater { |
126 | const date = Date.fromLocaleDateString(Qt.locale(), `${yearCalendar.year}-${monthCalendar.month + 1}-01`, "yyyy-M-dd"); | 149 | model: 12 |
127 | return date.toLocaleString(Qt.locale("en_DK"), "MMMM") | ||
128 | } | ||
129 | 150 | ||
130 | color: "#ffead3" | 151 | GridLayout { |
131 | } | 152 | columns: 2 |
132 | 153 | ||
133 | DayOfWeekRow { | 154 | required property int index |
134 | locale: grid.locale | 155 | property int month: index |
135 | 156 | ||
136 | Layout.row: 1 | 157 | id: monthCalendar |
137 | Layout.column: 1 | ||
138 | Layout.fillWidth: true | ||
139 | 158 | ||
140 | delegate: Text { | 159 | Layout.alignment: Qt.AlignTop | Qt.AlignRight |
141 | required property string shortName | 160 | Layout.fillWidth: false |
142 | 161 | ||
143 | font.pointSize: 10 | 162 | Text { |
144 | font.family: "Fira Mono" | 163 | Layout.column: 1 |
164 | Layout.fillWidth: true | ||
145 | 165 | ||
146 | text: shortName | 166 | horizontalAlignment: Text.AlignHCenter |
147 | color: "#ffcc66" | ||
148 | 167 | ||
149 | horizontalAlignment: Text.AlignRight | 168 | font.pointSize: 10 |
150 | verticalAlignment: Text.AlignVCenter | 169 | font.family: "Fira Sans" |
151 | } | ||
152 | } | ||
153 | 170 | ||
154 | WeekNumberColumn { | 171 | text: new Date(yearCalendar.year, monthCalendar.month, 1).toLocaleString(Qt.locale("en_DK"), "MMMM") |
155 | month: grid.month | ||
156 | year: grid.year | ||
157 | locale: grid.locale | ||
158 | 172 | ||
159 | Layout.fillHeight: true | 173 | color: "#ffead3" |
174 | } | ||
160 | 175 | ||
161 | delegate: Text { | 176 | DayOfWeekRow { |
162 | required property int weekNumber | 177 | locale: grid.locale |
163 | 178 | ||
164 | opacity: { | 179 | Layout.row: 1 |
165 | const simple = new Date(weekNumber == 1 && monthCalendar.month == 12 ? yearCalendar.year + 1 : yearCalendar.year, 0, 1 + (weekNumber - 1) * 7); | 180 | Layout.column: 1 |
166 | const dayOfWeek = simple.getDay(); | 181 | Layout.fillWidth: true |
167 | const isoWeekStart = simple; | ||
168 | 182 | ||
169 | isoWeekStart.setDate(simple.getDate() - dayOfWeek + 1); | 183 | delegate: WrapperItem { |
170 | if (dayOfWeek > 4) { | 184 | required property string shortName |
171 | isoWeekStart.setDate(isoWeekStart.getDate() + 7); | ||
172 | } | ||
173 | 185 | ||
174 | for (let i = 0; i < 7; i++) { | 186 | width: dowLabel.contentWidth + 6 |
175 | const dayInWeek = new Date(isoWeekStart); | 187 | |
176 | dayInWeek.setDate(dayInWeek.getDate() + i); | 188 | Text { |
177 | if (dayInWeek.getMonth() == monthCalendar.month) | 189 | id: dowLabel |
178 | return 1; | 190 | |
179 | } | 191 | anchors.fill: parent |
192 | |||
193 | font.pointSize: 10 | ||
194 | font.family: "Fira Sans" | ||
180 | 195 | ||
181 | return 0; | 196 | text: parent.shortName |
197 | color: "#ffcc66" | ||
198 | |||
199 | horizontalAlignment: Text.AlignHCenter | ||
200 | verticalAlignment: Text.AlignVCenter | ||
201 | } | ||
202 | } | ||
182 | } | 203 | } |
183 | 204 | ||
184 | font.pointSize: 10 | 205 | WeekNumberColumn { |
185 | font.family: "Fira Sans" | 206 | month: grid.month |
186 | font.features: { "tnum": 1 } | 207 | year: grid.year |
208 | locale: grid.locale | ||
187 | 209 | ||
188 | text: weekNumber | 210 | Layout.fillHeight: true |
189 | color: "#99ffdd" | ||
190 | 211 | ||
191 | horizontalAlignment: Text.AlignRight | 212 | delegate: Text { |
192 | verticalAlignment: Text.AlignVCenter | 213 | required property int weekNumber |
193 | } | ||
194 | } | ||
195 | 214 | ||
196 | MonthGrid { | 215 | opacity: { |
197 | id: grid | 216 | const simple = new Date(weekNumber == 1 && monthCalendar.month == 12 ? yearCalendar.year + 1 : yearCalendar.year, 0, 1 + (weekNumber - 1) * 7); |
217 | const dayOfWeek = simple.getDay(); | ||
218 | const isoWeekStart = simple; | ||
198 | 219 | ||
199 | year: yearCalendar.year | 220 | isoWeekStart.setDate(simple.getDate() - dayOfWeek + 1); |
200 | month: monthCalendar.month | 221 | if (dayOfWeek > 4) { |
201 | locale: Qt.locale("en_DK") | 222 | isoWeekStart.setDate(isoWeekStart.getDate() + 7); |
223 | } | ||
202 | 224 | ||
203 | Layout.fillWidth: true | 225 | for (let i = 0; i < 7; i++) { |
204 | Layout.fillHeight: true | 226 | const dayInWeek = new Date(isoWeekStart); |
227 | dayInWeek.setDate(dayInWeek.getDate() + i); | ||
228 | if (dayInWeek.getMonth() == monthCalendar.month) | ||
229 | return 1; | ||
230 | } | ||
205 | 231 | ||
206 | delegate: Text { | 232 | return 0; |
207 | required property var model | 233 | } |
208 | 234 | ||
209 | opacity: model.month === monthCalendar.month ? 1 : 0 | 235 | font.pointSize: 10 |
236 | font.family: "Fira Sans" | ||
237 | font.features: { "tnum": 1 } | ||
210 | 238 | ||
211 | font.pointSize: 10 | 239 | text: weekNumber |
212 | font.family: "Fira Sans" | 240 | color: "#99ffdd" |
213 | font.features: { "tnum": 1 } | ||
214 | 241 | ||
215 | text: model.day | 242 | horizontalAlignment: Text.AlignRight |
216 | color: model.today ? "#ff6699" : "white" | 243 | verticalAlignment: Text.AlignVCenter |
244 | } | ||
245 | } | ||
246 | |||
247 | MonthGrid { | ||
248 | id: grid | ||
249 | |||
250 | year: yearCalendar.year | ||
251 | month: monthCalendar.month | ||
252 | locale: Qt.locale("en_DK") | ||
253 | |||
254 | Layout.fillWidth: true | ||
255 | Layout.fillHeight: true | ||
256 | |||
257 | delegate: Text { | ||
258 | required property var model | ||
217 | 259 | ||
218 | horizontalAlignment: Text.AlignRight | 260 | opacity: model.month === monthCalendar.month ? 1 : 0 |
219 | verticalAlignment: Text.AlignVCenter | 261 | |
262 | font.pointSize: 10 | ||
263 | font.family: "Fira Sans" | ||
264 | font.features: { "tnum": 1 } | ||
265 | |||
266 | property bool today: chrono.date.getFullYear() == model.year && chrono.date.getMonth() == model.month && chrono.date.getDate() == model.day | ||
267 | |||
268 | text: model.day | ||
269 | color: today ? "#ff6699" : "white" | ||
270 | |||
271 | horizontalAlignment: Text.AlignRight | ||
272 | verticalAlignment: Text.AlignVCenter | ||
273 | } | ||
274 | } | ||
220 | } | 275 | } |
221 | } | 276 | } |
222 | } | 277 | } |
@@ -225,4 +280,4 @@ Item { | |||
225 | } | 280 | } |
226 | } | 281 | } |
227 | } | 282 | } |
228 | } \ No newline at end of file | 283 | } |
diff --git a/accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml b/accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml index 710ea10c..bc3750f9 100644 --- a/accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml +++ b/accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml | |||
@@ -1,77 +1,105 @@ | |||
1 | import Quickshell | 1 | import Quickshell |
2 | import QtQuick | 2 | import QtQuick |
3 | import qs.Services | 3 | import qs.Services |
4 | import Quickshell.Widgets | ||
4 | 5 | ||
5 | Rectangle { | 6 | Item { |
6 | id: kbdWidget | ||
7 | |||
8 | property var keyboardAbbrev: { "English (programmer Dvorak)": "dvp", "English (US)": "us" } | ||
9 | |||
10 | width: kbdLabel.contentWidth + 8 | 7 | width: kbdLabel.contentWidth + 8 |
11 | color: { | ||
12 | if (kbdMouseArea.containsMouse) { | ||
13 | return "#33808080"; | ||
14 | } | ||
15 | return "transparent"; | ||
16 | } | ||
17 | height: parent.height | 8 | height: parent.height |
18 | anchors.verticalCenter: parent.verticalCenter | 9 | anchors.verticalCenter: parent.verticalCenter |
19 | 10 | ||
20 | MouseArea { | 11 | WrapperMouseArea { |
21 | id: kbdMouseArea | 12 | id: kbdMouseArea |
22 | 13 | ||
23 | anchors.fill: parent | 14 | anchors.fill: parent |
15 | |||
24 | hoverEnabled: true | 16 | hoverEnabled: true |
25 | cursorShape: Qt.PointingHandCursor | 17 | cursorShape: Qt.PointingHandCursor |
26 | enabled: true | 18 | enabled: true |
27 | onClicked: { | 19 | onClicked: { |
28 | NiriService.sendCommand({ "Action": { "SwitchLayout": { "layout": "Next" } } }, _ => {}) | 20 | NiriService.sendCommand({ "Action": { "SwitchLayout": { "layout": "Next" } } }, _ => {}) |
29 | } | 21 | } |
30 | } | 22 | onWheel: event => { |
23 | NiriService.sendCommand({ "Action": { "SwitchLayout": { "layout": event.angleDelta > 0 ? "Next" : "Prev" } } }, _ => {}) | ||
24 | } | ||
31 | 25 | ||
32 | Text { | 26 | Rectangle { |
33 | id: kbdLabel | 27 | id: kbdWidget |
34 | 28 | ||
35 | font.pointSize: 10 | 29 | property var keyboardAbbrev: { "English (programmer Dvorak)": "dvp", "English (US)": "us" } |
36 | font.family: "Fira Sans" | 30 | |
37 | color: { | 31 | anchors.fill: parent |
38 | if (NiriService.keyboardLayouts?.current_idx === 0) | 32 | color: { |
39 | return "#555"; | 33 | if (kbdMouseArea.containsMouse) { |
40 | return "white"; | 34 | return "#33808080"; |
41 | } | 35 | } |
42 | anchors.centerIn: parent | 36 | return "transparent"; |
37 | } | ||
43 | 38 | ||
44 | text: { | 39 | Text { |
45 | const currentLayout = NiriService.keyboardLayouts?.names?.[NiriService.keyboardLayouts.current_idx]; | 40 | id: kbdLabel |
46 | if (!currentLayout) | 41 | |
47 | return ""; | 42 | font.pointSize: 10 |
48 | return kbdWidget.keyboardAbbrev[currentLayout] ? kbdWidget.keyboardAbbrev[currentLayout] : currentLayout; | 43 | font.family: "Fira Sans" |
44 | color: { | ||
45 | if (NiriService.keyboardLayouts?.current_idx === 0) | ||
46 | return "#555"; | ||
47 | return "white"; | ||
48 | } | ||
49 | anchors.centerIn: parent | ||
50 | |||
51 | text: { | ||
52 | const currentLayout = NiriService.keyboardLayouts?.names?.[NiriService.keyboardLayouts.current_idx]; | ||
53 | if (!currentLayout) | ||
54 | return ""; | ||
55 | return kbdWidget.keyboardAbbrev[currentLayout] ? kbdWidget.keyboardAbbrev[currentLayout] : currentLayout; | ||
56 | } | ||
57 | } | ||
49 | } | 58 | } |
50 | } | 59 | } |
51 | 60 | ||
52 | PopupWindow { | 61 | PopupWindow { |
62 | id: tooltip | ||
63 | |||
64 | property bool nextVisible: kbdMouseArea.containsMouse || tooltipMouseArea.containsMouse | ||
65 | |||
53 | anchor { | 66 | anchor { |
54 | item: kbdMouseArea | 67 | item: kbdMouseArea |
55 | edges: Edges.Bottom | 68 | edges: Edges.Bottom | Edges.Left |
69 | } | ||
70 | visible: false | ||
71 | |||
72 | onNextVisibleChanged: hangTimer.restart() | ||
73 | |||
74 | Timer { | ||
75 | id: hangTimer | ||
76 | interval: 100 | ||
77 | onTriggered: tooltip.visible = tooltip.nextVisible | ||
56 | } | 78 | } |
57 | visible: kbdMouseArea.containsMouse | ||
58 | 79 | ||
59 | implicitWidth: kbdTooltipText.contentWidth + 16 | 80 | implicitWidth: kbdTooltipText.contentWidth + 16 |
60 | implicitHeight: kbdTooltipText.contentHeight + 16 | 81 | implicitHeight: kbdTooltipText.contentHeight + 16 |
61 | color: "black" | 82 | color: "black" |
62 | 83 | ||
63 | Text { | 84 | WrapperMouseArea { |
64 | id: kbdTooltipText | 85 | id: tooltipMouseArea |
86 | |||
87 | hoverEnabled: true | ||
88 | enabled: true | ||
65 | 89 | ||
66 | anchors.centerIn: parent | 90 | anchors.centerIn: parent |
67 | 91 | ||
68 | font.pointSize: 10 | 92 | Text { |
69 | font.family: "Fira Sans" | 93 | id: kbdTooltipText |
70 | color: "white" | 94 | |
95 | font.pointSize: 10 | ||
96 | font.family: "Fira Sans" | ||
97 | color: "white" | ||
71 | 98 | ||
72 | text: { | 99 | text: { |
73 | const currentLayout = NiriService.keyboardLayouts?.names?.[NiriService.keyboardLayouts.current_idx]; | 100 | const currentLayout = NiriService.keyboardLayouts?.names?.[NiriService.keyboardLayouts.current_idx]; |
74 | return currentLayout || ""; | 101 | return currentLayout || ""; |
102 | } | ||
75 | } | 103 | } |
76 | } | 104 | } |
77 | } | 105 | } |
diff --git a/accounts/gkleen@sif/shell/quickshell/LockSurface.qml b/accounts/gkleen@sif/shell/quickshell/LockSurface.qml new file mode 100644 index 00000000..18698725 --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/LockSurface.qml | |||
@@ -0,0 +1,223 @@ | |||
1 | import Quickshell.Widgets | ||
2 | import QtQuick.Effects | ||
3 | import QtQuick.Layouts | ||
4 | import QtQuick | ||
5 | import QtQuick.Controls | ||
6 | import QtQuick.Controls.Fusion | ||
7 | import qs.Services | ||
8 | import QtQml | ||
9 | |||
10 | Item { | ||
11 | id: lockSurface | ||
12 | |||
13 | property var screen | ||
14 | property list<var> messages: [] | ||
15 | property bool responseRequired: false | ||
16 | property bool responseVisible: false | ||
17 | property string currentText: "" | ||
18 | property bool authRunning: false | ||
19 | |||
20 | signal response(string responseText) | ||
21 | |||
22 | anchors.fill: parent | ||
23 | |||
24 | Item { | ||
25 | id: background | ||
26 | |||
27 | anchors.fill: parent | ||
28 | |||
29 | property Img current: one | ||
30 | property string source: selector.selected | ||
31 | |||
32 | WallpaperSelector { | ||
33 | id: selector | ||
34 | seed: lockSurface.screen?.name || "" | ||
35 | } | ||
36 | |||
37 | onSourceChanged: { | ||
38 | if (!source) | ||
39 | current = null; | ||
40 | else if (current === one) | ||
41 | two.update() | ||
42 | else | ||
43 | one.update() | ||
44 | } | ||
45 | |||
46 | Img { id: one } | ||
47 | Img { id: two } | ||
48 | |||
49 | component Img: Item { | ||
50 | id: img | ||
51 | |||
52 | property string source | ||
53 | |||
54 | function update() { | ||
55 | source = background.source || "" | ||
56 | } | ||
57 | |||
58 | anchors.fill: parent | ||
59 | |||
60 | Image { | ||
61 | id: imageSource | ||
62 | |||
63 | source: img.source | ||
64 | sourceSize: Qt.size(parent.width, parent.height) | ||
65 | fillMode: Image.PreserveAspectCrop | ||
66 | smooth: true | ||
67 | visible: false | ||
68 | asynchronous: true | ||
69 | cache: false | ||
70 | |||
71 | onStatusChanged: { | ||
72 | if (status === Image.Ready) { | ||
73 | background.current = img | ||
74 | } | ||
75 | } | ||
76 | } | ||
77 | |||
78 | MultiEffect { | ||
79 | id: imageEffect | ||
80 | |||
81 | source: imageSource | ||
82 | anchors.fill: parent | ||
83 | blurEnabled: true | ||
84 | blur: 1 | ||
85 | blurMax: 64 | ||
86 | blurMultiplier: 2 | ||
87 | |||
88 | opacity: 0 | ||
89 | |||
90 | states: State { | ||
91 | name: "visible" | ||
92 | when: background.current === img | ||
93 | |||
94 | PropertyChanges { | ||
95 | imageEffect.opacity: 1 | ||
96 | } | ||
97 | StateChangeScript { | ||
98 | name: "unloadOther" | ||
99 | script: { | ||
100 | if (img === one) | ||
101 | two.source = "" | ||
102 | if (img === two) | ||
103 | one.source = "" | ||
104 | } | ||
105 | } | ||
106 | } | ||
107 | |||
108 | transitions: Transition { | ||
109 | SequentialAnimation { | ||
110 | NumberAnimation { | ||
111 | target: imageEffect | ||
112 | properties: "opacity" | ||
113 | duration: 5000 | ||
114 | easing.type: Easing.OutCubic | ||
115 | } | ||
116 | ScriptAction { | ||
117 | scriptName: "unloadOther" | ||
118 | } | ||
119 | } | ||
120 | } | ||
121 | } | ||
122 | } | ||
123 | } | ||
124 | |||
125 | Item { | ||
126 | anchors { | ||
127 | top: lockSurface.top | ||
128 | left: lockSurface.left | ||
129 | right: lockSurface.right | ||
130 | } | ||
131 | |||
132 | implicitWidth: lockSurface.width | ||
133 | implicitHeight: 21 | ||
134 | |||
135 | Rectangle { | ||
136 | anchors.fill: parent | ||
137 | color: Qt.rgba(0, 0, 0, 0.75) | ||
138 | } | ||
139 | |||
140 | Clock { | ||
141 | anchors.centerIn: parent | ||
142 | calendarPopup: false | ||
143 | } | ||
144 | } | ||
145 | |||
146 | WrapperRectangle { | ||
147 | id: unlockUi | ||
148 | |||
149 | Keys.onPressed: event => { | ||
150 | if (!lockSurface.authRunning) { | ||
151 | event.accepted = true; | ||
152 | lockSurface.authRunning = true; | ||
153 | } | ||
154 | } | ||
155 | focus: !passwordBox.visible | ||
156 | |||
157 | visible: lockSurface.authRunning | ||
158 | |||
159 | color: Qt.rgba(0, 0, 0, 0.75) | ||
160 | margin: 8 | ||
161 | |||
162 | anchors.centerIn: parent | ||
163 | |||
164 | ColumnLayout { | ||
165 | spacing: 4 | ||
166 | |||
167 | BusyIndicator { | ||
168 | visible: running | ||
169 | running: !Array.from(lockSurface.messages).length && !lockSurface.responseRequired | ||
170 | } | ||
171 | |||
172 | Repeater { | ||
173 | model: lockSurface.messages | ||
174 | |||
175 | Text { | ||
176 | required property var modelData | ||
177 | |||
178 | font.pointSize: 10 | ||
179 | font.family: "Fira Sans" | ||
180 | color: modelData.error ? "#f28a21" : "#ffffff" | ||
181 | |||
182 | text: String(modelData.text).trim() | ||
183 | |||
184 | Layout.fillWidth: true | ||
185 | horizontalAlignment: Text.AlignHCenter | ||
186 | } | ||
187 | } | ||
188 | |||
189 | TextField { | ||
190 | id: passwordBox | ||
191 | |||
192 | visible: lockSurface.responseRequired | ||
193 | echoMode: lockSurface.responseVisible ? TextInput.Normal : TextInput.Password | ||
194 | inputMethodHints: Qt.ImhSensitiveData | ||
195 | |||
196 | onTextChanged: lockSurface.currentText = passwordBox.text | ||
197 | onAccepted: { | ||
198 | passwordBox.readOnly = true; | ||
199 | lockSurface.response(lockSurface.currentText); | ||
200 | } | ||
201 | |||
202 | Connections { | ||
203 | target: lockSurface | ||
204 | function onCurrentTextChanged() { | ||
205 | passwordBox.text = lockSurface.currentText | ||
206 | } | ||
207 | } | ||
208 | Connections { | ||
209 | target: lockSurface | ||
210 | function onResponseRequiredChanged() { | ||
211 | if (lockSurface.responseRequired) | ||
212 | passwordBox.readOnly = false; | ||
213 | passwordBox.focus = true; | ||
214 | passwordBox.selectAll(); | ||
215 | } | ||
216 | } | ||
217 | |||
218 | Layout.topMargin: 4 | ||
219 | Layout.fillWidth: true | ||
220 | } | ||
221 | } | ||
222 | } | ||
223 | } | ||
diff --git a/accounts/gkleen@sif/shell/quickshell/Lockscreen.qml b/accounts/gkleen@sif/shell/quickshell/Lockscreen.qml new file mode 100644 index 00000000..cc82a275 --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/Lockscreen.qml | |||
@@ -0,0 +1,77 @@ | |||
1 | import Quickshell | ||
2 | import Quickshell.Wayland | ||
3 | import Quickshell.Io | ||
4 | import Quickshell.Services.Pam | ||
5 | import QtQml | ||
6 | |||
7 | Scope { | ||
8 | id: lockscreen | ||
9 | |||
10 | property string currentText: "" | ||
11 | |||
12 | PamContext { | ||
13 | id: pam | ||
14 | |||
15 | property list<var> messages: [] | ||
16 | |||
17 | config: "quickshell" | ||
18 | onCompleted: result => { | ||
19 | if (result === PamResult.Success) { | ||
20 | lock.locked = false; | ||
21 | } | ||
22 | } | ||
23 | onPamMessage: { | ||
24 | messages = Array.from(messages).concat([{ "text": pam.message, "error": pam.messageIsError }]) | ||
25 | } | ||
26 | onActiveChanged: { | ||
27 | messages = []; | ||
28 | } | ||
29 | } | ||
30 | |||
31 | IpcHandler { | ||
32 | target: "Lockscreen" | ||
33 | |||
34 | function setLocked(locked: bool): void { lock.locked = locked; } | ||
35 | function getLocked(): bool { return lock.locked; } | ||
36 | } | ||
37 | |||
38 | WlSessionLock { | ||
39 | id: lock | ||
40 | |||
41 | onLockedChanged: { | ||
42 | if (!locked && pam.active) | ||
43 | pam.abort(); | ||
44 | } | ||
45 | |||
46 | WlSessionLockSurface { | ||
47 | id: lockSurface | ||
48 | |||
49 | color: "black" | ||
50 | |||
51 | LockSurface { | ||
52 | id: surfaceContent | ||
53 | |||
54 | onResponse: responseText => pam.respond(responseText) | ||
55 | onAuthRunningChanged: { | ||
56 | if (authRunning) | ||
57 | pam.start(); | ||
58 | } | ||
59 | Connections { | ||
60 | target: pam | ||
61 | function onMessagesChanged() { surfaceContent.messages = pam.messages; } | ||
62 | function onResponseRequiredChanged() { surfaceContent.responseRequired = pam.responseRequired; } | ||
63 | function onActiveChanged() { surfaceContent.authRunning = pam.active; } | ||
64 | } | ||
65 | onCurrentTextChanged: lockscreen.currentText = currentText | ||
66 | Connections { | ||
67 | target: lockscreen | ||
68 | function onCurrentTextChanged() { surfaceContent.currentText = lockscreen.currentText; } | ||
69 | } | ||
70 | Connections { | ||
71 | target: lockSurface | ||
72 | function onScreenChanged() { surfaceContent.screen = lockSurface.screen; } | ||
73 | } | ||
74 | } | ||
75 | } | ||
76 | } | ||
77 | } | ||
diff --git a/accounts/gkleen@sif/shell/quickshell/Services/NiriService.qml b/accounts/gkleen@sif/shell/quickshell/Services/NiriService.qml index c82caaa6..af522ec4 100644 --- a/accounts/gkleen@sif/shell/quickshell/Services/NiriService.qml +++ b/accounts/gkleen@sif/shell/quickshell/Services/NiriService.qml | |||
@@ -28,9 +28,12 @@ Singleton { | |||
28 | path: root.socketPath | 28 | path: root.socketPath |
29 | connected: true | 29 | connected: true |
30 | 30 | ||
31 | property bool acked: false | ||
32 | |||
31 | onConnectionStateChanged: { | 33 | onConnectionStateChanged: { |
32 | if (connected) { | 34 | if (connected) { |
33 | write('"EventStream"\n') | 35 | acked = false; |
36 | write('"EventStream"\n'); | ||
34 | } | 37 | } |
35 | } | 38 | } |
36 | 39 | ||
@@ -66,6 +69,9 @@ Singleton { | |||
66 | eventWindowUrgencyChanged(event.WindowUrgencyChanged); | 69 | eventWindowUrgencyChanged(event.WindowUrgencyChanged); |
67 | else if (event.WindowLayoutsChanged) | 70 | else if (event.WindowLayoutsChanged) |
68 | eventWindowLayoutsChanged(event.WindowLayoutsChanged); | 71 | eventWindowLayoutsChanged(event.WindowLayoutsChanged); |
72 | else if (event.Ok && !eventStreamSocket.acked) { eventStreamSocket.acked = true; } | ||
73 | else if (event.OverviewOpenedOrClosed) {} | ||
74 | else if (event.ConfigLoaded) {} | ||
69 | else | 75 | else |
70 | console.log(JSON.stringify(event)); | 76 | console.log(JSON.stringify(event)); |
71 | } catch (e) { | 77 | } catch (e) { |
@@ -154,7 +160,11 @@ Singleton { | |||
154 | }); | 160 | }); |
155 | } | 161 | } |
156 | function eventWindowOpenedOrChanged(data) { | 162 | function eventWindowOpenedOrChanged(data) { |
157 | root.windows = Array.from(root.windows).filter(win => win.id !== data.window.id).concat([data.window]); | 163 | root.windows = Array.from(root.windows).map(win => { |
164 | if (data.window.is_focused) | ||
165 | win.is_focused = false; | ||
166 | return win; | ||
167 | }).filter(win => win.id !== data.window.id).concat([data.window]); | ||
158 | } | 168 | } |
159 | function eventWindowClosed(data) { | 169 | function eventWindowClosed(data) { |
160 | root.windows = Array.from(root.windows).filter(win => win.id !== data.id); | 170 | root.windows = Array.from(root.windows).filter(win => win.id !== data.id); |
diff --git a/accounts/gkleen@sif/shell/quickshell/Services/WallpaperSelector.qml b/accounts/gkleen@sif/shell/quickshell/Services/WallpaperSelector.qml new file mode 100644 index 00000000..3c524955 --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/Services/WallpaperSelector.qml | |||
@@ -0,0 +1,8 @@ | |||
1 | import Custom as Custom | ||
2 | |||
3 | Custom.FileSelector { | ||
4 | id: root | ||
5 | |||
6 | directory: @wallpapers@ | ||
7 | epoch: 72000000 | ||
8 | } | ||
diff --git a/accounts/gkleen@sif/shell/quickshell/SystemTray.qml b/accounts/gkleen@sif/shell/quickshell/SystemTray.qml index afed4bf0..55b1690e 100644 --- a/accounts/gkleen@sif/shell/quickshell/SystemTray.qml +++ b/accounts/gkleen@sif/shell/quickshell/SystemTray.qml | |||
@@ -17,13 +17,17 @@ Item { | |||
17 | spacing: 0 | 17 | spacing: 0 |
18 | 18 | ||
19 | Repeater { | 19 | Repeater { |
20 | model: { | 20 | model: ScriptModel { |
21 | var trayItems = Array.from(SystemTray.items.values).filter(item => item.status !== Status.Passive); | 21 | values: { |
22 | trayItems.sort((a, b) => a.category !== b.category ? b.category - a.category : a.id.localeCompare(b.id)) | 22 | var trayItems = Array.from(SystemTray.items.values).filter(item => item.status !== Status.Passive); |
23 | return trayItems; | 23 | trayItems.sort((a, b) => a.category !== b.category ? b.category - a.category : a.id.localeCompare(b.id)) |
24 | return trayItems; | ||
25 | } | ||
24 | } | 26 | } |
25 | 27 | ||
26 | delegate: Item { | 28 | delegate: Item { |
29 | id: trayItemWrapper | ||
30 | |||
27 | property var trayItem: modelData | 31 | property var trayItem: modelData |
28 | property string iconSource: { | 32 | property string iconSource: { |
29 | let icon = trayItem && trayItem.icon | 33 | let icon = trayItem && trayItem.icon |
@@ -47,17 +51,7 @@ Item { | |||
47 | height: parent.height | 51 | height: parent.height |
48 | anchors.verticalCenter: parent.verticalCenter | 52 | anchors.verticalCenter: parent.verticalCenter |
49 | 53 | ||
50 | IconImage { | 54 | WrapperMouseArea { |
51 | anchors.centerIn: parent | ||
52 | width: parent.width | ||
53 | height: parent.width | ||
54 | source: parent.iconSource | ||
55 | asynchronous: true | ||
56 | smooth: true | ||
57 | mipmap: true | ||
58 | } | ||
59 | |||
60 | MouseArea { | ||
61 | id: trayItemArea | 55 | id: trayItemArea |
62 | 56 | ||
63 | anchors.fill: parent | 57 | anchors.fill: parent |
@@ -88,21 +82,48 @@ Item { | |||
88 | menuAnchor.open() | 82 | menuAnchor.open() |
89 | } | 83 | } |
90 | } | 84 | } |
85 | |||
86 | IconImage { | ||
87 | anchors.centerIn: parent | ||
88 | width: parent.width | ||
89 | height: parent.width | ||
90 | source: trayItemWrapper.iconSource | ||
91 | asynchronous: true | ||
92 | smooth: true | ||
93 | mipmap: true | ||
94 | } | ||
91 | } | 95 | } |
92 | 96 | ||
93 | PopupWindow { | 97 | PopupWindow { |
98 | id: tooltip | ||
99 | |||
100 | property bool nextVisible: (trayItem.tooltipTitle || trayItem.tooltipDescription) && (trayItemArea.containsMouse || tooltipMouseArea.containsMouse) && !menuAnchor.visible | ||
101 | |||
94 | anchor { | 102 | anchor { |
95 | item: trayItemArea | 103 | item: trayItemArea |
96 | edges: Edges.Bottom | 104 | edges: Edges.Bottom |
97 | } | 105 | } |
98 | visible: (trayItem.tooltipTitle || trayItem.tooltipDescription) && trayItemArea.containsMouse && !menuAnchor.visible | 106 | |
107 | visible: false | ||
108 | onNextVisibleChanged: hangTimer.restart() | ||
109 | |||
110 | Timer { | ||
111 | id: hangTimer | ||
112 | interval: 100 | ||
113 | onTriggered: tooltip.visible = tooltip.nextVisible | ||
114 | } | ||
99 | 115 | ||
100 | color: "black" | 116 | color: "black" |
101 | 117 | ||
102 | implicitWidth: Math.max(tooltipTitle.contentWidth, tooltipDescription.contentWidth) + 16 | 118 | implicitWidth: Math.max(tooltipTitle.contentWidth, tooltipDescription.contentWidth) + 16 |
103 | implicitHeight: tooltipTitle.contentHeight + tooltipDescription.contentHeight + 16 | 119 | implicitHeight: tooltipTitle.contentHeight + tooltipDescription.contentHeight + 16 |
104 | 120 | ||
105 | WrapperItem { | 121 | WrapperMouseArea { |
122 | id: tooltipMouseArea | ||
123 | |||
124 | hoverEnabled: true | ||
125 | enabled: true | ||
126 | |||
106 | margin: 8 | 127 | margin: 8 |
107 | 128 | ||
108 | Column { | 129 | Column { |
diff --git a/accounts/gkleen@sif/shell/quickshell/WallpaperBackground.qml b/accounts/gkleen@sif/shell/quickshell/WallpaperBackground.qml new file mode 100644 index 00000000..de31915f --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/WallpaperBackground.qml | |||
@@ -0,0 +1,85 @@ | |||
1 | import QtQuick | ||
2 | import Quickshell | ||
3 | import qs.Services | ||
4 | |||
5 | Item { | ||
6 | id: root | ||
7 | |||
8 | anchors.fill: parent | ||
9 | |||
10 | required property string screen | ||
11 | |||
12 | property Img current: one | ||
13 | property string source: selector.selected | ||
14 | |||
15 | WallpaperSelector { | ||
16 | id: selector | ||
17 | seed: screen | ||
18 | } | ||
19 | |||
20 | onSourceChanged: { | ||
21 | if (!source) | ||
22 | current = null; | ||
23 | else if (current === one) | ||
24 | two.update() | ||
25 | else | ||
26 | one.update() | ||
27 | } | ||
28 | |||
29 | Img { id: one } | ||
30 | Img { id: two } | ||
31 | |||
32 | component Img: Image { | ||
33 | id: img | ||
34 | |||
35 | function update() { | ||
36 | source = root.source || "" | ||
37 | } | ||
38 | |||
39 | anchors.fill: parent | ||
40 | fillMode: Image.PreserveAspectCrop | ||
41 | smooth: true | ||
42 | asynchronous: true | ||
43 | cache: false | ||
44 | |||
45 | opacity: 0 | ||
46 | |||
47 | onStatusChanged: { | ||
48 | if (status === Image.Ready) { | ||
49 | root.current = this | ||
50 | } | ||
51 | } | ||
52 | |||
53 | states: State { | ||
54 | name: "visible" | ||
55 | when: root.current === img | ||
56 | |||
57 | PropertyChanges { | ||
58 | img.opacity: 1 | ||
59 | } | ||
60 | StateChangeScript { | ||
61 | name: "unloadOther" | ||
62 | script: { | ||
63 | if (img === one) | ||
64 | two.source = "" | ||
65 | if (img === two) | ||
66 | one.source = "" | ||
67 | } | ||
68 | } | ||
69 | } | ||
70 | |||
71 | transitions: Transition { | ||
72 | SequentialAnimation { | ||
73 | NumberAnimation { | ||
74 | target: img | ||
75 | properties: "opacity" | ||
76 | duration: 5000 | ||
77 | easing.type: Easing.OutCubic | ||
78 | } | ||
79 | ScriptAction { | ||
80 | scriptName: "unloadOther" | ||
81 | } | ||
82 | } | ||
83 | } | ||
84 | } | ||
85 | } | ||
diff --git a/accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml b/accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml index 153c56bb..c8c017c3 100644 --- a/accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml +++ b/accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml | |||
@@ -1,5 +1,8 @@ | |||
1 | import Quickshell | ||
1 | import QtQuick | 2 | import QtQuick |
2 | import qs.Services | 3 | import qs.Services |
4 | import Quickshell.Widgets | ||
5 | import QtQuick.Layouts | ||
3 | 6 | ||
4 | Row { | 7 | Row { |
5 | id: workspaces | 8 | id: workspaces |
@@ -11,61 +14,188 @@ Row { | |||
11 | spacing: 0 | 14 | spacing: 0 |
12 | 15 | ||
13 | Repeater { | 16 | Repeater { |
14 | model: { | 17 | model: ScriptModel { |
15 | let currWorkspaces = NiriService.workspaces; | 18 | values: { |
16 | const ignoreWorkspaces = Array.from(workspaces.ignoreWorkspaces); | 19 | let currWorkspaces = NiriService.workspaces; |
17 | currWorkspaces = currWorkspaces.filter(ws => ws.is_active || ignoreWorkspaces.every(iws => iws !== ws.name)); | 20 | const ignoreWorkspaces = Array.from(workspaces.ignoreWorkspaces); |
18 | currWorkspaces.sort((a, b) => { | 21 | 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) | 22 | currWorkspaces.sort((a, b) => { |
20 | return NiriService.outputs?.[a.output]?.logical?.x - NiriService.outputs?.[b.output]?.logical?.x | 23 | 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) | 24 | 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 | 25 | if (NiriService.outputs?.[a.output]?.logical?.y !== NiriService.outputs?.[b.output]?.logical?.y) |
23 | return a.idx - b.idx; | 26 | return NiriService.outputs?.[a.output]?.logical?.y - NiriService.outputs?.[b.output]?.logical?.y |
24 | }); | 27 | return a.idx - b.idx; |
25 | return currWorkspaces; | 28 | }); |
29 | return currWorkspaces; | ||
30 | } | ||
26 | } | 31 | } |
27 | 32 | ||
28 | Rectangle { | 33 | Item { |
34 | id: wsItem | ||
35 | |||
29 | property var workspaceData: modelData | 36 | property var workspaceData: modelData |
30 | 37 | ||
31 | width: wsLabel.contentWidth + 8 | 38 | width: wsLabel.contentWidth + 8 |
32 | color: { | ||
33 | if (mouseArea.containsMouse) { | ||
34 | return "#33808080"; | ||
35 | } | ||
36 | return "transparent"; | ||
37 | } | ||
38 | height: parent.height | 39 | height: parent.height |
39 | anchors.verticalCenter: parent.verticalCenter | 40 | anchors.verticalCenter: parent.verticalCenter |
40 | 41 | ||
41 | MouseArea { | 42 | WrapperMouseArea { |
42 | id: mouseArea | 43 | id: mouseArea |
43 | 44 | ||
44 | anchors.fill: parent | 45 | anchors.fill: parent |
46 | |||
45 | hoverEnabled: true | 47 | hoverEnabled: true |
46 | cursorShape: Qt.PointingHandCursor | 48 | cursorShape: Qt.PointingHandCursor |
47 | enabled: true | 49 | enabled: true |
48 | onClicked: { | 50 | onClicked: { |
49 | NiriService.sendCommand({ "Action": { "FocusWorkspace": { "reference": { "Id": workspaceData.id } } } }, _ => {}) | 51 | NiriService.sendCommand({ "Action": { "FocusWorkspace": { "reference": { "Id": workspaceData.id } } } }, _ => {}) |
50 | } | 52 | } |
53 | |||
54 | Rectangle { | ||
55 | anchors.fill: parent | ||
56 | |||
57 | color: { | ||
58 | if (mouseArea.containsMouse) { | ||
59 | return "#33808080"; | ||
60 | } | ||
61 | return "transparent"; | ||
62 | } | ||
63 | |||
64 | Text { | ||
65 | id: wsLabel | ||
66 | |||
67 | anchors.centerIn: parent | ||
68 | |||
69 | font.pointSize: 10 | ||
70 | font.family: "Fira Sans" | ||
71 | color: { | ||
72 | if (workspaceData.is_active) | ||
73 | return "#23fd00"; | ||
74 | if (workspaceData.active_window_id === null) | ||
75 | return "#555"; | ||
76 | return "white"; | ||
77 | } | ||
78 | |||
79 | text: workspaceData.name ? workspaceData.name : workspaceData.idx | ||
80 | } | ||
81 | } | ||
51 | } | 82 | } |
52 | 83 | ||
53 | Text { | 84 | PopupWindow { |
54 | id: wsLabel | 85 | id: tooltip |
55 | 86 | ||
56 | font.pointSize: 10 | 87 | property bool nextVisible: (mouseArea.containsMouse || tooltipMouseArea.containsMouse) && [...windowsModel.values].length > 0 |
57 | font.family: "Fira Sans" | 88 | |
58 | color: { | 89 | anchor { |
59 | if (workspaceData.is_active) | 90 | item: mouseArea |
60 | return "#23fd00"; | 91 | edges: Edges.Bottom | Edges.Left |
61 | if (workspaceData.active_window_id === null) | 92 | } |
62 | return "#555"; | 93 | visible: false |
63 | return "white"; | 94 | |
95 | onNextVisibleChanged: hangTimer.restart() | ||
96 | |||
97 | Timer { | ||
98 | id: hangTimer | ||
99 | interval: 100 | ||
100 | onTriggered: tooltip.visible = tooltip.nextVisible | ||
64 | } | 101 | } |
65 | anchors.centerIn: parent | ||
66 | 102 | ||
67 | text: workspaceData.name ? workspaceData.name : workspaceData.idx | 103 | implicitWidth: tooltipContent.implicitWidth |
104 | implicitHeight: tooltipContent.implicitHeight | ||
105 | color: "black" | ||
106 | |||
107 | WrapperMouseArea { | ||
108 | id: tooltipMouseArea | ||
109 | |||
110 | hoverEnabled: true | ||
111 | enabled: true | ||
112 | |||
113 | anchors.fill: parent | ||
114 | |||
115 | WrapperItem { | ||
116 | id: tooltipContent | ||
117 | |||
118 | margin: 0 | ||
119 | |||
120 | ColumnLayout { | ||
121 | spacing: 0 | ||
122 | |||
123 | Repeater { | ||
124 | model: ScriptModel { | ||
125 | id: windowsModel | ||
126 | |||
127 | values: { | ||
128 | let currWindows = Array.from(NiriService.windows).filter(win => win.workspace_id == wsItem.workspaceData.id); | ||
129 | currWindows.sort((a, b) => { | ||
130 | if (a.is_floating !== b.is_floating) | ||
131 | return b.is_floating - a.is_floating; | ||
132 | if (a.layout.tile_pos_in_workspace_view?.[0] !== b.layout.tile_pos_in_workspace_view?.[0]) | ||
133 | return a.layout.tile_pos_in_workspace_view?.[0] - b.layout.tile_pos_in_workspace_view?.[0] | ||
134 | if (a.layout.tile_pos_in_workspace_view?.[1] !== b.layout.tile_pos_in_workspace_view?.[1]) | ||
135 | return a.layout.tile_pos_in_workspace_view?.[1] - b.layout.tile_pos_in_workspace_view?.[1] | ||
136 | if (a.layout.pos_in_scrolling_layout?.[0] !== b.layout.pos_in_scrolling_layout?.[0]) | ||
137 | return a.layout.pos_in_scrolling_layout?.[0] - b.layout.pos_in_scrolling_layout?.[0] | ||
138 | if (a.layout.pos_in_scrolling_layout?.[1] !== b.layout.pos_in_scrolling_layout?.[1]) | ||
139 | return a.layout.pos_in_scrolling_layout?.[1] - b.layout.pos_in_scrolling_layout?.[1] | ||
140 | if (a.app_id !== b.app_id) | ||
141 | return a.app_id.localeCompare(b.app_id); | ||
142 | |||
143 | return a.title.localeCompare(b.title); | ||
144 | }); | ||
145 | return currWindows; | ||
146 | } | ||
147 | } | ||
148 | |||
149 | WrapperMouseArea { | ||
150 | id: windowMouseArea | ||
151 | |||
152 | property var windowData: modelData | ||
153 | |||
154 | hoverEnabled: true | ||
155 | cursorShape: Qt.PointingHandCursor | ||
156 | enabled: true | ||
157 | |||
158 | Layout.fillWidth: true | ||
159 | |||
160 | onClicked: { | ||
161 | NiriService.sendCommand({ "Action": { "FocusWindow": { "id": windowData.id } } }, _ => {}) | ||
162 | } | ||
163 | |||
164 | WrapperRectangle { | ||
165 | color: windowMouseArea.containsMouse ? "#33808080" : "transparent"; | ||
166 | |||
167 | anchors.fill: parent | ||
168 | |||
169 | WrapperItem { | ||
170 | anchors.fill: parent | ||
171 | |||
172 | margin: 4 | ||
173 | |||
174 | Text { | ||
175 | id: windowLabel | ||
176 | |||
177 | font.pointSize: 10 | ||
178 | font.family: "Fira Sans" | ||
179 | color: { | ||
180 | if (windowData.is_focused) | ||
181 | return "#23fd00"; | ||
182 | if (NiriService.workspaces.find(ws => ws.id == windowData.workspace_id)?.active_window_id == windowData.id) | ||
183 | return "white"; | ||
184 | return "#555"; | ||
185 | } | ||
186 | |||
187 | text: windowData.title | ||
188 | |||
189 | horizontalAlignment: Text.AlignLeft | ||
190 | } | ||
191 | } | ||
192 | } | ||
193 | } | ||
194 | } | ||
195 | } | ||
196 | } | ||
197 | } | ||
68 | } | 198 | } |
69 | } | 199 | } |
70 | } | 200 | } |
71 | } \ No newline at end of file | 201 | } |
diff --git a/accounts/gkleen@sif/shell/quickshell/displaymanager.qml b/accounts/gkleen@sif/shell/quickshell/displaymanager.qml new file mode 100644 index 00000000..b452c03d --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/displaymanager.qml | |||
@@ -0,0 +1,115 @@ | |||
1 | //@ pragma UseQApplication | ||
2 | |||
3 | import Quickshell | ||
4 | import Quickshell.Wayland | ||
5 | import Quickshell.Io | ||
6 | import Quickshell.Services.Greetd | ||
7 | import QtQml | ||
8 | |||
9 | |||
10 | ShellRoot { | ||
11 | id: displaymanager | ||
12 | |||
13 | settings.watchFiles: false | ||
14 | |||
15 | property string currentText: "" | ||
16 | property string username: @username@ | ||
17 | property list<string> command: @niri_session@ | ||
18 | property list<var> messages: [] | ||
19 | property bool responseRequired: false | ||
20 | property bool responseVisible: false | ||
21 | |||
22 | signal startAuth() | ||
23 | |||
24 | onStartAuth: { | ||
25 | if (Greetd.state !== GreetdState.Inactive) | ||
26 | Greetd.cancelSession(); | ||
27 | displaymanager.messages = []; | ||
28 | Greetd.createSession(displaymanager.username); | ||
29 | } | ||
30 | |||
31 | Connections { | ||
32 | target: Greetd | ||
33 | function onStateChanged() { | ||
34 | console.log("greetd state: ", GreetdState.toString(Greetd.state)); | ||
35 | if (Greetd.state === GreetdState.ReadyToLaunch) | ||
36 | Greetd.launch(displaymanager.command); | ||
37 | } | ||
38 | function onAuthMessage(message: string, error: bool, responseRequired: bool, echoResponse: bool) { | ||
39 | displaymanager.responseVisible = echoResponse; | ||
40 | displaymanager.responseRequired = responseRequired; | ||
41 | displaymanager.messages = Array.from(displaymanager.messages).concat([{ "text": message, "error": error }]); | ||
42 | } | ||
43 | function onAuthFailure(message: string) { | ||
44 | displaymanager.responseRequired = false; | ||
45 | displaymanager.messages = Array.from(displaymanager.messages).concat([{ "text": message, "error": true }]); | ||
46 | } | ||
47 | } | ||
48 | |||
49 | Component.onCompleted: { | ||
50 | if (Greetd.state !== GreetdState.Inactive) | ||
51 | Greetd.cancelSession(); | ||
52 | } | ||
53 | |||
54 | Variants { | ||
55 | model: Quickshell.screens | ||
56 | |||
57 | delegate: Scope { | ||
58 | id: screenScope | ||
59 | |||
60 | required property var modelData | ||
61 | |||
62 | PanelWindow { | ||
63 | color: "black" | ||
64 | |||
65 | screen: screenScope.modelData | ||
66 | |||
67 | WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive | ||
68 | |||
69 | anchors.top: true | ||
70 | anchors.bottom: true | ||
71 | anchors.left: true | ||
72 | anchors.right: true | ||
73 | |||
74 | LockSurface { | ||
75 | id: surfaceContent | ||
76 | |||
77 | screen: screenScope.modelData | ||
78 | |||
79 | onCurrentTextChanged: displaymanager.currentText = currentText | ||
80 | Connections { | ||
81 | target: displaymanager | ||
82 | function onCurrentTextChanged() { surfaceContent.currentText = displaymanager.currentText; } | ||
83 | function onMessagesChanged() { surfaceContent.messages = Array.from(displaymanager.messages); } | ||
84 | function onResponseRequiredChanged() { surfaceContent.responseRequired = displaymanager.responseRequired; } | ||
85 | function onResponseVisibleChanged() { surfaceContent.responseVisible = displaymanager.responseVisible; } | ||
86 | } | ||
87 | |||
88 | onResponse: responseText => Greetd.respond(responseText); | ||
89 | Connections { | ||
90 | target: Greetd | ||
91 | function onStateChanged() { | ||
92 | if (Greetd.state === GreetdState.Authenticating) { | ||
93 | surfaceContent.authRunning = true; | ||
94 | } else { | ||
95 | surfaceContent.authRunning = false; | ||
96 | } | ||
97 | } | ||
98 | } | ||
99 | |||
100 | onAuthRunningChanged: { | ||
101 | if (surfaceContent.authRunning && Greetd.state !== GreetdState.Authenticating) | ||
102 | displaymanager.startAuth(); | ||
103 | } | ||
104 | Component.onCompleted: { | ||
105 | surfaceContent.authRunning = Greetd.state === GreetdState.Authenticating | ||
106 | surfaceContent.messages = Array.from(displaymanager.messages); | ||
107 | surfaceContent.responseVisible = displaymanager.responseVisible; | ||
108 | surfaceContent.responseRequired = displaymanager.responseRequired; | ||
109 | surfaceContent.currentText = displaymanager.currentText; | ||
110 | } | ||
111 | } | ||
112 | } | ||
113 | } | ||
114 | } | ||
115 | } | ||
diff --git a/accounts/gkleen@sif/shell/quickshell/shell.qml b/accounts/gkleen@sif/shell/quickshell/shell.qml index 2abd1fef..1da9457d 100644 --- a/accounts/gkleen@sif/shell/quickshell/shell.qml +++ b/accounts/gkleen@sif/shell/quickshell/shell.qml | |||
@@ -1,6 +1,7 @@ | |||
1 | //@ pragma UseQApplication | 1 | //@ pragma UseQApplication |
2 | 2 | ||
3 | import Quickshell | 3 | import Quickshell |
4 | import Quickshell.Wayland | ||
4 | 5 | ||
5 | ShellRoot { | 6 | ShellRoot { |
6 | settings.watchFiles: false | 7 | settings.watchFiles: false |
@@ -8,8 +9,36 @@ ShellRoot { | |||
8 | Variants { | 9 | Variants { |
9 | model: Quickshell.screens | 10 | model: Quickshell.screens |
10 | 11 | ||
11 | delegate: Bar { | 12 | delegate: Scope { |
12 | modelData: item | 13 | id: screenScope |
14 | |||
15 | required property var modelData | ||
16 | |||
17 | PanelWindow { | ||
18 | id: bgWindow | ||
19 | |||
20 | screen: screenScope.modelData | ||
21 | |||
22 | WlrLayershell.layer: WlrLayer.Background | ||
23 | WlrLayershell.exclusionMode: ExclusionMode.Ignore | ||
24 | |||
25 | anchors.top: true | ||
26 | anchors.bottom: true | ||
27 | anchors.left: true | ||
28 | anchors.right: true | ||
29 | |||
30 | color: "black" | ||
31 | |||
32 | WallpaperBackground { | ||
33 | screen: bgWindow.screen.name | ||
34 | } | ||
35 | } | ||
36 | |||
37 | Bar { | ||
38 | screen: screenScope.modelData | ||
39 | } | ||
13 | } | 40 | } |
14 | } | 41 | } |
42 | |||
43 | Lockscreen {} | ||
15 | } | 44 | } |