style: format code with consistent indentation and object literals
This commit is contained in:
parent
59d7d6292a
commit
3cf3474957
1 changed files with 78 additions and 37 deletions
|
|
@ -22,10 +22,14 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
function signalIcon(signal) {
|
function signalIcon(signal) {
|
||||||
if (signal >= 80) return "network_wifi";
|
if (signal >= 80)
|
||||||
if (signal >= 60) return "network_wifi_3_bar";
|
return "network_wifi";
|
||||||
if (signal >= 40) return "network_wifi_2_bar";
|
if (signal >= 60)
|
||||||
if (signal >= 20) return "network_wifi_1_bar";
|
return "network_wifi_3_bar";
|
||||||
|
if (signal >= 40)
|
||||||
|
return "network_wifi_2_bar";
|
||||||
|
if (signal >= 20)
|
||||||
|
return "network_wifi_1_bar";
|
||||||
return "wifi_0_bar";
|
return "wifi_0_bar";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -43,7 +47,8 @@ Item {
|
||||||
|
|
||||||
for (let i = 0; i < lines.length; ++i) {
|
for (let i = 0; i < lines.length; ++i) {
|
||||||
const line = lines[i].trim();
|
const line = lines[i].trim();
|
||||||
if (!line) continue;
|
if (!line)
|
||||||
|
continue;
|
||||||
|
|
||||||
const parts = line.split(":");
|
const parts = line.split(":");
|
||||||
if (parts.length < 2) {
|
if (parts.length < 2) {
|
||||||
|
|
@ -55,7 +60,10 @@ Item {
|
||||||
const type = parts[1];
|
const type = parts[1];
|
||||||
|
|
||||||
if (ssid) {
|
if (ssid) {
|
||||||
networksMap[ssid] = { ssid: ssid, type: type };
|
networksMap[ssid] = {
|
||||||
|
ssid: ssid,
|
||||||
|
type: type
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scanProcess.existingNetwork = networksMap;
|
scanProcess.existingNetwork = networksMap;
|
||||||
|
|
@ -78,7 +86,8 @@ Item {
|
||||||
|
|
||||||
for (let i = 0; i < lines.length; ++i) {
|
for (let i = 0; i < lines.length; ++i) {
|
||||||
const line = lines[i].trim();
|
const line = lines[i].trim();
|
||||||
if (!line) continue;
|
if (!line)
|
||||||
|
continue;
|
||||||
|
|
||||||
const parts = line.split(":");
|
const parts = line.split(":");
|
||||||
if (parts.length < 4) {
|
if (parts.length < 4) {
|
||||||
|
|
@ -92,7 +101,13 @@ Item {
|
||||||
|
|
||||||
if (ssid) {
|
if (ssid) {
|
||||||
if (!networksMap[ssid]) {
|
if (!networksMap[ssid]) {
|
||||||
networksMap[ssid] = { ssid: ssid, security: security, signal: signal, connected: inUse, existing: ssid in scanProcess.existingNetwork };
|
networksMap[ssid] = {
|
||||||
|
ssid: ssid,
|
||||||
|
security: security,
|
||||||
|
signal: signal,
|
||||||
|
connected: inUse,
|
||||||
|
existing: ssid in scanProcess.existingNetwork
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
const existingNet = networksMap[ssid];
|
const existingNet = networksMap[ssid];
|
||||||
if (inUse) {
|
if (inUse) {
|
||||||
|
|
@ -106,7 +121,7 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wifiLogic.networks = Object.values(networksMap);
|
wifiLogic.networks = Object.values(networksMap);
|
||||||
scanProcess.existingNetwork = null;
|
scanProcess.existingNetwork = {};
|
||||||
refreshIndicator.running = false;
|
refreshIndicator.running = false;
|
||||||
refreshIndicator.visible = false;
|
refreshIndicator.visible = false;
|
||||||
}
|
}
|
||||||
|
|
@ -144,16 +159,25 @@ Item {
|
||||||
wifiLogic.refreshNetworks();
|
wifiLogic.refreshNetworks();
|
||||||
}
|
}
|
||||||
function connectNetwork(ssid, security) {
|
function connectNetwork(ssid, security) {
|
||||||
wifiLogic.pendingConnect = {ssid: ssid, security: security, password: ""};
|
wifiLogic.pendingConnect = {
|
||||||
|
ssid: ssid,
|
||||||
|
security: security,
|
||||||
|
password: ""
|
||||||
|
};
|
||||||
wifiLogic.doConnect();
|
wifiLogic.doConnect();
|
||||||
}
|
}
|
||||||
function submitPassword() {
|
function submitPassword() {
|
||||||
wifiLogic.pendingConnect = {ssid: wifiLogic.passwordPromptSsid, security: wifiLogic.connectSecurity, password: wifiLogic.passwordInput};
|
wifiLogic.pendingConnect = {
|
||||||
|
ssid: wifiLogic.passwordPromptSsid,
|
||||||
|
security: wifiLogic.connectSecurity,
|
||||||
|
password: wifiLogic.passwordInput
|
||||||
|
};
|
||||||
wifiLogic.doConnect();
|
wifiLogic.doConnect();
|
||||||
}
|
}
|
||||||
function doConnect() {
|
function doConnect() {
|
||||||
const params = wifiLogic.pendingConnect;
|
const params = wifiLogic.pendingConnect;
|
||||||
if (!params) return;
|
if (!params)
|
||||||
|
return;
|
||||||
|
|
||||||
wifiLogic.connectingSsid = params.ssid;
|
wifiLogic.connectingSsid = params.ssid;
|
||||||
|
|
||||||
|
|
@ -204,8 +228,6 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Handles connecting to a Wi-Fi network, with or without password
|
// Handles connecting to a Wi-Fi network, with or without password
|
||||||
Process {
|
Process {
|
||||||
id: connectProcess
|
id: connectProcess
|
||||||
|
|
@ -221,9 +243,9 @@ Item {
|
||||||
}
|
}
|
||||||
command: {
|
command: {
|
||||||
if (password) {
|
if (password) {
|
||||||
return ["nmcli", "device", "wifi", "connect", ssid, "password", password]
|
return ["nmcli", "device", "wifi", "connect", ssid, "password", password];
|
||||||
} else {
|
} else {
|
||||||
return ["nmcli", "device", "wifi", "connect", ssid]
|
return ["nmcli", "device", "wifi", "connect", ssid];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stdout: StdioCollector {
|
stdout: StdioCollector {
|
||||||
|
|
@ -354,7 +376,8 @@ Item {
|
||||||
// Wifi button (no background card)
|
// Wifi button (no background card)
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: wifiButton
|
id: wifiButton
|
||||||
width: 36; height: 36
|
width: 36
|
||||||
|
height: 36
|
||||||
radius: 18
|
radius: 18
|
||||||
border.color: Theme.accentPrimary
|
border.color: Theme.accentPrimary
|
||||||
border.width: 1
|
border.width: 1
|
||||||
|
|
@ -365,9 +388,7 @@ Item {
|
||||||
text: "wifi"
|
text: "wifi"
|
||||||
font.family: "Material Symbols Outlined"
|
font.family: "Material Symbols Outlined"
|
||||||
font.pixelSize: 22
|
font.pixelSize: 22
|
||||||
color: wifiButtonArea.containsMouse
|
color: wifiButtonArea.containsMouse ? Theme.backgroundPrimary : Theme.accentPrimary
|
||||||
? Theme.backgroundPrimary
|
|
||||||
: Theme.accentPrimary
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
}
|
}
|
||||||
|
|
@ -393,7 +414,7 @@ Item {
|
||||||
margins.top: 0
|
margins.top: 0
|
||||||
WlrLayershell.keyboardFocus: WlrKeyboardFocus.OnDemand
|
WlrLayershell.keyboardFocus: WlrKeyboardFocus.OnDemand
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
wifiLogic.refreshNetworks()
|
wifiLogic.refreshNetworks();
|
||||||
}
|
}
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
@ -422,7 +443,9 @@ Item {
|
||||||
color: Theme.textPrimary
|
color: Theme.textPrimary
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
Item { Layout.fillWidth: true }
|
Item {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
Spinner {
|
Spinner {
|
||||||
id: refreshIndicator
|
id: refreshIndicator
|
||||||
Layout.preferredWidth: 24
|
Layout.preferredWidth: 24
|
||||||
|
|
@ -440,7 +463,9 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
implicitWidth: 36; implicitHeight: 36; radius: 18
|
implicitWidth: 36
|
||||||
|
implicitHeight: 36
|
||||||
|
radius: 18
|
||||||
color: closeButtonArea.containsMouse ? Theme.accentPrimary : "transparent"
|
color: closeButtonArea.containsMouse ? Theme.accentPrimary : "transparent"
|
||||||
border.color: Theme.accentPrimary
|
border.color: Theme.accentPrimary
|
||||||
border.width: 1
|
border.width: 1
|
||||||
|
|
@ -510,8 +535,7 @@ Item {
|
||||||
property var signalIcon: wifiPanel.signalIcon
|
property var signalIcon: wifiPanel.signalIcon
|
||||||
|
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: (modelData.ssid === wifiLogic.passwordPromptSsid && wifiLogic.showPasswordPrompt ? 102 : 42) +
|
height: (modelData.ssid === wifiLogic.passwordPromptSsid && wifiLogic.showPasswordPrompt ? 102 : 42) + (modelData.ssid === wifiLogic.actionPanelSsid ? 60 : 0)
|
||||||
(modelData.ssid === wifiLogic.actionPanelSsid ? 60 : 0)
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
@ -548,7 +572,8 @@ Item {
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
}
|
}
|
||||||
Item {
|
Item {
|
||||||
width: 22; height: 22
|
width: 22
|
||||||
|
height: 22
|
||||||
visible: wifiLogic.connectStatusSsid === modelData.ssid && wifiLogic.connectStatus !== ""
|
visible: wifiLogic.connectStatusSsid === modelData.ssid && wifiLogic.connectStatus !== ""
|
||||||
RowLayout {
|
RowLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
@ -680,7 +705,11 @@ Item {
|
||||||
border.color: Theme.accentPrimary
|
border.color: Theme.accentPrimary
|
||||||
border.width: 0
|
border.width: 0
|
||||||
opacity: 1.0
|
opacity: 1.0
|
||||||
Behavior on color { ColorAnimation { duration: 100 } }
|
Behavior on color {
|
||||||
|
ColorAnimation {
|
||||||
|
duration: 100
|
||||||
|
}
|
||||||
|
}
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: wifiLogic.submitPassword()
|
onClicked: wifiLogic.submitPassword()
|
||||||
|
|
@ -739,7 +768,11 @@ Item {
|
||||||
echoMode: TextInput.Password
|
echoMode: TextInput.Password
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
// Connect with the entered password
|
// Connect with the entered password
|
||||||
wifiLogic.pendingConnect = {ssid: modelData.ssid, security: modelData.security, password: text};
|
wifiLogic.pendingConnect = {
|
||||||
|
ssid: modelData.ssid,
|
||||||
|
security: modelData.security,
|
||||||
|
password: text
|
||||||
|
};
|
||||||
wifiLogic.doConnect();
|
wifiLogic.doConnect();
|
||||||
|
|
||||||
wifiLogic.actionPanelSsid = ""; // Close the panel
|
wifiLogic.actionPanelSsid = ""; // Close the panel
|
||||||
|
|
@ -756,7 +789,11 @@ Item {
|
||||||
border.color: modelData.connected ? Theme.error : Theme.accentPrimary
|
border.color: modelData.connected ? Theme.error : Theme.accentPrimary
|
||||||
border.width: 0
|
border.width: 0
|
||||||
opacity: 1.0
|
opacity: 1.0
|
||||||
Behavior on color { ColorAnimation { duration: 100 } }
|
Behavior on color {
|
||||||
|
ColorAnimation {
|
||||||
|
duration: 100
|
||||||
|
}
|
||||||
|
}
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
|
@ -768,7 +805,11 @@ Item {
|
||||||
if (wifiLogic.isSecured(modelData.security) && !modelData.existing) {
|
if (wifiLogic.isSecured(modelData.security) && !modelData.existing) {
|
||||||
// If password field is visible and has content, use it
|
// If password field is visible and has content, use it
|
||||||
if (actionPanelPasswordField.text.length > 0) {
|
if (actionPanelPasswordField.text.length > 0) {
|
||||||
wifiLogic.pendingConnect = {ssid: modelData.ssid, security: modelData.security, password: actionPanelPasswordField.text};
|
wifiLogic.pendingConnect = {
|
||||||
|
ssid: modelData.ssid,
|
||||||
|
security: modelData.security,
|
||||||
|
password: actionPanelPasswordField.text
|
||||||
|
};
|
||||||
wifiLogic.doConnect();
|
wifiLogic.doConnect();
|
||||||
}
|
}
|
||||||
// For new networks without password entered, we might want to show an error or handle differently
|
// For new networks without password entered, we might want to show an error or handle differently
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue