mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-06-19 01:25:21 -04:00
feat(network): add saved WiFi state to settings (#2648)
This commit is contained in:
@@ -69,6 +69,7 @@ Singleton {
|
||||
property bool changingPreference: false
|
||||
property string targetPreference: ""
|
||||
property var savedWifiNetworks: []
|
||||
readonly property int savedWifiStateApiVersion: 26
|
||||
property string connectionStatus: ""
|
||||
property string lastConnectionError: ""
|
||||
property bool passwordDialogShouldReopen: false
|
||||
@@ -309,17 +310,21 @@ Singleton {
|
||||
|
||||
if (state.wifiNetworks) {
|
||||
wifiNetworks = state.wifiNetworks;
|
||||
}
|
||||
|
||||
if (state.wifiNetworks || state.savedWifiNetworks) {
|
||||
const hasSavedWifiState = DMSService.apiVersion >= savedWifiStateApiVersion && Array.isArray(state.savedWifiNetworks);
|
||||
const sourceSavedNetworks = hasSavedWifiState ? state.savedWifiNetworks : (state.wifiNetworks || []).filter(network => network.saved);
|
||||
const saved = [];
|
||||
const mapping = {};
|
||||
for (const network of state.wifiNetworks) {
|
||||
if (network.saved) {
|
||||
saved.push({
|
||||
ssid: network.ssid,
|
||||
saved: true
|
||||
});
|
||||
for (const network of sourceSavedNetworks) {
|
||||
const normalized = Object.assign({}, network, {
|
||||
saved: true,
|
||||
outOfRange: hasSavedWifiState ? network.outOfRange === true : false
|
||||
});
|
||||
saved.push(normalized);
|
||||
if (network?.ssid)
|
||||
mapping[network.ssid] = network.ssid;
|
||||
}
|
||||
}
|
||||
savedConnections = saved;
|
||||
savedWifiNetworks = saved;
|
||||
@@ -596,6 +601,7 @@ Singleton {
|
||||
}
|
||||
wifiNetworks = updated;
|
||||
networksUpdated();
|
||||
Qt.callLater(() => refreshSavedWifiNetworks());
|
||||
}
|
||||
forgetSSID = "";
|
||||
});
|
||||
@@ -985,4 +991,11 @@ Singleton {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function refreshSavedWifiNetworks() {
|
||||
if (!networkAvailable)
|
||||
return;
|
||||
|
||||
getState();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,9 +142,11 @@ Singleton {
|
||||
|
||||
readonly property var savedConnections: wifiNetworks.filter(n => n.saved).map(n => ({
|
||||
"ssid": n.ssid,
|
||||
"saved": true
|
||||
"saved": true,
|
||||
"outOfRange": false
|
||||
}))
|
||||
readonly property var savedWifiNetworks: savedConnections
|
||||
readonly property int savedWifiStateApiVersion: 26
|
||||
readonly property var ssidToConnectionName: {
|
||||
const map = {};
|
||||
for (const n of wifiNetworks) {
|
||||
|
||||
@@ -54,6 +54,7 @@ Singleton {
|
||||
property bool changingPreference: activeService?.changingPreference ?? false
|
||||
property string targetPreference: activeService?.targetPreference ?? ""
|
||||
property var savedWifiNetworks: activeService?.savedWifiNetworks ?? []
|
||||
readonly property int savedWifiStateApiVersion: activeService?.savedWifiStateApiVersion ?? 26
|
||||
property string connectionStatus: activeService?.connectionStatus ?? ""
|
||||
property string lastConnectionError: activeService?.lastConnectionError ?? ""
|
||||
property bool passwordDialogShouldReopen: activeService?.passwordDialogShouldReopen ?? false
|
||||
@@ -180,6 +181,12 @@ Singleton {
|
||||
}
|
||||
}
|
||||
|
||||
function refreshSavedWifiNetworks() {
|
||||
if (activeService && activeService.refreshSavedWifiNetworks) {
|
||||
activeService.refreshSavedWifiNetworks();
|
||||
}
|
||||
}
|
||||
|
||||
function connectToWifi(ssid, password = "", username = "", anonymousIdentity = "", domainSuffixMatch = "") {
|
||||
if (activeService && activeService.connectToWifi) {
|
||||
activeService.connectToWifi(ssid, password, username, anonymousIdentity, domainSuffixMatch);
|
||||
|
||||
Reference in New Issue
Block a user