From 85bf62eaa2fd71eb15ef401e537457fb9098a540 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Mon, 1 Sep 2025 15:12:09 +0200 Subject: ... --- accounts/gkleen@sif/shell/quickshell/Clock.qml | 30 +++++--- .../gkleen@sif/shell/quickshell/KeyboardLayout.qml | 53 ++++++++------ .../gkleen@sif/shell/quickshell/SystemTray.qml | 10 ++- .../shell/quickshell/WorkspaceSwitcher.qml | 85 +++++++++++++--------- 4 files changed, 102 insertions(+), 76 deletions(-) diff --git a/accounts/gkleen@sif/shell/quickshell/Clock.qml b/accounts/gkleen@sif/shell/quickshell/Clock.qml index 55fabd1c..d645cfa7 100644 --- a/accounts/gkleen@sif/shell/quickshell/Clock.qml +++ b/accounts/gkleen@sif/shell/quickshell/Clock.qml @@ -7,6 +7,8 @@ import QtQuick.Layouts import Quickshell.Widgets Item { + id: clockItem + width: clock.contentWidth height: parent.height anchors.verticalCenter: parent.verticalCenter @@ -30,22 +32,26 @@ Item { onWheel: event => scrollYear(event) - Text { - id: clock - color: "white" + Item { + anchors.fill: parent - anchors.verticalCenter: parent.verticalCenter + Text { + id: clock + color: "white" - Custom.Chrono { - id: chrono - format: "W{0:%V-%u} {0:%F} {0:%H:%M:%S%Ez}" - } + anchors.verticalCenter: parent.verticalCenter - text: chrono.date + Custom.Chrono { + id: chrono + format: "W{0:%V-%u} {0:%F} {0:%H:%M:%S%Ez}" + } + + text: chrono.date - font.pointSize: 10 - font.family: "Fira Sans" - font.features: { "tnum": 1 } + font.pointSize: 10 + font.family: "Fira Sans" + font.features: { "tnum": 1 } + } } } diff --git a/accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml b/accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml index 4a6b8390..bc3750f9 100644 --- a/accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml +++ b/accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml @@ -3,18 +3,8 @@ import QtQuick import qs.Services import Quickshell.Widgets -Rectangle { - id: kbdWidget - - property var keyboardAbbrev: { "English (programmer Dvorak)": "dvp", "English (US)": "us" } - +Item { width: kbdLabel.contentWidth + 8 - color: { - if (kbdMouseArea.containsMouse) { - return "#33808080"; - } - return "transparent"; - } height: parent.height anchors.verticalCenter: parent.verticalCenter @@ -22,6 +12,7 @@ Rectangle { id: kbdMouseArea anchors.fill: parent + hoverEnabled: true cursorShape: Qt.PointingHandCursor enabled: true @@ -32,23 +23,37 @@ Rectangle { NiriService.sendCommand({ "Action": { "SwitchLayout": { "layout": event.angleDelta > 0 ? "Next" : "Prev" } } }, _ => {}) } - Text { - id: kbdLabel + Rectangle { + id: kbdWidget - font.pointSize: 10 - font.family: "Fira Sans" + property var keyboardAbbrev: { "English (programmer Dvorak)": "dvp", "English (US)": "us" } + + anchors.fill: parent color: { - if (NiriService.keyboardLayouts?.current_idx === 0) - return "#555"; - return "white"; + if (kbdMouseArea.containsMouse) { + return "#33808080"; + } + return "transparent"; } - anchors.centerIn: parent - text: { - const currentLayout = NiriService.keyboardLayouts?.names?.[NiriService.keyboardLayouts.current_idx]; - if (!currentLayout) - return ""; - return kbdWidget.keyboardAbbrev[currentLayout] ? kbdWidget.keyboardAbbrev[currentLayout] : currentLayout; + Text { + id: kbdLabel + + font.pointSize: 10 + font.family: "Fira Sans" + color: { + if (NiriService.keyboardLayouts?.current_idx === 0) + return "#555"; + return "white"; + } + anchors.centerIn: parent + + text: { + const currentLayout = NiriService.keyboardLayouts?.names?.[NiriService.keyboardLayouts.current_idx]; + if (!currentLayout) + return ""; + return kbdWidget.keyboardAbbrev[currentLayout] ? kbdWidget.keyboardAbbrev[currentLayout] : currentLayout; + } } } } diff --git a/accounts/gkleen@sif/shell/quickshell/SystemTray.qml b/accounts/gkleen@sif/shell/quickshell/SystemTray.qml index 024026a3..55b1690e 100644 --- a/accounts/gkleen@sif/shell/quickshell/SystemTray.qml +++ b/accounts/gkleen@sif/shell/quickshell/SystemTray.qml @@ -17,10 +17,12 @@ Item { spacing: 0 Repeater { - model: { - var trayItems = Array.from(SystemTray.items.values).filter(item => item.status !== Status.Passive); - trayItems.sort((a, b) => a.category !== b.category ? b.category - a.category : a.id.localeCompare(b.id)) - return trayItems; + model: ScriptModel { + values: { + var trayItems = Array.from(SystemTray.items.values).filter(item => item.status !== Status.Passive); + trayItems.sort((a, b) => a.category !== b.category ? b.category - a.category : a.id.localeCompare(b.id)) + return trayItems; + } } delegate: Item { 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 @@ +import Quickshell import QtQuick import qs.Services +import Quickshell.Widgets Row { id: workspaces @@ -11,61 +13,72 @@ Row { spacing: 0 Repeater { - model: { - let currWorkspaces = NiriService.workspaces; - const ignoreWorkspaces = Array.from(workspaces.ignoreWorkspaces); - currWorkspaces = currWorkspaces.filter(ws => ws.is_active || ignoreWorkspaces.every(iws => iws !== ws.name)); - currWorkspaces.sort((a, b) => { - if (NiriService.outputs?.[a.output]?.logical?.x !== NiriService.outputs?.[b.output]?.logical?.x) - return NiriService.outputs?.[a.output]?.logical?.x - NiriService.outputs?.[b.output]?.logical?.x - if (NiriService.outputs?.[a.output]?.logical?.y !== NiriService.outputs?.[b.output]?.logical?.y) - return NiriService.outputs?.[a.output]?.logical?.y - NiriService.outputs?.[b.output]?.logical?.y - return a.idx - b.idx; - }); - return currWorkspaces; + model: ScriptModel { + values: { + let currWorkspaces = NiriService.workspaces; + const ignoreWorkspaces = Array.from(workspaces.ignoreWorkspaces); + currWorkspaces = currWorkspaces.filter(ws => ws.is_active || ignoreWorkspaces.every(iws => iws !== ws.name)); + currWorkspaces.sort((a, b) => { + if (NiriService.outputs?.[a.output]?.logical?.x !== NiriService.outputs?.[b.output]?.logical?.x) + return NiriService.outputs?.[a.output]?.logical?.x - NiriService.outputs?.[b.output]?.logical?.x + if (NiriService.outputs?.[a.output]?.logical?.y !== NiriService.outputs?.[b.output]?.logical?.y) + return NiriService.outputs?.[a.output]?.logical?.y - NiriService.outputs?.[b.output]?.logical?.y + return a.idx - b.idx; + }); + return currWorkspaces; + } } - Rectangle { + Item { + id: wsItem + property var workspaceData: modelData width: wsLabel.contentWidth + 8 - color: { - if (mouseArea.containsMouse) { - return "#33808080"; - } - return "transparent"; - } height: parent.height anchors.verticalCenter: parent.verticalCenter - MouseArea { + WrapperMouseArea { id: mouseArea anchors.fill: parent + hoverEnabled: true cursorShape: Qt.PointingHandCursor enabled: true onClicked: { NiriService.sendCommand({ "Action": { "FocusWorkspace": { "reference": { "Id": workspaceData.id } } } }, _ => {}) } - } - Text { - id: wsLabel - - font.pointSize: 10 - font.family: "Fira Sans" - color: { - if (workspaceData.is_active) - return "#23fd00"; - if (workspaceData.active_window_id === null) - return "#555"; - return "white"; - } - anchors.centerIn: parent + Rectangle { + anchors.fill: parent + + color: { + if (mouseArea.containsMouse) { + return "#33808080"; + } + return "transparent"; + } + + Text { + id: wsLabel - text: workspaceData.name ? workspaceData.name : workspaceData.idx + anchors.centerIn: parent + + font.pointSize: 10 + font.family: "Fira Sans" + color: { + if (workspaceData.is_active) + return "#23fd00"; + if (workspaceData.active_window_id === null) + return "#555"; + return "white"; + } + + text: workspaceData.name ? workspaceData.name : workspaceData.idx + } + } } } } -} \ No newline at end of file +} -- cgit v1.2.3