diff options
| author | ATMDA <atdma2600@gmail.com> | 2025-11-10 14:25:06 -0500 |
|---|---|---|
| committer | ATMDA <atdma2600@gmail.com> | 2025-11-10 14:25:06 -0500 |
| commit | bd61cbaac5ef765696bfa786dabff977ab6d03e9 (patch) | |
| tree | 6ba43cf7deb8355016d091804a9caebbc2eee6ff /modules | |
| parent | controlcenter: polishing appearance panel (diff) | |
| download | caelestia-shell-bd61cbaac5ef765696bfa786dabff977ab6d03e9.tar.gz caelestia-shell-bd61cbaac5ef765696bfa786dabff977ab6d03e9.tar.bz2 caelestia-shell-bd61cbaac5ef765696bfa786dabff977ab6d03e9.zip | |
statusicons: added ethernet when active and popout
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/bar/components/StatusIcons.qml | 12 | ||||
| -rw-r--r-- | modules/bar/popouts/Content.qml | 5 | ||||
| -rw-r--r-- | modules/bar/popouts/Ethernet.qml | 179 |
3 files changed, 196 insertions, 0 deletions
diff --git a/modules/bar/components/StatusIcons.qml b/modules/bar/components/StatusIcons.qml index 27fd9f8..6113539 100644 --- a/modules/bar/components/StatusIcons.qml +++ b/modules/bar/components/StatusIcons.qml @@ -152,6 +152,18 @@ StyledRect { } } + // Ethernet icon + WrappedLoader { + name: "ethernet" + active: Config.bar.status.showEthernet && Network.activeEthernet + + sourceComponent: MaterialIcon { + animate: true + text: "cable" + color: root.colour + } + } + // Bluetooth section WrappedLoader { Layout.preferredHeight: implicitHeight diff --git a/modules/bar/popouts/Content.qml b/modules/bar/popouts/Content.qml index e3f569d..f8ef549 100644 --- a/modules/bar/popouts/Content.qml +++ b/modules/bar/popouts/Content.qml @@ -37,6 +37,11 @@ Item { } Popout { + name: "ethernet" + sourceComponent: Ethernet {} + } + + Popout { name: "bluetooth" sourceComponent: Bluetooth { wrapper: root.wrapper diff --git a/modules/bar/popouts/Ethernet.qml b/modules/bar/popouts/Ethernet.qml new file mode 100644 index 0000000..b4a753c --- /dev/null +++ b/modules/bar/popouts/Ethernet.qml @@ -0,0 +1,179 @@ +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 + } + } +} + |