carry over requested changes from pt1 | apply pt1.patch

This commit is contained in:
Turann_
2026-03-13 22:57:00 +03:00
parent c497b97219
commit a5ac9541fe
2 changed files with 95 additions and 84 deletions
@@ -278,6 +278,15 @@ Item {
}
}
// Auto-scan timer when panel is visible
Timer {
id: autoScanTimer
interval: 15000 // Scan every 15s
running: root.effectivelyVisible && Settings.data.network.wifiEnabled
repeat: true
onTriggered: NetworkService.scan()
}
Repeater {
model: root.availableNetworks
delegate: nboxDelegate
@@ -668,7 +677,7 @@ Item {
radius: Style.radiusM
clip: true
color: (modelData.connected && NetworkService.disconnectingFrom !== modelData.ssid) ? Qt.alpha(Color.mPrimary, Math.min(1.15 - Settings.data.ui.panelBackgroundOpacity, 0.75)) : Color.mSurface
color: (modelData.connected && NetworkService.disconnectingFrom !== modelData.ssid) ? Qt.alpha(Color.mPrimary, Color.panelBackgroundOpacity) : Color.mSurface
ColumnLayout {
id: deviceColumn
@@ -742,7 +751,7 @@ Item {
if (modelData.cached && !modelData.existing) {
return I18n.tr("wifi.panel.saved");
}
return NetworkService.isSecured(modelData.security) ? modelData.security : "Open";
return NetworkService.isSecured(modelData.security) ? modelData.security : I18n.tr("wifi.panel.security-open");
}
pointSize: Style.fontSizeXXS
color: {
+84 -82
View File
@@ -172,44 +172,8 @@ Singleton {
// Function to detect host's networking capabilities eg has WiFi/Ethernet.
function detectNetworkCapabilities() {
if (ProgramCheckerService.nmcliAvailable) {
Logger.d("Network", "Starting network capability detection...");
capabilityDetectProcess.running = true;
}
}
// Process to detect host's networking capabilities
Process {
id: capabilityDetectProcess
running: false
command: ["nmcli", "-t", "-f", "DEVICE,TYPE", "device"]
stdout: StdioCollector {
onStreamFinished: {
var lines = text.trim().split("\n");
var wifi = false;
var eth = false;
var wifiDev = "";
for (var i = 0; i < lines.length; i++) {
var parts = lines[i].split(":");
if (parts.length < 2)
continue;
var dev = parts[0].trim();
var type = parts[1].trim();
if (type === "wifi") {
wifi = true;
if (!wifiDev)
wifiDev = dev;
} else if (type === "ethernet") {
eth = true;
}
}
root._wifiAvailable = wifi;
root._ethernetAvailable = eth;
Logger.d("Network", "Detected capabilities - WiFi:", wifi, "Ethernet:", eth);
if (wifi && wifiDev) {
// Additional initialization if needed
}
}
Logger.d("Network", "Refreshing network status and capabilities...");
ethernetStateProcess.running = true;
}
}
@@ -573,28 +537,42 @@ Singleton {
stdout: StdioCollector {
onStreamFinished: {
var connected = false;
var wifiAvailable = false;
var ethernetAvailable = false;
var devIf = "";
var lines = text.split("\n");
var lines = text.trim().split("\n");
var ethList = [];
for (var i = 0; i < lines.length; i++) {
var parts = lines[i].split(":");
if (parts.length >= 3 && parts[1] === "ethernet" && parts[2] !== "unmanaged") {
if (parts.length >= 3) {
var ifname = parts[0];
var type = parts[1];
var state = parts[2];
var conName = parts.slice(3).join(":") || "";
var isConn = state === "connected";
ethList.push({
ifname: ifname,
state: state,
connected: isConn,
connectionName: conName
});
if (isConn && !connected) {
connected = true;
devIf = ifname;
if (type === "wifi") {
wifiAvailable = true;
} else if (type === "ethernet" && state !== "unmanaged") {
ethernetAvailable = true;
var isConn = state === "connected";
ethList.push({
ifname: ifname,
state: state,
connected: isConn,
connectionName: conName
});
if (isConn && !connected) {
connected = true;
devIf = ifname;
}
}
}
}
// Update capabilities
root._wifiAvailable = wifiAvailable;
root._ethernetAvailable = ethernetAvailable;
// Sort interfaces: connected first, then by name
ethList.sort(function (a, b) {
if (a.connected !== b.connected) {
@@ -1055,6 +1033,9 @@ Singleton {
id: wifiStateProcess
running: false
command: ["nmcli", "radio", "wifi"]
environment: ({
"LC_ALL": "C"
})
stdout: StdioCollector {
onStreamFinished: {
@@ -1442,10 +1423,10 @@ Singleton {
stderr: StdioCollector {
onStreamFinished: {
root.connecting = false;
root.connectingTo = "";
if (text.trim()) {
root.connecting = false;
root.connectingTo = "";
// Parse common errors
if (text.indexOf("Secrets were required") !== -1 || text.indexOf("no secrets provided") !== -1) {
root.lastError = I18n.tr("toast.wifi.incorrect-password");
@@ -1502,15 +1483,22 @@ Singleton {
}
const script = `
ID="$1"
nmcli connection delete id "$ID" 2>/dev/null || true
SSID="$1"
shift
nmcli "$@"
nmcli connection up id "$ID"
# Remove existing wifi profile with same SSID to avoid conflict
UUID=$(nmcli -t -f UUID,TYPE,NAME connection show | grep ":802-11-wireless:$SSID$" | head -n1 | cut -d: -f1)
if [ -n "$UUID" ]; then
nmcli connection delete uuid "$UUID" 2>/dev/null || true
fi
eval nmcli "$@"
nmcli connection up id "$SSID"
`;
return ["sh", "-c", script, "--", ssid].concat(nmArgs);
}
environment: ({
"LC_ALL": "C"
})
stdout: StdioCollector {
onStreamFinished: {
@@ -1546,9 +1534,9 @@ Singleton {
stderr: StdioCollector {
onStreamFinished: {
root.connecting = false;
root.connectingTo = "";
if (text.trim()) {
root.connecting = false;
root.connectingTo = "";
root.lastError = I18n.tr("toast.wifi.connection-failed");
Logger.w("Network", "Manual connect error: " + text);
ToastService.showWarning(I18n.tr("common.wifi"), root.lastError);
@@ -1597,32 +1585,46 @@ Singleton {
id: forgetProcess
property string ssid: ""
running: false
environment: ({
"LC_ALL": "C"
})
// Try multiple common profile name patterns
command: {
var script = "";
script += "ssid=\"$1\"\n";
script += "deleted=false\n\n";
script += "# Try exact SSID match first\n";
script += "if nmcli connection delete id \"$ssid\" 2>/dev/null; then\n";
script += " echo \"Deleted profile: $ssid\"\n";
script += " deleted=true\n";
script += "fi\n\n";
script += "# Try \"Auto $ssid\" pattern\n";
script += "if nmcli connection delete id \"Auto $ssid\" 2>/dev/null; then\n";
script += " echo \"Deleted profile: Auto $ssid\"\n";
script += " deleted=true\n";
script += "fi\n\n";
script += "# Try \"$ssid 1\", \"$ssid 2\", etc. patterns\n";
script += "for i in 1 2 3; do\n";
script += " if nmcli connection delete id \"$ssid $i\" 2>/dev/null; then\n";
script += " echo \"Deleted profile: $ssid $i\"\n";
script += " deleted=true\n";
script += " fi\n";
script += "done\n\n";
script += "if [ \"$deleted\" = \"false\" ]; then\n";
script += " echo \"No profiles found for SSID: $ssid\"\n";
script += "fi\n";
var script = `
ssid="$1"
deleted=false
# Try to find a wifi connection with this SSID and delete it
UUID=$(nmcli -t -f UUID,TYPE,NAME connection show | grep ":802-11-wireless:$ssid$" | head -n1 | cut -d: -f1)
if [ -n "$UUID" ]; then
if nmcli connection delete uuid "$UUID" 2>/dev/null; then
echo "Deleted profile: $ssid ($UUID)"
deleted=true
fi
fi
# Fallback: try common patterns if UUID lookup failed
if [ "$deleted" = "false" ]; then
# Try "Auto $ssid" pattern
if nmcli connection delete id "Auto $ssid" 2>/dev/null; then
echo "Deleted profile: Auto $ssid"
deleted=true
fi
# Try "$ssid 1", "$ssid 2", etc. patterns
for i in 1 2 3; do
if nmcli connection delete id "$ssid $i" 2>/dev/null; then
echo "Deleted profile: $ssid $i"
deleted=true
fi
done
fi
if [ "$deleted" = "false" ]; then
echo "No profiles found for SSID: $ssid"
fi
`;
return ["sh", "-c", script, "--", ssid];
}