From 6eebd15c1eef2fa9dafccdd4036ad23800e1154c Mon Sep 17 00:00:00 2001 From: ATMDA Date: Thu, 13 Nov 2025 21:38:46 -0500 Subject: tray: consolidating ethernet into network --- modules/bar/components/StatusIcons.qml | 6 +- modules/bar/popouts/Content.qml | 5 - modules/bar/popouts/Ethernet.qml | 179 --------------------------------- modules/bar/popouts/Network.qml | 110 ++++++++++++++++++++ 4 files changed, 113 insertions(+), 187 deletions(-) delete mode 100644 modules/bar/popouts/Ethernet.qml (limited to 'modules/bar') diff --git a/modules/bar/components/StatusIcons.qml b/modules/bar/components/StatusIcons.qml index 6113539..1afa616 100644 --- a/modules/bar/components/StatusIcons.qml +++ b/modules/bar/components/StatusIcons.qml @@ -147,15 +147,15 @@ StyledRect { sourceComponent: MaterialIcon { animate: true - text: Network.active ? Icons.getNetworkIcon(Network.active.strength ?? 0) : "wifi_off" + text: Nmcli.active ? Icons.getNetworkIcon(Nmcli.active.strength ?? 0) : "wifi_off" color: root.colour } } // Ethernet icon WrappedLoader { - name: "ethernet" - active: Config.bar.status.showEthernet && Network.activeEthernet + name: "network" + active: Config.bar.status.showEthernet && Nmcli.activeEthernet sourceComponent: MaterialIcon { animate: true diff --git a/modules/bar/popouts/Content.qml b/modules/bar/popouts/Content.qml index f8ef549..e3f569d 100644 --- a/modules/bar/popouts/Content.qml +++ b/modules/bar/popouts/Content.qml @@ -36,11 +36,6 @@ Item { sourceComponent: Network {} } - Popout { - name: "ethernet" - sourceComponent: Ethernet {} - } - Popout { name: "bluetooth" sourceComponent: Bluetooth { diff --git a/modules/bar/popouts/Ethernet.qml b/modules/bar/popouts/Ethernet.qml deleted file mode 100644 index b4a753c..0000000 --- a/modules/bar/popouts/Ethernet.qml +++ /dev/null @@ -1,179 +0,0 @@ -pragma ComponentBehavior: Bound - -import qs.components -import qs.components.controls -import qs.services -import qs.config -import qs.utils -import Quickshell -import QtQuick -import QtQuick.Layouts - -ColumnLayout { - id: root - - spacing: Appearance.spacing.small - width: Config.bar.sizes.networkWidth - - StyledText { - Layout.topMargin: Appearance.padding.normal - Layout.rightMargin: Appearance.padding.small - text: qsTr("Ethernet") - font.weight: 500 - } - - StyledText { - Layout.topMargin: Appearance.spacing.small - Layout.rightMargin: Appearance.padding.small - text: qsTr("%1 devices available").arg(Network.ethernetDeviceCount || Network.ethernetDevices.length) - color: Colours.palette.m3onSurfaceVariant - font.pointSize: Appearance.font.size.small - } - - Repeater { - model: ScriptModel { - values: [...Network.ethernetDevices].sort((a, b) => { - if (a.connected !== b.connected) - return b.connected - a.connected; - return (a.interface || "").localeCompare(b.interface || ""); - }).slice(0, 8) - } - - RowLayout { - id: ethernetItem - - required property var modelData - readonly property bool loading: false - - Layout.fillWidth: true - Layout.rightMargin: Appearance.padding.small - spacing: Appearance.spacing.small - - opacity: 0 - scale: 0.7 - - Component.onCompleted: { - opacity = 1; - scale = 1; - } - - Behavior on opacity { - Anim {} - } - - Behavior on scale { - Anim {} - } - - MaterialIcon { - text: "cable" - color: ethernetItem.modelData.connected ? Colours.palette.m3primary : Colours.palette.m3onSurfaceVariant - } - - StyledText { - Layout.leftMargin: Appearance.spacing.small / 2 - Layout.rightMargin: Appearance.spacing.small / 2 - Layout.fillWidth: true - text: ethernetItem.modelData.interface || qsTr("Unknown") - elide: Text.ElideRight - font.weight: ethernetItem.modelData.connected ? 500 : 400 - color: ethernetItem.modelData.connected ? Colours.palette.m3primary : Colours.palette.m3onSurface - } - - StyledRect { - id: connectBtn - - implicitWidth: implicitHeight - implicitHeight: connectIcon.implicitHeight + Appearance.padding.small - - radius: Appearance.rounding.full - color: Qt.alpha(Colours.palette.m3primary, ethernetItem.modelData.connected ? 1 : 0) - - CircularIndicator { - anchors.fill: parent - running: ethernetItem.loading - } - - StateLayer { - color: ethernetItem.modelData.connected ? Colours.palette.m3onPrimary : Colours.palette.m3onSurface - disabled: ethernetItem.loading - - function onClicked(): void { - if (ethernetItem.modelData.connected && ethernetItem.modelData.connection) { - Network.disconnectEthernet(ethernetItem.modelData.connection); - } else { - Network.connectEthernet(ethernetItem.modelData.connection || "", ethernetItem.modelData.interface || ""); - } - } - } - - MaterialIcon { - id: connectIcon - - anchors.centerIn: parent - animate: true - text: ethernetItem.modelData.connected ? "link_off" : "link" - color: ethernetItem.modelData.connected ? Colours.palette.m3onPrimary : Colours.palette.m3onSurface - - opacity: ethernetItem.loading ? 0 : 1 - - Behavior on opacity { - Anim {} - } - } - } - } - } - - StyledRect { - Layout.topMargin: Appearance.spacing.small - Layout.fillWidth: true - implicitHeight: refreshBtn.implicitHeight + Appearance.padding.small * 2 - - radius: Appearance.rounding.full - color: Colours.palette.m3primaryContainer - - StateLayer { - color: Colours.palette.m3onPrimaryContainer - disabled: Network.ethernetProcessRunning - - function onClicked(): void { - Network.getEthernetDevices(); - } - } - - RowLayout { - id: refreshBtn - - anchors.centerIn: parent - spacing: Appearance.spacing.small - opacity: Network.ethernetProcessRunning ? 0 : 1 - - MaterialIcon { - id: refreshIcon - - animate: true - text: "refresh" - color: Colours.palette.m3onPrimaryContainer - } - - StyledText { - text: qsTr("Refresh devices") - color: Colours.palette.m3onPrimaryContainer - } - - Behavior on opacity { - Anim {} - } - } - - CircularIndicator { - anchors.centerIn: parent - strokeWidth: Appearance.padding.small / 2 - bgColour: "transparent" - implicitHeight: parent.implicitHeight - Appearance.padding.smaller * 2 - running: Network.ethernetProcessRunning - } - } -} - diff --git a/modules/bar/popouts/Network.qml b/modules/bar/popouts/Network.qml index cb012bf..d185887 100644 --- a/modules/bar/popouts/Network.qml +++ b/modules/bar/popouts/Network.qml @@ -192,6 +192,116 @@ ColumnLayout { } } + StyledText { + Layout.topMargin: Appearance.spacing.normal + Layout.rightMargin: Appearance.padding.small + text: qsTr("Ethernet") + font.weight: 500 + } + + StyledText { + Layout.topMargin: Appearance.spacing.small + Layout.rightMargin: Appearance.padding.small + text: qsTr("%1 devices available").arg(Nmcli.ethernetDevices.length) + color: Colours.palette.m3onSurfaceVariant + font.pointSize: Appearance.font.size.small + } + + Repeater { + model: ScriptModel { + values: [...Nmcli.ethernetDevices].sort((a, b) => { + if (a.connected !== b.connected) + return b.connected - a.connected; + return (a.interface || "").localeCompare(b.interface || ""); + }).slice(0, 8) + } + + RowLayout { + id: ethernetItem + + required property var modelData + readonly property bool loading: false + + Layout.fillWidth: true + Layout.rightMargin: Appearance.padding.small + spacing: Appearance.spacing.small + + opacity: 0 + scale: 0.7 + + Component.onCompleted: { + opacity = 1; + scale = 1; + } + + Behavior on opacity { + Anim {} + } + + Behavior on scale { + Anim {} + } + + MaterialIcon { + text: "cable" + color: ethernetItem.modelData.connected ? Colours.palette.m3primary : Colours.palette.m3onSurfaceVariant + } + + StyledText { + Layout.leftMargin: Appearance.spacing.small / 2 + Layout.rightMargin: Appearance.spacing.small / 2 + Layout.fillWidth: true + text: ethernetItem.modelData.interface || qsTr("Unknown") + elide: Text.ElideRight + font.weight: ethernetItem.modelData.connected ? 500 : 400 + color: ethernetItem.modelData.connected ? Colours.palette.m3primary : Colours.palette.m3onSurface + } + + StyledRect { + id: connectBtn + + implicitWidth: implicitHeight + implicitHeight: connectIcon.implicitHeight + Appearance.padding.small + + radius: Appearance.rounding.full + color: Qt.alpha(Colours.palette.m3primary, ethernetItem.modelData.connected ? 1 : 0) + + CircularIndicator { + anchors.fill: parent + running: ethernetItem.loading + } + + StateLayer { + color: ethernetItem.modelData.connected ? Colours.palette.m3onPrimary : Colours.palette.m3onSurface + disabled: ethernetItem.loading + + function onClicked(): void { + if (ethernetItem.modelData.connected && ethernetItem.modelData.connection) { + Nmcli.disconnectEthernet(ethernetItem.modelData.connection, () => {}); + } else { + Nmcli.connectEthernet(ethernetItem.modelData.connection || "", ethernetItem.modelData.interface || "", () => {}); + } + } + } + + MaterialIcon { + id: connectIcon + + anchors.centerIn: parent + animate: true + text: ethernetItem.modelData.connected ? "link_off" : "link" + color: ethernetItem.modelData.connected ? Colours.palette.m3onPrimary : Colours.palette.m3onSurface + + opacity: ethernetItem.loading ? 0 : 1 + + Behavior on opacity { + Anim {} + } + } + } + } + } + Connections { target: Nmcli -- cgit v1.2.3-freya