From 09706ccb28b7f998057811ee4b8b59c35c31d76d Mon Sep 17 00:00:00 2001 From: quadbyte Date: Thu, 7 Aug 2025 11:43:56 -0400 Subject: [PATCH] Settings: cleanup Network tab --- Widgets/SettingsWindow/Tabs/Network.qml | 232 +++++------------------- 1 file changed, 45 insertions(+), 187 deletions(-) diff --git a/Widgets/SettingsWindow/Tabs/Network.qml b/Widgets/SettingsWindow/Tabs/Network.qml index 8bf9dc6..5bc582c 100644 --- a/Widgets/SettingsWindow/Tabs/Network.qml +++ b/Widgets/SettingsWindow/Tabs/Network.qml @@ -6,223 +6,81 @@ import Quickshell.Bluetooth import qs.Components import qs.Settings -ScrollView { +ColumnLayout { + id: root + + spacing: 0 anchors.fill: parent - padding: 0 - rightPadding: 12 - clip: true - ScrollBar.horizontal.policy: ScrollBar.AlwaysOff - ScrollBar.vertical.policy: ScrollBar.AsNeeded - - ColumnLayout { - id: root - width: parent.availableWidth + anchors.margins: 0 + + ScrollView { + id: scrollView + Layout.fillWidth: true Layout.fillHeight: true - spacing: 24 - Component.onCompleted: { - Quickshell.execDetached(["nmcli", "-t", "-f", "WIFI", "radio"]); - } + padding: 16 + rightPadding: 12 + clip: true + ScrollBar.horizontal.policy: ScrollBar.AlwaysOff + ScrollBar.vertical.policy: ScrollBar.AsNeeded ColumnLayout { - spacing: 16 - Layout.fillWidth: true + width: scrollView.availableWidth + spacing: 0 Text { text: "Wi-Fi" font.pixelSize: 18 * Theme.uiScale font.bold: true color: Theme.textPrimary + Layout.bottomMargin: 16 * Theme.uiScale } - ColumnLayout { - spacing: 8 - Layout.fillWidth: true - - RowLayout { - spacing: 8 - Layout.fillWidth: true - - ColumnLayout { - spacing: 4 - Layout.fillWidth: true - - Text { - text: "Enable Wi-Fi" - font.pixelSize: 13 * Theme.uiScale - font.bold: true - color: Theme.textPrimary - } - - Text { - text: "Turn Wi-Fi radio on or off" - font.pixelSize: 12 * Theme.uiScale - color: Theme.textSecondary - wrapMode: Text.WordWrap - Layout.fillWidth: true - } - - } - - Rectangle { - id: wifiSwitch - - property bool checked: Settings.settings.wifiEnabled - - width: 52 - height: 32 - radius: 16 - color: checked ? Theme.accentPrimary : Theme.surfaceVariant - border.color: checked ? Theme.accentPrimary : Theme.outline - border.width: 2 - - Rectangle { - id: wifiThumb - - width: 28 - height: 28 - radius: 14 - color: Theme.surface - border.color: Theme.outline - border.width: 1 - y: 2 - x: wifiSwitch.checked ? wifiSwitch.width - width - 2 : 2 - - Behavior on x { - NumberAnimation { - duration: 200 - easing.type: Easing.OutCubic - } - - } - - } - - MouseArea { - anchors.fill: parent - cursorShape: Qt.PointingHandCursor - onClicked: { - Settings.settings.wifiEnabled = !Settings.settings.wifiEnabled; - Quickshell.execDetached(["nmcli", "radio", "wifi", Settings.settings.wifiEnabled ? "on" : "off"]); - } - } - - } - + ToggleOption { + label: "Enable Wi-Fi" + description: "Turn Wi-Fi radio on or off" + value: Settings.settings.wifiEnabled + onToggled: function() { + Settings.settings.wifiEnabled = !Settings.settings.wifiEnabled; + Quickshell.execDetached(["nmcli", "radio", "wifi", Settings.settings.wifiEnabled ? "on" : "off"]); } - } - } - - Rectangle { - Layout.fillWidth: true - Layout.topMargin: 26 - Layout.bottomMargin: 0 - height: 1 - color: Theme.outline - opacity: 0.3 - } - - ColumnLayout { - spacing: 16 - Layout.fillWidth: true + // Separator + Rectangle { + Layout.fillWidth: true + Layout.topMargin: 26 + Layout.bottomMargin: 18 + height: 1 + color: Theme.outline + opacity: 0.3 + } Text { text: "Bluetooth" font.pixelSize: 18 * Theme.uiScale font.bold: true color: Theme.textPrimary + Layout.bottomMargin: 16 * Theme.uiScale } - ColumnLayout { - spacing: 8 - Layout.fillWidth: true - - RowLayout { - spacing: 8 - Layout.fillWidth: true - - ColumnLayout { - spacing: 4 - Layout.fillWidth: true - - Text { - text: "Enable Bluetooth" - font.pixelSize: 13 * Theme.uiScale - font.bold: true - color: Theme.textPrimary - } - - Text { - text: "Turn Bluetooth radio on or off" - font.pixelSize: 12 * Theme.uiScale - color: Theme.textSecondary - wrapMode: Text.WordWrap - Layout.fillWidth: true - } + ToggleOption { + label: "Enable Bluetooth" + description: "Turn Bluetooth radio on or off" + value: Settings.settings.bluetoothEnabled + onToggled: function() { + if (Bluetooth.defaultAdapter) { + Settings.settings.bluetoothEnabled = !Settings.settings.bluetoothEnabled; + Bluetooth.defaultAdapter.enabled = Settings.settings.bluetoothEnabled; + if (Bluetooth.defaultAdapter.enabled) + Bluetooth.defaultAdapter.discovering = true; } - - Rectangle { - id: bluetoothSwitch - - property bool checked: Settings.settings.bluetoothEnabled - - width: 52 - height: 32 - radius: 16 - color: checked ? Theme.accentPrimary : Theme.surfaceVariant - border.color: checked ? Theme.accentPrimary : Theme.outline - border.width: 2 - - Rectangle { - id: bluetoothThumb - - width: 28 - height: 28 - radius: 14 - color: Theme.surface - border.color: Theme.outline - border.width: 1 - y: 2 - x: bluetoothSwitch.checked ? bluetoothSwitch.width - width - 2 : 2 - - Behavior on x { - NumberAnimation { - duration: 200 - easing.type: Easing.OutCubic - } - - } - - } - - MouseArea { - anchors.fill: parent - cursorShape: Qt.PointingHandCursor - onClicked: { - if (Bluetooth.defaultAdapter) { - Settings.settings.bluetoothEnabled = !Settings.settings.bluetoothEnabled; - Bluetooth.defaultAdapter.enabled = Settings.settings.bluetoothEnabled; - if (Bluetooth.defaultAdapter.enabled) - Bluetooth.defaultAdapter.discovering = true; - - } - } - } - - } - } - } } - Item { - Layout.fillWidth: true - Layout.fillHeight: true - } } + }