C++ / fmt (pull_request) Successful in 4s
JS/TS / fmt (pull_request) Successful in 11s
JS/TS / lint (pull_request) Successful in 24s
Python / fmt (pull_request) Successful in 30s
Python / lint (pull_request) Successful in 34s
Python / test (pull_request) Successful in 53s
C++ / build (pull_request) Successful in 1m52s
Rust / fmt (pull_request) Successful in 1m14s
Rust / build (pull_request) Successful in 1m57s
Rust / clippy (pull_request) Successful in 2m0s
Python / buildcheck (pull_request) Successful in 2m37s
C++ / clang-tidy (pull_request) Successful in 3m43s
115 lines
2.5 KiB
QML
115 lines
2.5 KiB
QML
pragma Singleton
|
|
|
|
import Quickshell
|
|
import Quickshell.Networking
|
|
import QtQuick
|
|
|
|
Singleton {
|
|
id: root
|
|
|
|
property bool active: false
|
|
readonly property list<Network> connectedNetworks: networks.filter(n => n.connected)
|
|
property Network connectingNetwork
|
|
readonly property list<NetworkDevice> devices: Networking.devices.values
|
|
property Network failedNetwork
|
|
readonly property list<Network> knownNetworks: networks.filter(n => n.known && !n.connected)
|
|
readonly property list<Network> networks: {
|
|
const list = [];
|
|
for (const d of wifiDevices) {
|
|
for (const n of d.networks.values) {
|
|
if (!list.includes(n))
|
|
list.push(n);
|
|
}
|
|
}
|
|
return list;
|
|
}
|
|
property bool scanning: false
|
|
readonly property list<Network> unknownNetworks: networks.filter(n => !n.known)
|
|
readonly property list<WifiDevice> wifiDevices: devices.filter(d => wifiDevice(d))
|
|
readonly property bool wifiEnabled: Networking.wifiEnabled
|
|
|
|
signal networkConnected
|
|
|
|
function isSecure(security): bool {
|
|
return (security === WifiSecurityType.WpaPsk || security === WifiSecurityType.Wpa2Psk || security === WifiSecurityType.Sae);
|
|
}
|
|
|
|
function requestConnect(network: Network, secret = undefined): void {
|
|
connectingNetwork = network;
|
|
if (secret === undefined || secret === "") {
|
|
network.connect();
|
|
} else {
|
|
(network as WifiNetwork).connectWithPsk(secret);
|
|
}
|
|
}
|
|
|
|
function setScan(value: bool): void {
|
|
for (const d of wifiDevices) {
|
|
d.scannerEnabled = value;
|
|
}
|
|
}
|
|
|
|
function setWifi(value: bool): void {
|
|
Networking.wifiEnabled = value;
|
|
}
|
|
|
|
function wifiDevice(dev): bool {
|
|
return dev.type === DeviceType.Wifi;
|
|
}
|
|
|
|
onActiveChanged: {
|
|
for (const d of wifiDevices)
|
|
d.scannerEnabled = active;
|
|
}
|
|
|
|
Timer {
|
|
id: flushFailed
|
|
|
|
interval: 5000
|
|
running: root.failedNetwork
|
|
|
|
onTriggered: {
|
|
root.failedNetwork = null;
|
|
}
|
|
}
|
|
|
|
Timer {
|
|
id: checkConnection
|
|
|
|
interval: 500
|
|
repeat: true
|
|
running: root.connectingNetwork
|
|
|
|
onTriggered: {
|
|
var completedNetwork;
|
|
|
|
switch (root.connectingNetwork.state) {
|
|
case ConnectionState.Connecting:
|
|
break;
|
|
case ConnectionState.Connected:
|
|
completedNetwork = root.connectingNetwork;
|
|
root.networkConnected();
|
|
break;
|
|
case ConnectionState.Disconnected:
|
|
root.failedNetwork = root.connectingNetwork;
|
|
completedNetwork = root.connectingNetwork;
|
|
break;
|
|
}
|
|
|
|
if (completedNetwork) {
|
|
root.connectingNetwork = null;
|
|
}
|
|
}
|
|
}
|
|
|
|
Timer {
|
|
interval: 10000
|
|
running: checkConnection.running
|
|
|
|
onTriggered: {
|
|
root.failedNetwork = root.connectingNetwork;
|
|
root.connectingNetwork = null;
|
|
}
|
|
}
|
|
}
|