summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorATMDA <atdma2600@gmail.com>2025-11-13 19:52:24 -0500
committerATMDA <atdma2600@gmail.com>2025-11-13 19:52:24 -0500
commit7799ec67fda75d8b06f59c491ef119b15d9daf3d (patch)
treeb33b9b71d7c504c01cbbca5c72c8a75d53c60c3a
parentnetwork: migrated to nmcli.qml (diff)
downloadcaelestia-shell-7799ec67fda75d8b06f59c491ef119b15d9daf3d.tar.gz
caelestia-shell-7799ec67fda75d8b06f59c491ef119b15d9daf3d.tar.bz2
caelestia-shell-7799ec67fda75d8b06f59c491ef119b15d9daf3d.zip
nmcli: migrated all of wireless controlcenter
-rw-r--r--modules/controlcenter/network/WirelessDetails.qml61
-rw-r--r--modules/controlcenter/network/WirelessList.qml55
-rw-r--r--modules/controlcenter/network/WirelessPasswordDialog.qml66
-rw-r--r--modules/controlcenter/network/WirelessSettings.qml12
4 files changed, 84 insertions, 110 deletions
diff --git a/modules/controlcenter/network/WirelessDetails.qml b/modules/controlcenter/network/WirelessDetails.qml
index d5abc9d..4f11589 100644
--- a/modules/controlcenter/network/WirelessDetails.qml
+++ b/modules/controlcenter/network/WirelessDetails.qml
@@ -28,28 +28,23 @@ Item {
}
function checkSavedProfile(): void {
- // Refresh saved connections list to ensure it's up to date
- // This ensures the "Forget Network" button visibility is accurate
if (network && network.ssid) {
- // Always refresh to ensure we have the latest saved connections
- // This is important when networks are selected or changed
- Network.listConnectionsProc.running = true;
+ Nmcli.loadSavedConnections(() => {});
}
}
Connections {
- target: Network
+ target: Nmcli
function onActiveChanged() {
updateDeviceDetails();
}
}
function updateDeviceDetails(): void {
- // Only update details if the selected network is currently active
- if (network && Network.active && Network.active.ssid === network.ssid) {
- Network.updateWirelessDeviceDetails();
+ if (network && Nmcli.active && Nmcli.active.ssid === network.ssid) {
+ Nmcli.getWirelessDeviceDetails("", () => {});
} else {
- Network.wirelessDeviceDetails = null;
+ Nmcli.wirelessDeviceDetails = null;
}
}
@@ -84,7 +79,7 @@ Item {
if (checked) {
handleConnect();
} else {
- Network.disconnectFromNetwork();
+ Nmcli.disconnectFromNetwork();
}
}
}
@@ -96,8 +91,7 @@ Item {
if (!root.network || !root.network.ssid) {
return false;
}
- // Check if profile exists - this will update reactively when savedConnectionSsids changes
- return Network.hasSavedProfile(root.network.ssid);
+ return Nmcli.hasSavedProfile(root.network.ssid);
}
color: Colours.palette.m3errorContainer
onColor: Colours.palette.m3onErrorContainer
@@ -105,12 +99,10 @@ Item {
onClicked: {
if (root.network && root.network.ssid) {
- // Disconnect first if connected
if (root.network.active) {
- Network.disconnectFromNetwork();
+ Nmcli.disconnectFromNetwork();
}
- // Delete the connection profile
- Network.forgetNetwork(root.network.ssid);
+ Nmcli.forgetNetwork(root.network.ssid, () => {});
}
}
}
@@ -161,7 +153,7 @@ Item {
SectionContainer {
ConnectionInfoSection {
- deviceDetails: Network.wirelessDeviceDetails
+ deviceDetails: Nmcli.wirelessDeviceDetails
}
}
@@ -169,9 +161,8 @@ Item {
}
function handleConnect(): void {
- // If already connected to a different network, disconnect first
- if (Network.active && Network.active.ssid !== root.network.ssid) {
- Network.disconnectFromNetwork();
+ if (Nmcli.active && Nmcli.active.ssid !== root.network.ssid) {
+ Nmcli.disconnectFromNetwork();
Qt.callLater(() => {
connectToNetwork();
});
@@ -182,29 +173,31 @@ Item {
function connectToNetwork(): void {
if (root.network.isSecure) {
- // Check if we have a saved connection profile for this network (by SSID)
- const hasSavedProfile = Network.hasSavedProfile(root.network.ssid);
+ const hasSavedProfile = Nmcli.hasSavedProfile(root.network.ssid);
if (hasSavedProfile) {
- // Try connecting with saved password - don't show dialog if it fails
- // The saved password should work, but if connection fails for other reasons,
- // we'll let the user try manually later
- Network.connectToNetwork(root.network.ssid, "", root.network.bssid, null);
+ Nmcli.connectToNetwork(root.network.ssid, "", root.network.bssid, null);
} else {
- // No saved profile, try connecting without password first
- Network.connectToNetworkWithPasswordCheck(
+ Nmcli.connectToNetworkWithPasswordCheck(
root.network.ssid,
root.network.isSecure,
- () => {
- // Callback: connection failed, show password dialog
- root.session.network.showPasswordDialog = true;
- root.session.network.pendingNetwork = root.network;
+ (result) => {
+ if (result.needsPassword) {
+ if (Nmcli.pendingConnection) {
+ Nmcli.connectionCheckTimer.stop();
+ Nmcli.immediateCheckTimer.stop();
+ Nmcli.immediateCheckTimer.checkCount = 0;
+ Nmcli.pendingConnection = null;
+ }
+ root.session.network.showPasswordDialog = true;
+ root.session.network.pendingNetwork = root.network;
+ }
},
root.network.bssid
);
}
} else {
- Network.connectToNetwork(root.network.ssid, "", root.network.bssid, null);
+ Nmcli.connectToNetwork(root.network.ssid, "", root.network.bssid, null);
}
}
} \ No newline at end of file
diff --git a/modules/controlcenter/network/WirelessList.qml b/modules/controlcenter/network/WirelessList.qml
index ca6947a..f4e76b4 100644
--- a/modules/controlcenter/network/WirelessList.qml
+++ b/modules/controlcenter/network/WirelessList.qml
@@ -31,22 +31,22 @@ ColumnLayout {
}
ToggleButton {
- toggled: Network.wifiEnabled
+ toggled: Nmcli.wifiEnabled
icon: "wifi"
accent: "Tertiary"
onClicked: {
- Network.toggleWifi();
+ Nmcli.toggleWifi(null);
}
}
ToggleButton {
- toggled: Network.scanning
+ toggled: Nmcli.scanning
icon: "wifi_find"
accent: "Secondary"
onClicked: {
- Network.rescanWifi();
+ Nmcli.rescanWifi();
}
}
@@ -70,13 +70,13 @@ ColumnLayout {
spacing: Appearance.spacing.small
StyledText {
- text: qsTr("Networks (%1)").arg(Network.networks.length)
+ text: qsTr("Networks (%1)").arg(Nmcli.networks.length)
font.pointSize: Appearance.font.size.large
font.weight: 500
}
StyledText {
- visible: Network.scanning
+ visible: Nmcli.scanning
text: qsTr("Scanning...")
color: Colours.palette.m3primary
font.pointSize: Appearance.font.size.small
@@ -94,7 +94,7 @@ ColumnLayout {
Layout.fillWidth: true
Layout.fillHeight: true
- model: Network.networks
+ model: Nmcli.networks
spacing: Appearance.spacing.small / 2
clip: true
@@ -183,7 +183,7 @@ ColumnLayout {
StateLayer {
function onClicked(): void {
if (modelData.active) {
- Network.disconnectFromNetwork();
+ Nmcli.disconnectFromNetwork();
} else {
handleConnect(modelData);
}
@@ -205,19 +205,14 @@ ColumnLayout {
}
function checkSavedProfileForNetwork(ssid: string): void {
- // Refresh saved connections list to ensure it's up to date
- // This ensures accurate profile detection when selecting networks
if (ssid && ssid.length > 0) {
- // Always refresh to ensure we have the latest saved connections
- // This is important when a network is selected from the list
- Network.listConnectionsProc.running = true;
+ Nmcli.loadSavedConnections(() => {});
}
}
function handleConnect(network): void {
- // If already connected to a different network, disconnect first
- if (Network.active && Network.active.ssid !== network.ssid) {
- Network.disconnectFromNetwork();
+ if (Nmcli.active && Nmcli.active.ssid !== network.ssid) {
+ Nmcli.disconnectFromNetwork();
Qt.callLater(() => {
connectToNetwork(network);
});
@@ -228,29 +223,31 @@ ColumnLayout {
function connectToNetwork(network): void {
if (network.isSecure) {
- // Check if we have a saved connection profile for this network (by SSID)
- const hasSavedProfile = Network.hasSavedProfile(network.ssid);
+ const hasSavedProfile = Nmcli.hasSavedProfile(network.ssid);
if (hasSavedProfile) {
- // Try connecting with saved password - don't show dialog if it fails
- // The saved password should work, but if connection fails for other reasons,
- // we'll let the user try manually later
- Network.connectToNetwork(network.ssid, "", network.bssid, null);
+ Nmcli.connectToNetwork(network.ssid, "", network.bssid, null);
} else {
- // No saved profile, try connecting without password first
- Network.connectToNetworkWithPasswordCheck(
+ Nmcli.connectToNetworkWithPasswordCheck(
network.ssid,
network.isSecure,
- () => {
- // Callback: connection failed, show password dialog
- root.session.network.showPasswordDialog = true;
- root.session.network.pendingNetwork = network;
+ (result) => {
+ if (result.needsPassword) {
+ if (Nmcli.pendingConnection) {
+ Nmcli.connectionCheckTimer.stop();
+ Nmcli.immediateCheckTimer.stop();
+ Nmcli.immediateCheckTimer.checkCount = 0;
+ Nmcli.pendingConnection = null;
+ }
+ root.session.network.showPasswordDialog = true;
+ root.session.network.pendingNetwork = network;
+ }
},
network.bssid
);
}
} else {
- Network.connectToNetwork(network.ssid, "", network.bssid, null);
+ Nmcli.connectToNetwork(network.ssid, "", network.bssid, null);
}
}
} \ No newline at end of file
diff --git a/modules/controlcenter/network/WirelessPasswordDialog.qml b/modules/controlcenter/network/WirelessPasswordDialog.qml
index 8a71fa8..e416016 100644
--- a/modules/controlcenter/network/WirelessPasswordDialog.qml
+++ b/modules/controlcenter/network/WirelessPasswordDialog.qml
@@ -108,26 +108,16 @@ Item {
Layout.alignment: Qt.AlignHCenter
Layout.topMargin: Appearance.spacing.small
- visible: Network.connectionStatus.length > 0 || connectButton.connecting
+ visible: connectButton.connecting
text: {
- if (Network.connectionStatus.length > 0) {
- return Network.connectionStatus;
- } else if (connectButton.connecting) {
+ if (connectButton.connecting) {
return qsTr("Connecting...");
}
return "";
}
- color: {
- const status = Network.connectionStatus;
- if (status.includes("Error") || status.includes("error") || status.includes("failed")) {
- return Colours.palette.m3error;
- } else if (status.includes("successful") || status.includes("Connected") || status.includes("success")) {
- return Colours.palette.m3primary;
- }
- return Colours.palette.m3onSurfaceVariant;
- }
+ color: Colours.palette.m3onSurfaceVariant
font.pointSize: Appearance.font.size.small
- font.weight: (Network.connectionStatus.includes("Error") || Network.connectionStatus.includes("error")) ? 500 : 400
+ font.weight: 400
wrapMode: Text.WordWrap
Layout.maximumWidth: parent.width - Appearance.padding.large * 2
}
@@ -166,7 +156,6 @@ Item {
if (root.visible) {
passwordField.forceActiveFocus();
passwordField.text = "";
- Network.clearConnectionStatus();
}
}
}
@@ -225,10 +214,9 @@ Item {
connecting = true;
enabled = false;
text = qsTr("Connecting...");
- Network.clearConnectionStatus();
// Connect to network
- Network.connectToNetwork(
+ Nmcli.connectToNetwork(
root.network.ssid,
password,
root.network.bssid || "",
@@ -248,27 +236,17 @@ Item {
return;
}
- // Check connection status message for success indicators
- const status = Network.connectionStatus;
- const statusLower = status.toLowerCase();
-
- // Check for success indicators in status message
- const hasSuccessIndicator = statusLower.includes("connection activated") ||
- statusLower.includes("successfully") ||
- statusLower.includes("connected successfully") ||
- (statusLower.includes("connected") && !statusLower.includes("error") && !statusLower.includes("failed"));
-
// Check if we're connected to the target network (case-insensitive SSID comparison)
- const isConnected = root.network && Network.active && Network.active.ssid &&
- Network.active.ssid.toLowerCase().trim() === root.network.ssid.toLowerCase().trim();
+ const isConnected = root.network && Nmcli.active && Nmcli.active.ssid &&
+ Nmcli.active.ssid.toLowerCase().trim() === root.network.ssid.toLowerCase().trim();
- if (isConnected || hasSuccessIndicator) {
+ if (isConnected) {
// Successfully connected - give it a moment for network list to update
Qt.callLater(() => {
// Double-check connection is still active
- if (root.visible && Network.active && Network.active.ssid) {
- const stillConnected = Network.active.ssid.toLowerCase().trim() === root.network.ssid.toLowerCase().trim();
- if (stillConnected || hasSuccessIndicator) {
+ if (root.visible && Nmcli.active && Nmcli.active.ssid) {
+ const stillConnected = Nmcli.active.ssid.toLowerCase().trim() === root.network.ssid.toLowerCase().trim();
+ if (stillConnected) {
connectionMonitor.stop();
connectButton.connecting = false;
connectButton.text = qsTr("Connect");
@@ -279,11 +257,10 @@ Item {
return;
}
- // Check for connection errors (but not warnings about duplicate names)
- if (status.includes("Error") || (status.includes("error") && !status.includes("Warning"))) {
- // Only treat as error if it's not just a warning about duplicate names
- if (!status.includes("another connection with the name") && !status.includes("Reference the connection by its uuid")) {
- // Connection failed
+ // Check for connection failures - if pending connection was cleared but we're not connected
+ if (Nmcli.pendingConnection === null && connectButton.connecting) {
+ // Wait a bit more before giving up (allow time for connection to establish)
+ if (connectionMonitor.repeatCount > 10) {
connectionMonitor.stop();
connectButton.connecting = false;
connectButton.enabled = true;
@@ -297,14 +274,22 @@ Item {
interval: 1000
repeat: true
triggeredOnStart: false
+ property int repeatCount: 0
onTriggered: {
+ repeatCount++;
checkConnectionStatus();
}
+
+ onRunningChanged: {
+ if (!running) {
+ repeatCount = 0;
+ }
+ }
}
Connections {
- target: Network
+ target: Nmcli
function onActiveChanged() {
if (root.visible) {
checkConnectionStatus();
@@ -318,6 +303,5 @@ Item {
connectButton.connecting = false;
connectButton.text = qsTr("Connect");
connectionMonitor.stop();
- Network.clearConnectionStatus();
}
-} \ No newline at end of file
+}
diff --git a/modules/controlcenter/network/WirelessSettings.qml b/modules/controlcenter/network/WirelessSettings.qml
index 073b09c..0eb1578 100644
--- a/modules/controlcenter/network/WirelessSettings.qml
+++ b/modules/controlcenter/network/WirelessSettings.qml
@@ -39,9 +39,9 @@ ColumnLayout {
SectionContainer {
ToggleRow {
label: qsTr("WiFi enabled")
- checked: Network.wifiEnabled
+ checked: Nmcli.wifiEnabled
toggle.onToggled: {
- Network.enableWifi(checked);
+ Nmcli.enableWifi(checked);
}
}
}
@@ -57,25 +57,25 @@ ColumnLayout {
PropertyRow {
label: qsTr("Connected network")
- value: Network.active ? Network.active.ssid : qsTr("Not connected")
+ value: Nmcli.active ? Nmcli.active.ssid : qsTr("Not connected")
}
PropertyRow {
showTopMargin: true
label: qsTr("Signal strength")
- value: Network.active ? qsTr("%1%").arg(Network.active.strength) : qsTr("N/A")
+ value: Nmcli.active ? qsTr("%1%").arg(Nmcli.active.strength) : qsTr("N/A")
}
PropertyRow {
showTopMargin: true
label: qsTr("Security")
- value: Network.active ? (Network.active.isSecure ? qsTr("Secured") : qsTr("Open")) : qsTr("N/A")
+ value: Nmcli.active ? (Nmcli.active.isSecure ? qsTr("Secured") : qsTr("Open")) : qsTr("N/A")
}
PropertyRow {
showTopMargin: true
label: qsTr("Frequency")
- value: Network.active ? qsTr("%1 MHz").arg(Network.active.frequency) : qsTr("N/A")
+ value: Nmcli.active ? qsTr("%1 MHz").arg(Nmcli.active.frequency) : qsTr("N/A")
}
}
} \ No newline at end of file