mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-06 05:25:41 -05:00
network: general improvements, itnegrate preference of wifi/ethernet
This commit is contained in:
@@ -33,6 +33,9 @@ Singleton {
|
||||
property string appLauncherViewMode: "list"
|
||||
property string spotlightLauncherViewMode: "list"
|
||||
|
||||
// Network preference
|
||||
property string networkPreference: "auto" // "auto", "wifi", "ethernet"
|
||||
|
||||
|
||||
Component.onCompleted: loadSettings()
|
||||
|
||||
@@ -92,6 +95,7 @@ Singleton {
|
||||
showSystemTray = settings.showSystemTray !== undefined ? settings.showSystemTray : true
|
||||
appLauncherViewMode = settings.appLauncherViewMode !== undefined ? settings.appLauncherViewMode : "list"
|
||||
spotlightLauncherViewMode = settings.spotlightLauncherViewMode !== undefined ? settings.spotlightLauncherViewMode : "list"
|
||||
networkPreference = settings.networkPreference !== undefined ? settings.networkPreference : "auto"
|
||||
console.log("Loaded settings - themeIndex:", themeIndex, "isDynamic:", themeIsDynamic, "lightMode:", isLightMode, "transparency:", topBarTransparency, "recentApps:", recentlyUsedApps.length)
|
||||
|
||||
applyStoredTheme()
|
||||
@@ -125,7 +129,8 @@ Singleton {
|
||||
showSystemResources,
|
||||
showSystemTray,
|
||||
appLauncherViewMode,
|
||||
spotlightLauncherViewMode
|
||||
spotlightLauncherViewMode,
|
||||
networkPreference
|
||||
}, null, 2))
|
||||
console.log("Saving settings - themeIndex:", themeIndex, "isDynamic:", themeIsDynamic, "lightMode:", isLightMode, "transparency:", topBarTransparency, "recentApps:", recentlyUsedApps.length)
|
||||
}
|
||||
@@ -306,4 +311,11 @@ Singleton {
|
||||
weatherLocationOverride = location
|
||||
saveSettings()
|
||||
}
|
||||
|
||||
// Network preference setter
|
||||
function setNetworkPreference(preference) {
|
||||
console.log("Prefs setNetworkPreference called - networkPreference:", preference)
|
||||
networkPreference = preference
|
||||
saveSettings()
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import "../Common"
|
||||
pragma Singleton
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
@@ -13,11 +14,27 @@ Singleton {
|
||||
property string wifiIP: ""
|
||||
property bool wifiAvailable: false
|
||||
property bool wifiEnabled: true
|
||||
property bool wifiToggling: false
|
||||
property string userPreference: "auto" // "auto", "wifi", "ethernet"
|
||||
property bool changingPreference: false
|
||||
property string targetPreference: "" // Track what preference we're switching to
|
||||
|
||||
// Load saved preference on startup
|
||||
Component.onCompleted: {
|
||||
// Load preference from Prefs system
|
||||
root.userPreference = Prefs.networkPreference
|
||||
console.log("NetworkService: Loaded network preference from Prefs:", root.userPreference)
|
||||
|
||||
// Trigger immediate WiFi info update if WiFi is connected
|
||||
if (root.networkStatus === "wifi") {
|
||||
WifiService.updateCurrentWifiInfo()
|
||||
}
|
||||
}
|
||||
|
||||
// Real Network Management
|
||||
Process {
|
||||
id: networkStatusChecker
|
||||
command: ["bash", "-c", "nmcli -t -f DEVICE,TYPE,STATE device | grep -E '(ethernet|wifi)' && echo '---' && ip link show | grep -E '^[0-9]+:.*ethernet.*state UP'"]
|
||||
command: ["sh", "-c", "nmcli -t -f DEVICE,TYPE,STATE device | grep -E '(ethernet|wifi)' && echo '---' && ip link show | grep -E '^[0-9]+:.*ethernet.*state UP'"]
|
||||
running: true
|
||||
|
||||
stdout: StdioCollector {
|
||||
@@ -29,15 +46,64 @@ Singleton {
|
||||
let hasWifi = text.includes("wifi:connected")
|
||||
let ethernetCableUp = text.includes("state UP")
|
||||
|
||||
// Check if ethernet cable is physically connected but not managed
|
||||
// Always check both IPs when available
|
||||
if (hasWifi) {
|
||||
wifiIPChecker.running = true
|
||||
}
|
||||
if (hasEthernet || ethernetCableUp) {
|
||||
root.networkStatus = "ethernet"
|
||||
ethernetIPChecker.running = true
|
||||
console.log("Setting network status to ethernet (cable connected)")
|
||||
}
|
||||
|
||||
// Check connection priorities when both are active
|
||||
if (hasWifi && hasEthernet) {
|
||||
console.log("Both WiFi and Ethernet connected, user preference:", root.userPreference)
|
||||
|
||||
// Use user preference if set, otherwise check default route
|
||||
if (root.userPreference === "wifi") {
|
||||
root.networkStatus = "wifi"
|
||||
console.log("User prefers WiFi, setting status to wifi")
|
||||
WifiService.updateCurrentWifiInfo()
|
||||
} else if (root.userPreference === "ethernet") {
|
||||
root.networkStatus = "ethernet"
|
||||
console.log("User prefers Ethernet, setting status to ethernet")
|
||||
} else {
|
||||
// Auto mode - check which interface has the default route
|
||||
let priorityChecker = Qt.createQmlObject(`
|
||||
import Quickshell.Io
|
||||
Process {
|
||||
command: ["sh", "-c", "ip route show default | head -1 | cut -d\\\" \\\" -f5"]
|
||||
running: true
|
||||
stdout: SplitParser {
|
||||
splitMarker: "\\n"
|
||||
onRead: function(data) {
|
||||
let defaultInterface = data.trim()
|
||||
console.log("Default route interface:", defaultInterface)
|
||||
// Check if the interface is wifi or ethernet
|
||||
if (defaultInterface.startsWith("wl") || defaultInterface.includes("wifi")) {
|
||||
root.networkStatus = "wifi"
|
||||
console.log("WiFi interface has default route, setting status to wifi")
|
||||
// Trigger WiFi SSID update
|
||||
WifiService.updateCurrentWifiInfo()
|
||||
} else if (defaultInterface.startsWith("en") || defaultInterface.includes("eth")) {
|
||||
root.networkStatus = "ethernet"
|
||||
console.log("Ethernet interface has default route, setting status to ethernet")
|
||||
} else {
|
||||
root.networkStatus = "disconnected"
|
||||
console.log("Unknown interface type:", defaultInterface)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`, root)
|
||||
}
|
||||
} else if (hasWifi) {
|
||||
root.networkStatus = "wifi"
|
||||
wifiIPChecker.running = true
|
||||
console.log("Setting network status to wifi")
|
||||
console.log("Only WiFi connected, setting status to wifi")
|
||||
// Trigger WiFi SSID update
|
||||
WifiService.updateCurrentWifiInfo()
|
||||
} else if (hasEthernet || ethernetCableUp) {
|
||||
root.networkStatus = "ethernet"
|
||||
console.log("Only Ethernet connected, setting status to ethernet")
|
||||
} else {
|
||||
root.networkStatus = "disconnected"
|
||||
root.ethernetIP = ""
|
||||
@@ -46,6 +112,26 @@ Singleton {
|
||||
console.log("Setting network status to disconnected")
|
||||
}
|
||||
|
||||
// Check if we're done changing preferences
|
||||
if (root.changingPreference && root.targetPreference !== "") {
|
||||
let preferenceComplete = false
|
||||
|
||||
if (root.targetPreference === "wifi" && root.networkStatus === "wifi") {
|
||||
preferenceComplete = true
|
||||
console.log("WiFi preference change complete - network is now using WiFi")
|
||||
} else if (root.targetPreference === "ethernet" && root.networkStatus === "ethernet") {
|
||||
preferenceComplete = true
|
||||
console.log("Ethernet preference change complete - network is now using Ethernet")
|
||||
}
|
||||
|
||||
if (preferenceComplete) {
|
||||
root.changingPreference = false
|
||||
root.targetPreference = ""
|
||||
preferenceTimeoutTimer.stop()
|
||||
console.log("Network preference change completed successfully")
|
||||
}
|
||||
}
|
||||
|
||||
// Always check WiFi radio status
|
||||
wifiRadioChecker.running = true
|
||||
} else {
|
||||
@@ -66,7 +152,7 @@ Singleton {
|
||||
|
||||
stdout: SplitParser {
|
||||
splitMarker: "\n"
|
||||
onRead: (data) => {
|
||||
onRead: function(data) {
|
||||
let response = data.trim()
|
||||
root.wifiAvailable = response === "enabled" || response === "disabled"
|
||||
root.wifiEnabled = response === "enabled"
|
||||
@@ -77,23 +163,40 @@ Singleton {
|
||||
|
||||
Process {
|
||||
id: ethernetIPChecker
|
||||
command: ["bash", "-c", "ip route get 1.1.1.1 | grep -oP '(dev \\K\\S+|src \\K\\S+)' | tr '\\n' ' '"]
|
||||
command: ["sh", "-c", "ETH_DEV=$(nmcli -t -f DEVICE,TYPE device | grep ethernet | grep connected | cut -d: -f1 | head -1); if [ -n \"$ETH_DEV\" ]; then nmcli -t -f IP4.ADDRESS dev show \"$ETH_DEV\" | cut -d: -f2 | cut -d/ -f1 | head -1; fi"]
|
||||
running: false
|
||||
|
||||
stdout: SplitParser {
|
||||
splitMarker: "\n"
|
||||
onRead: (data) => {
|
||||
onRead: function(data) {
|
||||
if (data.trim()) {
|
||||
const parts = data.trim().split(' ')
|
||||
if (parts.length >= 2) {
|
||||
root.ethernetInterface = parts[0]
|
||||
root.ethernetIP = parts[1]
|
||||
console.log("Ethernet Interface:", root.ethernetInterface, "IP:", root.ethernetIP)
|
||||
} else if (parts.length === 1) {
|
||||
// Fallback if only IP is found
|
||||
root.ethernetIP = parts[0]
|
||||
console.log("Ethernet IP:", root.ethernetIP)
|
||||
}
|
||||
root.ethernetIP = data.trim()
|
||||
console.log("Ethernet IP:", root.ethernetIP)
|
||||
|
||||
// Get the ethernet interface name
|
||||
let ethInterfaceProcess = Qt.createQmlObject(`
|
||||
import Quickshell.Io
|
||||
Process {
|
||||
command: ["sh", "-c", "nmcli -t -f DEVICE,TYPE device | grep ethernet | grep connected | cut -d: -f1 | head -1"]
|
||||
running: true
|
||||
stdout: SplitParser {
|
||||
splitMarker: "\\n"
|
||||
onRead: function(interfaceData) {
|
||||
if (interfaceData.trim()) {
|
||||
root.ethernetInterface = interfaceData.trim()
|
||||
console.log("Ethernet Interface:", root.ethernetInterface)
|
||||
|
||||
// Ethernet interface detected - status will be determined by route checking
|
||||
console.log("Ethernet interface detected:", root.ethernetInterface)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`, root)
|
||||
} else {
|
||||
console.log("No ethernet IP found")
|
||||
root.ethernetIP = ""
|
||||
root.ethernetInterface = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -101,15 +204,21 @@ Singleton {
|
||||
|
||||
Process {
|
||||
id: wifiIPChecker
|
||||
command: ["bash", "-c", "nmcli -t -f IP4.ADDRESS dev show $(nmcli -t -f DEVICE,TYPE device | grep wifi | cut -d: -f1 | head -1) | cut -d: -f2 | cut -d/ -f1"]
|
||||
command: ["sh", "-c", "WIFI_DEV=$(nmcli -t -f DEVICE,TYPE device | grep wifi | grep connected | cut -d: -f1 | head -1); if [ -n \"$WIFI_DEV\" ]; then nmcli -t -f IP4.ADDRESS dev show \"$WIFI_DEV\" | cut -d: -f2 | cut -d/ -f1 | head -1; fi"]
|
||||
running: false
|
||||
|
||||
stdout: SplitParser {
|
||||
splitMarker: "\n"
|
||||
onRead: (data) => {
|
||||
onRead: function(data) {
|
||||
if (data.trim()) {
|
||||
root.wifiIP = data.trim()
|
||||
console.log("WiFi IP:", root.wifiIP)
|
||||
|
||||
// WiFi IP detected - status will be determined by route checking
|
||||
console.log("WiFi has IP:", root.wifiIP)
|
||||
} else {
|
||||
console.log("No WiFi IP found")
|
||||
root.wifiIP = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,51 +229,209 @@ Singleton {
|
||||
// Toggle ethernet connection
|
||||
if (root.networkStatus === "ethernet") {
|
||||
// Disconnect ethernet
|
||||
let disconnectProcess = Qt.createQmlObject('
|
||||
console.log("Disconnecting ethernet...")
|
||||
let disconnectProcess = Qt.createQmlObject(`
|
||||
import Quickshell.Io
|
||||
Process {
|
||||
command: ["bash", "-c", "nmcli device disconnect $(nmcli -t -f DEVICE,TYPE device | grep ethernet | cut -d: -f1 | head -1)"]
|
||||
command: ["sh", "-c", "nmcli device disconnect $(nmcli -t -f DEVICE,TYPE device | grep ethernet | cut -d: -f1 | head -1)"]
|
||||
running: true
|
||||
onExited: networkStatusChecker.running = true
|
||||
onExited: function(exitCode) {
|
||||
console.log("Ethernet disconnect result:", exitCode)
|
||||
delayedRefreshNetworkStatus()
|
||||
}
|
||||
stderr: SplitParser {
|
||||
splitMarker: "\\n"
|
||||
onRead: function(data) {
|
||||
console.log("Ethernet disconnect stderr:", data)
|
||||
}
|
||||
}
|
||||
}
|
||||
', root)
|
||||
`, root)
|
||||
} else {
|
||||
// Connect ethernet with proper nmcli device connect
|
||||
let connectProcess = Qt.createQmlObject('
|
||||
// Connect ethernet and set higher priority
|
||||
console.log("Connecting ethernet...")
|
||||
let connectProcess = Qt.createQmlObject(`
|
||||
import Quickshell.Io
|
||||
Process {
|
||||
command: ["bash", "-c", "nmcli device connect $(nmcli -t -f DEVICE,TYPE device | grep ethernet | cut -d: -f1 | head -1)"]
|
||||
command: ["sh", "-c", "ETH_DEV=$(nmcli -t -f DEVICE,TYPE device | grep ethernet | cut -d: -f1 | head -1); if [ -n \\"$ETH_DEV\\" ]; then nmcli device connect \\"$ETH_DEV\\"; ETH_CONN=$(nmcli -t -f NAME,DEVICE connection show --active | grep \\"$ETH_DEV\\" | cut -d: -f1); if [ -n \\"$ETH_CONN\\" ]; then nmcli connection modify \\"$ETH_CONN\\" connection.autoconnect-priority 100; nmcli connection down \\"$ETH_CONN\\"; nmcli connection up \\"$ETH_CONN\\"; fi; else echo \\"No ethernet device found\\"; exit 1; fi"]
|
||||
running: true
|
||||
onExited: networkStatusChecker.running = true
|
||||
onExited: function(exitCode) {
|
||||
console.log("Ethernet connect result:", exitCode)
|
||||
if (exitCode === 0) {
|
||||
console.log("Ethernet connected successfully with higher priority")
|
||||
} else {
|
||||
console.log("Ethernet connection failed")
|
||||
}
|
||||
delayedRefreshNetworkStatus()
|
||||
}
|
||||
stderr: SplitParser {
|
||||
splitMarker: "\\n"
|
||||
onRead: function(data) {
|
||||
console.log("Ethernet connect stderr:", data)
|
||||
}
|
||||
}
|
||||
}
|
||||
', root)
|
||||
`, root)
|
||||
}
|
||||
} else if (type === "wifi") {
|
||||
// Connect to WiFi if disconnected
|
||||
if (root.networkStatus !== "wifi" && root.wifiEnabled) {
|
||||
let connectProcess = Qt.createQmlObject('
|
||||
console.log("Connecting to WiFi device...")
|
||||
let connectProcess = Qt.createQmlObject(`
|
||||
import Quickshell.Io
|
||||
Process {
|
||||
command: ["bash", "-c", "nmcli device connect $(nmcli -t -f DEVICE,TYPE device | grep wifi | cut -d: -f1 | head -1)"]
|
||||
command: ["sh", "-c", "WIFI_DEV=$(nmcli -t -f DEVICE,TYPE device | grep wifi | cut -d: -f1 | head -1); if [ -n \\"$WIFI_DEV\\" ]; then nmcli device connect \\"$WIFI_DEV\\"; else echo \\"No WiFi device found\\"; exit 1; fi"]
|
||||
running: true
|
||||
onExited: networkStatusChecker.running = true
|
||||
onExited: function(exitCode) {
|
||||
console.log("WiFi device connect result:", exitCode)
|
||||
delayedRefreshNetworkStatus()
|
||||
}
|
||||
stderr: SplitParser {
|
||||
splitMarker: "\\n"
|
||||
onRead: function(data) {
|
||||
console.log("WiFi device connect stderr:", data)
|
||||
}
|
||||
}
|
||||
}
|
||||
', root)
|
||||
`, root)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function toggleWifiRadio() {
|
||||
let action = root.wifiEnabled ? "off" : "on"
|
||||
let toggleProcess = Qt.createQmlObject('
|
||||
function switchToWifi() {
|
||||
console.log("Switching to WiFi")
|
||||
// Disconnect ethernet first, then try to connect to a known WiFi network
|
||||
let switchProcess = Qt.createQmlObject(`
|
||||
import Quickshell.Io
|
||||
Process {
|
||||
command: ["nmcli", "radio", "wifi", "' + action + '"]
|
||||
command: ["sh", "-c", "ETH_DEV=$(nmcli -t -f DEVICE,TYPE device | grep ethernet | cut -d: -f1 | head -1); WIFI_DEV=$(nmcli -t -f DEVICE,TYPE device | grep wifi | cut -d: -f1 | head -1); [ -n \\"$ETH_DEV\\" ] && nmcli device disconnect \\"$ETH_DEV\\" 2>/dev/null; [ -n \\"$WIFI_DEV\\" ] && nmcli device connect \\"$WIFI_DEV\\" 2>/dev/null || true"]
|
||||
running: true
|
||||
onExited: function(exitCode) {
|
||||
console.log("Switch to wifi result:", exitCode)
|
||||
delayedRefreshNetworkStatus()
|
||||
}
|
||||
stderr: SplitParser {
|
||||
splitMarker: "\\n"
|
||||
onRead: function(data) {
|
||||
console.log("Switch to wifi stderr:", data)
|
||||
}
|
||||
}
|
||||
}
|
||||
`, root)
|
||||
}
|
||||
|
||||
function switchToEthernet() {
|
||||
console.log("Switching to Ethernet")
|
||||
// Disconnect WiFi first, then connect ethernet
|
||||
let switchProcess = Qt.createQmlObject(`
|
||||
import Quickshell.Io
|
||||
Process {
|
||||
command: ["sh", "-c", "WIFI_DEV=$(nmcli -t -f DEVICE,TYPE device | grep wifi | cut -d: -f1 | head -1); ETH_DEV=$(nmcli -t -f DEVICE,TYPE device | grep ethernet | cut -d: -f1 | head -1); [ -n \\"$WIFI_DEV\\" ] && nmcli device disconnect \\"$WIFI_DEV\\" 2>/dev/null; [ -n \\"$ETH_DEV\\" ] && nmcli device connect \\"$ETH_DEV\\" 2>/dev/null || true"]
|
||||
running: true
|
||||
onExited: function(exitCode) {
|
||||
console.log("Switch to ethernet result:", exitCode)
|
||||
delayedRefreshNetworkStatus()
|
||||
}
|
||||
stderr: SplitParser {
|
||||
splitMarker: "\\n"
|
||||
onRead: function(data) {
|
||||
console.log("Switch to ethernet stderr:", data)
|
||||
}
|
||||
}
|
||||
}
|
||||
`, root)
|
||||
}
|
||||
|
||||
function toggleWifiRadio() {
|
||||
if (root.wifiToggling) return
|
||||
|
||||
root.wifiToggling = true
|
||||
let action = root.wifiEnabled ? "off" : "on"
|
||||
let toggleProcess = Qt.createQmlObject(`
|
||||
import Quickshell.Io
|
||||
Process {
|
||||
command: ["nmcli", "radio", "wifi", "${action}"]
|
||||
running: true
|
||||
onExited: {
|
||||
root.wifiToggling = false
|
||||
networkStatusChecker.running = true
|
||||
}
|
||||
}
|
||||
', root)
|
||||
`, root)
|
||||
}
|
||||
|
||||
function refreshNetworkStatus() {
|
||||
console.log("Refreshing network status...")
|
||||
networkStatusChecker.running = true
|
||||
}
|
||||
|
||||
function delayedRefreshNetworkStatus() {
|
||||
console.log("Delayed network status refresh...")
|
||||
refreshTimer.start()
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: refreshTimer
|
||||
interval: 1000
|
||||
onTriggered: {
|
||||
refreshNetworkStatus()
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: preferenceTimeoutTimer
|
||||
interval: 15000 // 15 seconds timeout
|
||||
onTriggered: {
|
||||
console.log("Network preference change timeout - resetting changingPreference state")
|
||||
root.changingPreference = false
|
||||
root.targetPreference = ""
|
||||
}
|
||||
}
|
||||
|
||||
function setNetworkPreference(preference) {
|
||||
console.log("Setting network preference to:", preference)
|
||||
root.userPreference = preference
|
||||
root.changingPreference = true
|
||||
root.targetPreference = preference
|
||||
preferenceTimeoutTimer.start()
|
||||
Prefs.setNetworkPreference(preference)
|
||||
|
||||
if (preference === "wifi") {
|
||||
// Set WiFi to low route metric (high priority), ethernet to high route metric (low priority)
|
||||
let wifiPriorityProcess = Qt.createQmlObject(`
|
||||
import Quickshell.Io
|
||||
Process {
|
||||
command: ["sh", "-c", "nmcli -t -f NAME,TYPE connection show | grep 802-11-wireless | cut -d: -f1 | while read conn; do nmcli connection modify \\\\\\"$conn\\\\\\" ipv4.route-metric 50; done; nmcli -t -f NAME,TYPE connection show | grep 802-3-ethernet | cut -d: -f1 | while read conn; do nmcli connection modify \\\\\\"$conn\\\\\\" ipv4.route-metric 200; done; nmcli -t -f NAME,TYPE connection show --active | grep -E \\\\\\"(802-11-wireless|802-3-ethernet)\\\\\\" | cut -d: -f1 | while read conn; do nmcli connection down \\\\\\"$conn\\\\\\" && nmcli connection up \\\\\\"$conn\\\\\\"; done"]
|
||||
running: true
|
||||
onExited: function(exitCode) {
|
||||
console.log("WiFi route metric set to 50, ethernet to 200, connections restarted, exit code:", exitCode)
|
||||
// Don't reset changingPreference here - let network status check handle it
|
||||
delayedRefreshNetworkStatus()
|
||||
}
|
||||
}
|
||||
`, root)
|
||||
} else if (preference === "ethernet") {
|
||||
// Set ethernet to low route metric (high priority), WiFi to high route metric (low priority)
|
||||
let ethernetPriorityProcess = Qt.createQmlObject(`
|
||||
import Quickshell.Io
|
||||
Process {
|
||||
command: ["sh", "-c", "nmcli -t -f NAME,TYPE connection show | grep 802-3-ethernet | cut -d: -f1 | while read conn; do nmcli connection modify \\\\\\"$conn\\\\\\" ipv4.route-metric 50; done; nmcli -t -f NAME,TYPE connection show | grep 802-11-wireless | cut -d: -f1 | while read conn; do nmcli connection modify \\\\\\"$conn\\\\\\" ipv4.route-metric 200; done; nmcli -t -f NAME,TYPE connection show --active | grep -E \\\\\\"(802-11-wireless|802-3-ethernet)\\\\\\" | cut -d: -f1 | while read conn; do nmcli connection down \\\\\\"$conn\\\\\\" && nmcli connection up \\\\\\"$conn\\\\\\"; done"]
|
||||
running: true
|
||||
onExited: function(exitCode) {
|
||||
console.log("Ethernet route metric set to 50, WiFi to 200, connections restarted, exit code:", exitCode)
|
||||
// Don't reset changingPreference here - let network status check handle it
|
||||
delayedRefreshNetworkStatus()
|
||||
}
|
||||
}
|
||||
`, root)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function connectToWifiAndSetPreference(ssid, password) {
|
||||
console.log("Connecting to WiFi and setting preference:", ssid)
|
||||
root.userPreference = "wifi"
|
||||
Prefs.setNetworkPreference("wifi")
|
||||
WifiService.connectToWifiWithPassword(ssid, password)
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import "."
|
||||
pragma Singleton
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
@@ -11,10 +12,13 @@ Singleton {
|
||||
property string wifiSignalStrength: "excellent" // "excellent", "good", "fair", "poor"
|
||||
property var wifiNetworks: []
|
||||
property var savedWifiNetworks: []
|
||||
property bool isScanning: false
|
||||
property string connectionStatus: "" // "connecting", "connected", "failed", ""
|
||||
property string connectingSSID: ""
|
||||
|
||||
Process {
|
||||
id: currentWifiInfo
|
||||
command: ["bash", "-c", "nmcli -t -f ssid,signal connection show --active | grep -v '^--' | grep -v '^$'"]
|
||||
command: ["bash", "-c", "nmcli -t -f ACTIVE,SSID,SIGNAL dev wifi | grep '^yes' | head -1"]
|
||||
running: false
|
||||
|
||||
stdout: SplitParser {
|
||||
@@ -22,9 +26,9 @@ Singleton {
|
||||
onRead: (data) => {
|
||||
if (data.trim()) {
|
||||
let parts = data.split(":")
|
||||
if (parts.length >= 2 && parts[0].trim() !== "") {
|
||||
root.currentWifiSSID = parts[0].trim()
|
||||
let signal = parseInt(parts[1]) || 100
|
||||
if (parts.length >= 3 && parts[1].trim() !== "") {
|
||||
root.currentWifiSSID = parts[1].trim()
|
||||
let signal = parseInt(parts[2]) || 100
|
||||
|
||||
if (signal >= 75) root.wifiSignalStrength = "excellent"
|
||||
else if (signal >= 50) root.wifiSignalStrength = "good"
|
||||
@@ -58,11 +62,15 @@ Singleton {
|
||||
|
||||
// Skip duplicates
|
||||
if (!networks.find(n => n.ssid === ssid)) {
|
||||
// Check if this network is saved
|
||||
let isSaved = root.savedWifiNetworks.some(saved => saved.ssid === ssid)
|
||||
|
||||
networks.push({
|
||||
ssid: ssid,
|
||||
signal: signal,
|
||||
secured: security !== "",
|
||||
connected: ssid === root.currentWifiSSID,
|
||||
saved: isSaved,
|
||||
signalStrength: signal >= 75 ? "excellent" :
|
||||
signal >= 50 ? "good" :
|
||||
signal >= 25 ? "fair" : "poor"
|
||||
@@ -75,6 +83,12 @@ Singleton {
|
||||
networks.sort((a, b) => b.signal - a.signal)
|
||||
root.wifiNetworks = networks
|
||||
console.log("Found", networks.length, "WiFi networks")
|
||||
|
||||
// Stop scanning once we have results
|
||||
if (networks.length > 0) {
|
||||
root.isScanning = false
|
||||
fallbackTimer.stop()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,9 +106,14 @@ Singleton {
|
||||
let lines = text.trim().split('\n')
|
||||
|
||||
for (let line of lines) {
|
||||
if (line.trim() && !line.includes("ethernet") && !line.includes("lo")) {
|
||||
let connectionName = line.trim()
|
||||
if (connectionName &&
|
||||
!connectionName.includes("ethernet") &&
|
||||
!connectionName.includes("lo") &&
|
||||
!connectionName.includes("Wired") &&
|
||||
!connectionName.toLowerCase().includes("eth")) {
|
||||
saved.push({
|
||||
ssid: line.trim(),
|
||||
ssid: connectionName,
|
||||
saved: true
|
||||
})
|
||||
}
|
||||
@@ -108,65 +127,144 @@ Singleton {
|
||||
}
|
||||
|
||||
function scanWifi() {
|
||||
if (root.isScanning) return
|
||||
|
||||
root.isScanning = true
|
||||
console.log("Starting WiFi scan...")
|
||||
|
||||
wifiScanner.running = true
|
||||
savedWifiScanner.running = true
|
||||
currentWifiInfo.running = true
|
||||
|
||||
// Fallback timer in case no networks are found
|
||||
fallbackTimer.start()
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: fallbackTimer
|
||||
interval: 5000
|
||||
onTriggered: {
|
||||
root.isScanning = false
|
||||
console.log("WiFi scan timeout - no networks found")
|
||||
}
|
||||
}
|
||||
|
||||
function connectToWifi(ssid) {
|
||||
console.log("Connecting to WiFi:", ssid)
|
||||
|
||||
let connectProcess = Qt.createQmlObject('
|
||||
root.connectionStatus = "connecting"
|
||||
root.connectingSSID = ssid
|
||||
|
||||
let connectProcess = Qt.createQmlObject(`
|
||||
import Quickshell.Io
|
||||
Process {
|
||||
command: ["nmcli", "dev", "wifi", "connect", "' + ssid + '"]
|
||||
command: ["bash", "-c", "nmcli dev wifi connect \\"' + ssid + '\\" || nmcli connection up \\"' + ssid + '\\"; if [ $? -eq 0 ]; then nmcli connection modify \\"' + ssid + '\\" connection.autoconnect-priority 50; nmcli connection down \\"' + ssid + '\\"; nmcli connection up \\"' + ssid + '\\"; fi"]
|
||||
running: true
|
||||
onExited: (exitCode) => {
|
||||
console.log("WiFi connection result:", exitCode)
|
||||
if (exitCode === 0) {
|
||||
root.connectionStatus = "connected"
|
||||
console.log("Connected to WiFi successfully")
|
||||
// Set user preference to WiFi when manually connecting
|
||||
NetworkService.setNetworkPreference("wifi")
|
||||
// Force network status refresh after successful connection
|
||||
NetworkService.delayedRefreshNetworkStatus()
|
||||
} else {
|
||||
root.connectionStatus = "failed"
|
||||
console.log("WiFi connection failed")
|
||||
}
|
||||
scanWifi()
|
||||
|
||||
statusResetTimer.start()
|
||||
}
|
||||
|
||||
stderr: SplitParser {
|
||||
splitMarker: "\\n"
|
||||
onRead: (data) => {
|
||||
console.log("WiFi connection stderr:", data)
|
||||
}
|
||||
}
|
||||
}
|
||||
', root)
|
||||
`, root)
|
||||
}
|
||||
|
||||
function connectToWifiWithPassword(ssid, password) {
|
||||
console.log("Connecting to WiFi with password:", ssid)
|
||||
|
||||
let connectProcess = Qt.createQmlObject('
|
||||
root.connectionStatus = "connecting"
|
||||
root.connectingSSID = ssid
|
||||
|
||||
let connectProcess = Qt.createQmlObject(`
|
||||
import Quickshell.Io
|
||||
Process {
|
||||
command: ["nmcli", "dev", "wifi", "connect", "' + ssid + '", "password", "' + password + '"]
|
||||
command: ["bash", "-c", "nmcli dev wifi connect \\"' + ssid + '\\" password \\"' + password + '\\"; if [ $? -eq 0 ]; then nmcli connection modify \\"' + ssid + '\\" connection.autoconnect-priority 50; nmcli connection down \\"' + ssid + '\\"; nmcli connection up \\"' + ssid + '\\"; fi"]
|
||||
running: true
|
||||
onExited: (exitCode) => {
|
||||
console.log("WiFi connection with password result:", exitCode)
|
||||
if (exitCode === 0) {
|
||||
root.connectionStatus = "connected"
|
||||
console.log("Connected to WiFi with password successfully")
|
||||
// Set user preference to WiFi when manually connecting
|
||||
NetworkService.setNetworkPreference("wifi")
|
||||
// Force network status refresh after successful connection
|
||||
NetworkService.delayedRefreshNetworkStatus()
|
||||
} else {
|
||||
root.connectionStatus = "failed"
|
||||
console.log("WiFi connection with password failed")
|
||||
}
|
||||
scanWifi()
|
||||
|
||||
statusResetTimer.start()
|
||||
}
|
||||
|
||||
stderr: SplitParser {
|
||||
splitMarker: "\\n"
|
||||
onRead: (data) => {
|
||||
console.log("WiFi connection with password stderr:", data)
|
||||
}
|
||||
}
|
||||
}
|
||||
', root)
|
||||
`, root)
|
||||
}
|
||||
|
||||
function forgetWifiNetwork(ssid) {
|
||||
console.log("Forgetting WiFi network:", ssid)
|
||||
let forgetProcess = Qt.createQmlObject('
|
||||
let forgetProcess = Qt.createQmlObject(`
|
||||
import Quickshell.Io
|
||||
Process {
|
||||
command: ["nmcli", "connection", "delete", "' + ssid + '"]
|
||||
command: ["bash", "-c", "nmcli connection delete \\"' + ssid + '\\" || nmcli connection delete id \\"' + ssid + '\\""]
|
||||
running: true
|
||||
onExited: (exitCode) => {
|
||||
console.log("WiFi forget result:", exitCode)
|
||||
if (exitCode === 0) {
|
||||
console.log("Successfully forgot WiFi network:", "' + ssid + '")
|
||||
} else {
|
||||
console.log("Failed to forget WiFi network:", "' + ssid + '")
|
||||
}
|
||||
scanWifi()
|
||||
}
|
||||
|
||||
stderr: SplitParser {
|
||||
splitMarker: "\\n"
|
||||
onRead: (data) => {
|
||||
console.log("WiFi forget stderr:", data)
|
||||
}
|
||||
}
|
||||
}
|
||||
', root)
|
||||
`, root)
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: statusResetTimer
|
||||
interval: 3000
|
||||
onTriggered: {
|
||||
root.connectionStatus = ""
|
||||
root.connectingSSID = ""
|
||||
}
|
||||
}
|
||||
|
||||
function updateCurrentWifiInfo() {
|
||||
console.log("Updating current WiFi info...")
|
||||
currentWifiInfo.running = true
|
||||
}
|
||||
}
|
||||
@@ -650,16 +650,19 @@ PanelWindow {
|
||||
networkStatus: root.networkStatus
|
||||
wifiAvailable: root.wifiAvailable
|
||||
wifiEnabled: root.wifiEnabled
|
||||
wifiToggling: root.wifiToggling
|
||||
ethernetIP: root.ethernetIP
|
||||
ethernetInterface: root.ethernetInterface
|
||||
currentWifiSSID: root.currentWifiSSID
|
||||
wifiIP: root.wifiIP
|
||||
wifiSignalStrength: root.wifiSignalStrength
|
||||
wifiNetworks: root.wifiNetworks
|
||||
wifiScanning: root.wifiScanning
|
||||
wifiConnectionStatus: root.wifiConnectionStatus
|
||||
wifiPasswordSSID: root.wifiPasswordSSID
|
||||
wifiPasswordInput: root.wifiPasswordInput
|
||||
wifiPasswordDialogVisible: root.wifiPasswordDialogVisible
|
||||
changingNetworkPreference: root.changingNetworkPreference
|
||||
|
||||
// Bind the auto-refresh flag
|
||||
onWifiAutoRefreshEnabledChanged: {
|
||||
|
||||
@@ -23,16 +23,19 @@ Item {
|
||||
property string networkStatus: ""
|
||||
property bool wifiAvailable: false
|
||||
property bool wifiEnabled: false
|
||||
property bool wifiToggling: false
|
||||
property string ethernetIP: ""
|
||||
property string ethernetInterface: ""
|
||||
property string currentWifiSSID: ""
|
||||
property string wifiIP: ""
|
||||
property string wifiSignalStrength: ""
|
||||
property var wifiNetworks: []
|
||||
property bool wifiScanning: false
|
||||
property string wifiConnectionStatus: ""
|
||||
property string wifiPasswordSSID: ""
|
||||
property string wifiPasswordInput: ""
|
||||
property bool wifiPasswordDialogVisible: false
|
||||
property bool changingNetworkPreference: false
|
||||
|
||||
Column {
|
||||
anchors.fill: parent
|
||||
@@ -156,7 +159,7 @@ Item {
|
||||
color: Qt.rgba(Theme.surfaceContainer.r, Theme.surfaceContainer.g, Theme.surfaceContainer.b, 0.5)
|
||||
border.color: networkTab.networkStatus === "ethernet" ? Theme.primary : Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.12)
|
||||
border.width: networkTab.networkStatus === "ethernet" ? 2 : 1
|
||||
visible: networkTab.networkStatus === "ethernet" || networkTab.networkStatus === "disconnected"
|
||||
visible: true
|
||||
|
||||
Row {
|
||||
anchors.left: parent.left
|
||||
@@ -189,6 +192,79 @@ Item {
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.7)
|
||||
}
|
||||
}
|
||||
|
||||
// Force Ethernet preference button
|
||||
Rectangle {
|
||||
width: 120
|
||||
height: 30
|
||||
color: networkTab.networkStatus === "ethernet" ? Theme.primary : Theme.surface
|
||||
border.color: Theme.primary
|
||||
border.width: 1
|
||||
radius: 6
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
z: 10
|
||||
opacity: networkTab.changingNetworkPreference ? 0.6 : 1.0
|
||||
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
anchors.centerIn: parent
|
||||
spacing: Theme.spacingXS
|
||||
|
||||
Text {
|
||||
id: ethernetPreferenceIcon
|
||||
text: networkTab.changingNetworkPreference ? "sync" : ""
|
||||
font.family: Theme.iconFont
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: networkTab.networkStatus === "ethernet" ? Theme.background : Theme.primary
|
||||
visible: networkTab.changingNetworkPreference
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
rotation: networkTab.changingNetworkPreference ? ethernetPreferenceIcon.rotation : 0
|
||||
|
||||
RotationAnimation {
|
||||
target: ethernetPreferenceIcon
|
||||
property: "rotation"
|
||||
running: networkTab.changingNetworkPreference
|
||||
from: 0
|
||||
to: 360
|
||||
duration: 1000
|
||||
loops: Animation.Infinite
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
text: networkTab.changingNetworkPreference ? "Switching..." :
|
||||
(networkTab.networkStatus === "ethernet" ? "Using Ethernet" : "Use Ethernet")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: networkTab.networkStatus === "ethernet" ? Theme.background : Theme.primary
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
font.weight: Font.Medium
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
propagateComposedEvents: false
|
||||
enabled: !networkTab.changingNetworkPreference
|
||||
onClicked: {
|
||||
console.log("*** ETHERNET PREFERENCE BUTTON CLICKED ***")
|
||||
if (networkTab.networkStatus !== "ethernet") {
|
||||
console.log("Setting preference to ethernet")
|
||||
NetworkService.setNetworkPreference("ethernet")
|
||||
} else {
|
||||
console.log("Setting preference to auto")
|
||||
NetworkService.setNetworkPreference("auto")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,6 +339,14 @@ Item {
|
||||
radius: Theme.cornerRadius
|
||||
color: wifiToggleArea.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.08) : Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.08)
|
||||
visible: networkTab.wifiAvailable
|
||||
opacity: networkTab.wifiToggling ? 0.6 : 1.0
|
||||
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
anchors.left: parent.left
|
||||
@@ -271,15 +355,34 @@ Item {
|
||||
spacing: Theme.spacingM
|
||||
|
||||
Text {
|
||||
text: "power_settings_new"
|
||||
id: wifiToggleIcon
|
||||
text: networkTab.wifiToggling ? "sync" : "power_settings_new"
|
||||
font.family: Theme.iconFont
|
||||
font.pixelSize: Theme.iconSize
|
||||
color: networkTab.wifiEnabled ? Theme.primary : Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.5)
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
rotation: networkTab.wifiToggling ? wifiToggleIcon.rotation : 0
|
||||
|
||||
RotationAnimation {
|
||||
target: wifiToggleIcon
|
||||
property: "rotation"
|
||||
running: networkTab.wifiToggling
|
||||
from: 0
|
||||
to: 360
|
||||
duration: 1000
|
||||
loops: Animation.Infinite
|
||||
}
|
||||
|
||||
Behavior on rotation {
|
||||
RotationAnimation {
|
||||
duration: 200
|
||||
easing.type: Easing.OutQuad
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
text: networkTab.wifiEnabled ? "Turn WiFi Off" : "Turn WiFi On"
|
||||
text: networkTab.wifiToggling ? "Switching WiFi..." : (networkTab.wifiEnabled ? "Turn WiFi Off" : "Turn WiFi On")
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
color: Theme.surfaceText
|
||||
font.weight: Font.Medium
|
||||
@@ -343,6 +446,76 @@ Item {
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.7)
|
||||
}
|
||||
}
|
||||
|
||||
// Force WiFi preference button
|
||||
Rectangle {
|
||||
width: 120
|
||||
height: 30
|
||||
color: networkTab.networkStatus === "wifi" ? Theme.primary : Theme.surface
|
||||
border.color: Theme.primary
|
||||
border.width: 1
|
||||
radius: 6
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
opacity: networkTab.changingNetworkPreference ? 0.6 : 1.0
|
||||
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
anchors.centerIn: parent
|
||||
spacing: Theme.spacingXS
|
||||
|
||||
Text {
|
||||
id: wifiPreferenceIcon
|
||||
text: networkTab.changingNetworkPreference ? "sync" : ""
|
||||
font.family: Theme.iconFont
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: networkTab.networkStatus === "wifi" ? Theme.background : Theme.primary
|
||||
visible: networkTab.changingNetworkPreference
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
rotation: networkTab.changingNetworkPreference ? wifiPreferenceIcon.rotation : 0
|
||||
|
||||
RotationAnimation {
|
||||
target: wifiPreferenceIcon
|
||||
property: "rotation"
|
||||
running: networkTab.changingNetworkPreference
|
||||
from: 0
|
||||
to: 360
|
||||
duration: 1000
|
||||
loops: Animation.Infinite
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
text: networkTab.changingNetworkPreference ? "Switching..." :
|
||||
(networkTab.networkStatus === "wifi" ? "Using WiFi" : "Use WiFi")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: networkTab.networkStatus === "wifi" ? Theme.background : Theme.primary
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
font.weight: Font.Medium
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
propagateComposedEvents: false
|
||||
enabled: !networkTab.changingNetworkPreference
|
||||
onClicked: {
|
||||
console.log("Force WiFi preference clicked")
|
||||
if (networkTab.networkStatus !== "wifi") {
|
||||
NetworkService.setNetworkPreference("wifi")
|
||||
} else {
|
||||
NetworkService.setNetworkPreference("auto")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,14 +541,34 @@ Item {
|
||||
width: 32
|
||||
height: 32
|
||||
radius: 16
|
||||
color: refreshArea.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : "transparent"
|
||||
color: refreshArea.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) :
|
||||
networkTab.wifiScanning ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.06) : "transparent"
|
||||
|
||||
Text {
|
||||
id: refreshIcon
|
||||
anchors.centerIn: parent
|
||||
text: "refresh"
|
||||
text: networkTab.wifiScanning ? "sync" : "refresh"
|
||||
font.family: Theme.iconFont
|
||||
font.pixelSize: Theme.iconSize - 4
|
||||
color: Theme.surfaceText
|
||||
rotation: networkTab.wifiScanning ? refreshIcon.rotation : 0
|
||||
|
||||
RotationAnimation {
|
||||
target: refreshIcon
|
||||
property: "rotation"
|
||||
running: networkTab.wifiScanning
|
||||
from: 0
|
||||
to: 360
|
||||
duration: 1000
|
||||
loops: Animation.Infinite
|
||||
}
|
||||
|
||||
Behavior on rotation {
|
||||
RotationAnimation {
|
||||
duration: 200
|
||||
easing.type: Easing.OutQuad
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
@@ -383,6 +576,7 @@ Item {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
enabled: !networkTab.wifiScanning
|
||||
onClicked: {
|
||||
WifiService.scanWifi()
|
||||
}
|
||||
@@ -390,6 +584,7 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Connection status indicator
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
@@ -423,6 +618,7 @@ Item {
|
||||
spacing: Theme.spacingS
|
||||
|
||||
Text {
|
||||
id: connectionIcon
|
||||
text: {
|
||||
if (networkTab.wifiConnectionStatus === "connecting") return "sync"
|
||||
if (networkTab.wifiConnectionStatus === "failed") return "error"
|
||||
@@ -438,22 +634,31 @@ Item {
|
||||
return Theme.surfaceText
|
||||
}
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
rotation: networkTab.wifiConnectionStatus === "connecting" ? connectionIcon.rotation : 0
|
||||
|
||||
RotationAnimation {
|
||||
target: parent
|
||||
target: connectionIcon
|
||||
property: "rotation"
|
||||
running: networkTab.wifiConnectionStatus === "connecting"
|
||||
from: 0
|
||||
to: 360
|
||||
duration: 1000
|
||||
loops: Animation.Infinite
|
||||
}
|
||||
|
||||
Behavior on rotation {
|
||||
RotationAnimation {
|
||||
duration: 200
|
||||
easing.type: Easing.OutQuad
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
text: {
|
||||
if (networkTab.wifiConnectionStatus === "connecting") return "Connecting to " + networkTab.wifiPasswordSSID
|
||||
if (networkTab.wifiConnectionStatus === "failed") return "Failed to connect to " + networkTab.wifiPasswordSSID
|
||||
if (networkTab.wifiConnectionStatus === "connected") return "Connected to " + networkTab.wifiPasswordSSID
|
||||
if (networkTab.wifiConnectionStatus === "connecting") return "Connecting to " + WifiService.connectingSSID
|
||||
if (networkTab.wifiConnectionStatus === "failed") return "Failed to connect to " + WifiService.connectingSSID
|
||||
if (networkTab.wifiConnectionStatus === "connected") return "Connected to " + WifiService.connectingSSID
|
||||
return ""
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
@@ -598,10 +803,10 @@ Item {
|
||||
// Saved network, connect directly
|
||||
WifiService.connectToWifi(modelData.ssid)
|
||||
} else if (modelData.secured) {
|
||||
// Secured network, need password
|
||||
networkTab.wifiPasswordSSID = modelData.ssid
|
||||
networkTab.wifiPasswordInput = ""
|
||||
networkTab.wifiPasswordDialogVisible = true
|
||||
// Secured network, need password - use root dialog
|
||||
root.wifiPasswordSSID = modelData.ssid
|
||||
root.wifiPasswordInput = ""
|
||||
root.wifiPasswordDialogVisible = true
|
||||
} else {
|
||||
// Open network, connect directly
|
||||
WifiService.connectToWifi(modelData.ssid)
|
||||
@@ -641,6 +846,7 @@ Item {
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.4)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,12 +70,15 @@ ShellRoot {
|
||||
property bool bluetoothAvailable: BluetoothService.bluetoothAvailable
|
||||
property bool wifiEnabled: NetworkService.wifiEnabled
|
||||
property bool wifiAvailable: NetworkService.wifiAvailable
|
||||
property bool wifiToggling: NetworkService.wifiToggling
|
||||
property bool changingNetworkPreference: NetworkService.changingPreference
|
||||
|
||||
// WiFi properties from WifiService
|
||||
property string wifiSignalStrength: WifiService.wifiSignalStrength
|
||||
property string currentWifiSSID: WifiService.currentWifiSSID
|
||||
property var wifiNetworks: WifiService.wifiNetworks
|
||||
property var savedWifiNetworks: WifiService.savedWifiNetworks
|
||||
property bool wifiScanning: WifiService.isScanning
|
||||
|
||||
// Audio properties from AudioService
|
||||
property int volumeLevel: AudioService.volumeLevel
|
||||
@@ -102,7 +105,7 @@ ShellRoot {
|
||||
property bool wifiPasswordDialogVisible: false
|
||||
property string wifiPasswordSSID: ""
|
||||
property string wifiPasswordInput: ""
|
||||
property string wifiConnectionStatus: ""
|
||||
property string wifiConnectionStatus: WifiService.connectionStatus
|
||||
property bool wifiAutoRefreshEnabled: false
|
||||
|
||||
// Wallpaper error status
|
||||
|
||||
Reference in New Issue
Block a user