mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 13:32:50 -05:00
network: tweak preference settings for clarity
This commit is contained in:
@@ -11,6 +11,7 @@ Singleton {
|
||||
property string networkStatus: "disconnected" // "ethernet", "wifi", "disconnected"
|
||||
property string ethernetIP: ""
|
||||
property string ethernetInterface: ""
|
||||
property bool ethernetConnected: false
|
||||
property string wifiIP: ""
|
||||
property bool wifiAvailable: false
|
||||
property bool wifiEnabled: true
|
||||
@@ -25,8 +26,8 @@ Singleton {
|
||||
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") {
|
||||
// Trigger immediate WiFi info update if WiFi is connected and enabled
|
||||
if (root.networkStatus === "wifi" && root.wifiEnabled) {
|
||||
WifiService.updateCurrentWifiInfo()
|
||||
}
|
||||
}
|
||||
@@ -46,6 +47,9 @@ Singleton {
|
||||
let hasWifi = text.includes("wifi:connected")
|
||||
let ethernetCableUp = text.includes("state UP")
|
||||
|
||||
// Update connection status properties
|
||||
root.ethernetConnected = hasEthernet || ethernetCableUp
|
||||
|
||||
// Always check both IPs when available
|
||||
if (hasWifi) {
|
||||
wifiIPChecker.running = true
|
||||
@@ -62,7 +66,9 @@ Singleton {
|
||||
if (root.userPreference === "wifi") {
|
||||
root.networkStatus = "wifi"
|
||||
console.log("User prefers WiFi, setting status to wifi")
|
||||
WifiService.updateCurrentWifiInfo()
|
||||
if (root.wifiEnabled) {
|
||||
WifiService.updateCurrentWifiInfo()
|
||||
}
|
||||
} else if (root.userPreference === "ethernet") {
|
||||
root.networkStatus = "ethernet"
|
||||
console.log("User prefers Ethernet, setting status to ethernet")
|
||||
@@ -83,7 +89,9 @@ Singleton {
|
||||
root.networkStatus = "wifi"
|
||||
console.log("WiFi interface has default route, setting status to wifi")
|
||||
// Trigger WiFi SSID update
|
||||
WifiService.updateCurrentWifiInfo()
|
||||
if (root.wifiEnabled) {
|
||||
WifiService.updateCurrentWifiInfo()
|
||||
}
|
||||
} else if (defaultInterface.startsWith("en") || defaultInterface.includes("eth")) {
|
||||
root.networkStatus = "ethernet"
|
||||
console.log("Ethernet interface has default route, setting status to ethernet")
|
||||
@@ -100,7 +108,9 @@ Singleton {
|
||||
root.networkStatus = "wifi"
|
||||
console.log("Only WiFi connected, setting status to wifi")
|
||||
// Trigger WiFi SSID update
|
||||
WifiService.updateCurrentWifiInfo()
|
||||
if (root.wifiEnabled) {
|
||||
WifiService.updateCurrentWifiInfo()
|
||||
}
|
||||
} else if (hasEthernet || ethernetCableUp) {
|
||||
root.networkStatus = "ethernet"
|
||||
console.log("Only Ethernet connected, setting status to ethernet")
|
||||
@@ -108,6 +118,7 @@ Singleton {
|
||||
root.networkStatus = "disconnected"
|
||||
root.ethernetIP = ""
|
||||
root.ethernetInterface = ""
|
||||
root.ethernetConnected = false
|
||||
root.wifiIP = ""
|
||||
console.log("Setting network status to disconnected")
|
||||
}
|
||||
@@ -138,6 +149,7 @@ Singleton {
|
||||
root.networkStatus = "disconnected"
|
||||
root.ethernetIP = ""
|
||||
root.ethernetInterface = ""
|
||||
root.ethernetConnected = false
|
||||
root.wifiIP = ""
|
||||
console.log("No network output, setting to disconnected")
|
||||
}
|
||||
@@ -430,6 +442,10 @@ Singleton {
|
||||
|
||||
function connectToWifiAndSetPreference(ssid, password) {
|
||||
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"
|
||||
Prefs.setNetworkPreference("wifi")
|
||||
WifiService.connectToWifiWithPassword(ssid, password)
|
||||
|
||||
@@ -653,6 +653,7 @@ PanelWindow {
|
||||
wifiToggling: root.wifiToggling
|
||||
ethernetIP: root.ethernetIP
|
||||
ethernetInterface: root.ethernetInterface
|
||||
ethernetConnected: root.ethernetConnected
|
||||
currentWifiSSID: root.currentWifiSSID
|
||||
wifiIP: root.wifiIP
|
||||
wifiSignalStrength: root.wifiSignalStrength
|
||||
|
||||
@@ -26,6 +26,7 @@ Item {
|
||||
property bool wifiToggling: false
|
||||
property string ethernetIP: ""
|
||||
property string ethernetInterface: ""
|
||||
property bool ethernetConnected: false
|
||||
property string currentWifiSSID: ""
|
||||
property string wifiIP: ""
|
||||
property string wifiSignalStrength: ""
|
||||
@@ -124,7 +125,9 @@ Item {
|
||||
onClicked: {
|
||||
networkTab.networkSubTab = 1
|
||||
networkTab.wifiAutoRefreshEnabled = true
|
||||
WifiService.scanWifi()
|
||||
if (NetworkService.wifiEnabled) {
|
||||
WifiService.scanWifi()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -187,7 +190,7 @@ Item {
|
||||
}
|
||||
|
||||
Text {
|
||||
text: networkTab.networkStatus === "ethernet" ? (networkTab.ethernetIP || "Connected") : "Disconnected"
|
||||
text: networkTab.ethernetConnected ? (networkTab.ethernetIP || "Connected") : "Disconnected"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.7)
|
||||
}
|
||||
@@ -195,7 +198,7 @@ Item {
|
||||
|
||||
// Force Ethernet preference button
|
||||
Rectangle {
|
||||
width: 120
|
||||
width: 150
|
||||
height: 30
|
||||
color: networkTab.networkStatus === "ethernet" ? Theme.primary : Theme.surface
|
||||
border.color: Theme.primary
|
||||
@@ -204,6 +207,7 @@ Item {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
z: 10
|
||||
opacity: networkTab.changingNetworkPreference ? 0.6 : 1.0
|
||||
visible: networkTab.networkStatus !== "ethernet"
|
||||
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
@@ -239,7 +243,7 @@ Item {
|
||||
|
||||
Text {
|
||||
text: networkTab.changingNetworkPreference ? "Switching..." :
|
||||
(networkTab.networkStatus === "ethernet" ? "Using Ethernet" : "Use Ethernet")
|
||||
(networkTab.networkStatus === "ethernet" ? "" : "Prefer over WiFi")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: networkTab.networkStatus === "ethernet" ? Theme.background : Theme.primary
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
@@ -282,15 +286,15 @@ Item {
|
||||
spacing: Theme.spacingM
|
||||
|
||||
Text {
|
||||
text: networkTab.networkStatus === "ethernet" ? "link_off" : "link"
|
||||
text: networkTab.ethernetConnected ? "link_off" : "link"
|
||||
font.family: Theme.iconFont
|
||||
font.pixelSize: Theme.iconSize
|
||||
color: networkTab.networkStatus === "ethernet" ? Theme.error : Theme.primary
|
||||
color: networkTab.ethernetConnected ? Theme.error : Theme.primary
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
Text {
|
||||
text: networkTab.networkStatus === "ethernet" ? "Disconnect Ethernet" : "Connect Ethernet"
|
||||
text: networkTab.ethernetConnected ? "Disconnect Ethernet" : "Connect Ethernet"
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
color: Theme.surfaceText
|
||||
font.weight: Font.Medium
|
||||
@@ -449,7 +453,7 @@ Item {
|
||||
|
||||
// Force WiFi preference button
|
||||
Rectangle {
|
||||
width: 120
|
||||
width: 150
|
||||
height: 30
|
||||
color: networkTab.networkStatus === "wifi" ? Theme.primary : Theme.surface
|
||||
border.color: Theme.primary
|
||||
@@ -457,6 +461,7 @@ Item {
|
||||
radius: 6
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
opacity: networkTab.changingNetworkPreference ? 0.6 : 1.0
|
||||
visible: networkTab.networkStatus !== "wifi"
|
||||
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
@@ -492,7 +497,7 @@ Item {
|
||||
|
||||
Text {
|
||||
text: networkTab.changingNetworkPreference ? "Switching..." :
|
||||
(networkTab.networkStatus === "wifi" ? "Using WiFi" : "Use WiFi")
|
||||
(networkTab.networkStatus === "wifi" ? "" : "Prefer over Ethernet")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: networkTab.networkStatus === "wifi" ? Theme.background : Theme.primary
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
@@ -578,7 +583,9 @@ Item {
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
enabled: !networkTab.wifiScanning
|
||||
onClicked: {
|
||||
WifiService.scanWifi()
|
||||
if (NetworkService.wifiEnabled) {
|
||||
WifiService.scanWifi()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,7 +319,9 @@ PanelWindow {
|
||||
if (topBar.shellRoot) {
|
||||
topBar.shellRoot.controlCenterVisible = !topBar.shellRoot.controlCenterVisible
|
||||
if (topBar.shellRoot.controlCenterVisible) {
|
||||
WifiService.scanWifi()
|
||||
if (NetworkService.wifiEnabled) {
|
||||
WifiService.scanWifi()
|
||||
}
|
||||
// Bluetooth devices are automatically updated via signals
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ ShellRoot {
|
||||
property string networkStatus: NetworkService.networkStatus
|
||||
property string ethernetIP: NetworkService.ethernetIP
|
||||
property string ethernetInterface: NetworkService.ethernetInterface
|
||||
property bool ethernetConnected: NetworkService.ethernetConnected
|
||||
property string wifiIP: NetworkService.wifiIP
|
||||
property bool bluetoothEnabled: BluetoothService.bluetoothEnabled
|
||||
property bool bluetoothAvailable: BluetoothService.bluetoothAvailable
|
||||
@@ -130,7 +131,7 @@ ShellRoot {
|
||||
running: root.wifiAutoRefreshEnabled && root.controlCenterVisible
|
||||
repeat: true
|
||||
onTriggered: {
|
||||
if (root.wifiAutoRefreshEnabled && root.controlCenterVisible) {
|
||||
if (root.wifiAutoRefreshEnabled && root.controlCenterVisible && NetworkService.wifiEnabled) {
|
||||
WifiService.scanWifi()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user