1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 21:42:51 -05:00

network: tweak preference settings for clarity

This commit is contained in:
bbedward
2025-07-16 17:20:30 -04:00
parent ed17b43d45
commit a49911863d
5 changed files with 44 additions and 17 deletions

View File

@@ -11,6 +11,7 @@ Singleton {
property string networkStatus: "disconnected" // "ethernet", "wifi", "disconnected" property string networkStatus: "disconnected" // "ethernet", "wifi", "disconnected"
property string ethernetIP: "" property string ethernetIP: ""
property string ethernetInterface: "" property string ethernetInterface: ""
property bool ethernetConnected: false
property string wifiIP: "" property string wifiIP: ""
property bool wifiAvailable: false property bool wifiAvailable: false
property bool wifiEnabled: true property bool wifiEnabled: true
@@ -25,8 +26,8 @@ Singleton {
root.userPreference = Prefs.networkPreference root.userPreference = Prefs.networkPreference
console.log("NetworkService: Loaded network preference from Prefs:", root.userPreference) console.log("NetworkService: Loaded network preference from Prefs:", root.userPreference)
// Trigger immediate WiFi info update if WiFi is connected // Trigger immediate WiFi info update if WiFi is connected and enabled
if (root.networkStatus === "wifi") { if (root.networkStatus === "wifi" && root.wifiEnabled) {
WifiService.updateCurrentWifiInfo() WifiService.updateCurrentWifiInfo()
} }
} }
@@ -46,6 +47,9 @@ Singleton {
let hasWifi = text.includes("wifi:connected") let hasWifi = text.includes("wifi:connected")
let ethernetCableUp = text.includes("state UP") let ethernetCableUp = text.includes("state UP")
// Update connection status properties
root.ethernetConnected = hasEthernet || ethernetCableUp
// Always check both IPs when available // Always check both IPs when available
if (hasWifi) { if (hasWifi) {
wifiIPChecker.running = true wifiIPChecker.running = true
@@ -62,7 +66,9 @@ Singleton {
if (root.userPreference === "wifi") { if (root.userPreference === "wifi") {
root.networkStatus = "wifi" root.networkStatus = "wifi"
console.log("User prefers WiFi, setting status to wifi") console.log("User prefers WiFi, setting status to wifi")
WifiService.updateCurrentWifiInfo() if (root.wifiEnabled) {
WifiService.updateCurrentWifiInfo()
}
} else if (root.userPreference === "ethernet") { } else if (root.userPreference === "ethernet") {
root.networkStatus = "ethernet" root.networkStatus = "ethernet"
console.log("User prefers Ethernet, setting status to ethernet") console.log("User prefers Ethernet, setting status to ethernet")
@@ -83,7 +89,9 @@ Singleton {
root.networkStatus = "wifi" root.networkStatus = "wifi"
console.log("WiFi interface has default route, setting status to wifi") console.log("WiFi interface has default route, setting status to wifi")
// Trigger WiFi SSID update // Trigger WiFi SSID update
WifiService.updateCurrentWifiInfo() if (root.wifiEnabled) {
WifiService.updateCurrentWifiInfo()
}
} else if (defaultInterface.startsWith("en") || defaultInterface.includes("eth")) { } else if (defaultInterface.startsWith("en") || defaultInterface.includes("eth")) {
root.networkStatus = "ethernet" root.networkStatus = "ethernet"
console.log("Ethernet interface has default route, setting status to ethernet") console.log("Ethernet interface has default route, setting status to ethernet")
@@ -100,7 +108,9 @@ Singleton {
root.networkStatus = "wifi" root.networkStatus = "wifi"
console.log("Only WiFi connected, setting status to wifi") console.log("Only WiFi connected, setting status to wifi")
// Trigger WiFi SSID update // Trigger WiFi SSID update
WifiService.updateCurrentWifiInfo() if (root.wifiEnabled) {
WifiService.updateCurrentWifiInfo()
}
} else if (hasEthernet || ethernetCableUp) { } else if (hasEthernet || ethernetCableUp) {
root.networkStatus = "ethernet" root.networkStatus = "ethernet"
console.log("Only Ethernet connected, setting status to ethernet") console.log("Only Ethernet connected, setting status to ethernet")
@@ -108,6 +118,7 @@ Singleton {
root.networkStatus = "disconnected" root.networkStatus = "disconnected"
root.ethernetIP = "" root.ethernetIP = ""
root.ethernetInterface = "" root.ethernetInterface = ""
root.ethernetConnected = false
root.wifiIP = "" root.wifiIP = ""
console.log("Setting network status to disconnected") console.log("Setting network status to disconnected")
} }
@@ -138,6 +149,7 @@ Singleton {
root.networkStatus = "disconnected" root.networkStatus = "disconnected"
root.ethernetIP = "" root.ethernetIP = ""
root.ethernetInterface = "" root.ethernetInterface = ""
root.ethernetConnected = false
root.wifiIP = "" root.wifiIP = ""
console.log("No network output, setting to disconnected") console.log("No network output, setting to disconnected")
} }
@@ -430,6 +442,10 @@ Singleton {
function connectToWifiAndSetPreference(ssid, password) { function connectToWifiAndSetPreference(ssid, password) {
console.log("Connecting to WiFi and setting preference:", ssid) console.log("Connecting to WiFi and setting preference:", ssid)
if (!root.wifiEnabled) {
console.log("WiFi is disabled, cannot connect to network")
return
}
root.userPreference = "wifi" root.userPreference = "wifi"
Prefs.setNetworkPreference("wifi") Prefs.setNetworkPreference("wifi")
WifiService.connectToWifiWithPassword(ssid, password) WifiService.connectToWifiWithPassword(ssid, password)

View File

@@ -653,6 +653,7 @@ PanelWindow {
wifiToggling: root.wifiToggling wifiToggling: root.wifiToggling
ethernetIP: root.ethernetIP ethernetIP: root.ethernetIP
ethernetInterface: root.ethernetInterface ethernetInterface: root.ethernetInterface
ethernetConnected: root.ethernetConnected
currentWifiSSID: root.currentWifiSSID currentWifiSSID: root.currentWifiSSID
wifiIP: root.wifiIP wifiIP: root.wifiIP
wifiSignalStrength: root.wifiSignalStrength wifiSignalStrength: root.wifiSignalStrength

View File

@@ -26,6 +26,7 @@ Item {
property bool wifiToggling: false property bool wifiToggling: false
property string ethernetIP: "" property string ethernetIP: ""
property string ethernetInterface: "" property string ethernetInterface: ""
property bool ethernetConnected: false
property string currentWifiSSID: "" property string currentWifiSSID: ""
property string wifiIP: "" property string wifiIP: ""
property string wifiSignalStrength: "" property string wifiSignalStrength: ""
@@ -124,7 +125,9 @@ Item {
onClicked: { onClicked: {
networkTab.networkSubTab = 1 networkTab.networkSubTab = 1
networkTab.wifiAutoRefreshEnabled = true networkTab.wifiAutoRefreshEnabled = true
WifiService.scanWifi() if (NetworkService.wifiEnabled) {
WifiService.scanWifi()
}
} }
} }
} }
@@ -187,7 +190,7 @@ Item {
} }
Text { Text {
text: networkTab.networkStatus === "ethernet" ? (networkTab.ethernetIP || "Connected") : "Disconnected" text: networkTab.ethernetConnected ? (networkTab.ethernetIP || "Connected") : "Disconnected"
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.7) color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.7)
} }
@@ -195,7 +198,7 @@ Item {
// Force Ethernet preference button // Force Ethernet preference button
Rectangle { Rectangle {
width: 120 width: 150
height: 30 height: 30
color: networkTab.networkStatus === "ethernet" ? Theme.primary : Theme.surface color: networkTab.networkStatus === "ethernet" ? Theme.primary : Theme.surface
border.color: Theme.primary border.color: Theme.primary
@@ -204,6 +207,7 @@ Item {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
z: 10 z: 10
opacity: networkTab.changingNetworkPreference ? 0.6 : 1.0 opacity: networkTab.changingNetworkPreference ? 0.6 : 1.0
visible: networkTab.networkStatus !== "ethernet"
Behavior on opacity { Behavior on opacity {
NumberAnimation { NumberAnimation {
@@ -239,7 +243,7 @@ Item {
Text { Text {
text: networkTab.changingNetworkPreference ? "Switching..." : text: networkTab.changingNetworkPreference ? "Switching..." :
(networkTab.networkStatus === "ethernet" ? "Using Ethernet" : "Use Ethernet") (networkTab.networkStatus === "ethernet" ? "" : "Prefer over WiFi")
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
color: networkTab.networkStatus === "ethernet" ? Theme.background : Theme.primary color: networkTab.networkStatus === "ethernet" ? Theme.background : Theme.primary
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
@@ -282,15 +286,15 @@ Item {
spacing: Theme.spacingM spacing: Theme.spacingM
Text { Text {
text: networkTab.networkStatus === "ethernet" ? "link_off" : "link" text: networkTab.ethernetConnected ? "link_off" : "link"
font.family: Theme.iconFont font.family: Theme.iconFont
font.pixelSize: Theme.iconSize font.pixelSize: Theme.iconSize
color: networkTab.networkStatus === "ethernet" ? Theme.error : Theme.primary color: networkTab.ethernetConnected ? Theme.error : Theme.primary
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
} }
Text { Text {
text: networkTab.networkStatus === "ethernet" ? "Disconnect Ethernet" : "Connect Ethernet" text: networkTab.ethernetConnected ? "Disconnect Ethernet" : "Connect Ethernet"
font.pixelSize: Theme.fontSizeMedium font.pixelSize: Theme.fontSizeMedium
color: Theme.surfaceText color: Theme.surfaceText
font.weight: Font.Medium font.weight: Font.Medium
@@ -449,7 +453,7 @@ Item {
// Force WiFi preference button // Force WiFi preference button
Rectangle { Rectangle {
width: 120 width: 150
height: 30 height: 30
color: networkTab.networkStatus === "wifi" ? Theme.primary : Theme.surface color: networkTab.networkStatus === "wifi" ? Theme.primary : Theme.surface
border.color: Theme.primary border.color: Theme.primary
@@ -457,6 +461,7 @@ Item {
radius: 6 radius: 6
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
opacity: networkTab.changingNetworkPreference ? 0.6 : 1.0 opacity: networkTab.changingNetworkPreference ? 0.6 : 1.0
visible: networkTab.networkStatus !== "wifi"
Behavior on opacity { Behavior on opacity {
NumberAnimation { NumberAnimation {
@@ -492,7 +497,7 @@ Item {
Text { Text {
text: networkTab.changingNetworkPreference ? "Switching..." : text: networkTab.changingNetworkPreference ? "Switching..." :
(networkTab.networkStatus === "wifi" ? "Using WiFi" : "Use WiFi") (networkTab.networkStatus === "wifi" ? "" : "Prefer over Ethernet")
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
color: networkTab.networkStatus === "wifi" ? Theme.background : Theme.primary color: networkTab.networkStatus === "wifi" ? Theme.background : Theme.primary
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
@@ -578,7 +583,9 @@ Item {
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
enabled: !networkTab.wifiScanning enabled: !networkTab.wifiScanning
onClicked: { onClicked: {
WifiService.scanWifi() if (NetworkService.wifiEnabled) {
WifiService.scanWifi()
}
} }
} }
} }

View File

@@ -319,7 +319,9 @@ PanelWindow {
if (topBar.shellRoot) { if (topBar.shellRoot) {
topBar.shellRoot.controlCenterVisible = !topBar.shellRoot.controlCenterVisible topBar.shellRoot.controlCenterVisible = !topBar.shellRoot.controlCenterVisible
if (topBar.shellRoot.controlCenterVisible) { if (topBar.shellRoot.controlCenterVisible) {
WifiService.scanWifi() if (NetworkService.wifiEnabled) {
WifiService.scanWifi()
}
// Bluetooth devices are automatically updated via signals // Bluetooth devices are automatically updated via signals
} }
} }

View File

@@ -65,6 +65,7 @@ ShellRoot {
property string networkStatus: NetworkService.networkStatus property string networkStatus: NetworkService.networkStatus
property string ethernetIP: NetworkService.ethernetIP property string ethernetIP: NetworkService.ethernetIP
property string ethernetInterface: NetworkService.ethernetInterface property string ethernetInterface: NetworkService.ethernetInterface
property bool ethernetConnected: NetworkService.ethernetConnected
property string wifiIP: NetworkService.wifiIP property string wifiIP: NetworkService.wifiIP
property bool bluetoothEnabled: BluetoothService.bluetoothEnabled property bool bluetoothEnabled: BluetoothService.bluetoothEnabled
property bool bluetoothAvailable: BluetoothService.bluetoothAvailable property bool bluetoothAvailable: BluetoothService.bluetoothAvailable
@@ -130,7 +131,7 @@ ShellRoot {
running: root.wifiAutoRefreshEnabled && root.controlCenterVisible running: root.wifiAutoRefreshEnabled && root.controlCenterVisible
repeat: true repeat: true
onTriggered: { onTriggered: {
if (root.wifiAutoRefreshEnabled && root.controlCenterVisible) { if (root.wifiAutoRefreshEnabled && root.controlCenterVisible && NetworkService.wifiEnabled) {
WifiService.scanWifi() WifiService.scanWifi()
} }
} }