qs: wifi pwd
This commit is contained in:
parent
dc2712c66b
commit
b3e9b4e6be
5 changed files with 56 additions and 10 deletions
|
|
@ -29,6 +29,7 @@ PanelWindow {
|
|||
color: "transparent"
|
||||
|
||||
WlrLayershell.namespace: "shell:bar"
|
||||
focusable: tooltip.activeItem != null
|
||||
|
||||
readonly property Tooltip tooltip: tooltip;
|
||||
Tooltip {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import qs.bar
|
|||
ClickableIcon {
|
||||
id: root
|
||||
required property var bar;
|
||||
readonly property NetworkDevice adapter: Networking.devices.values[0]
|
||||
readonly property WifiDevice adapter: Networking.devices.values[0] ?? null
|
||||
readonly property bool connected: adapter.connected
|
||||
readonly property WifiNetwork activeNetwork: adapter.networks.values.find(network => network.connected)
|
||||
|
||||
|
|
@ -124,6 +124,7 @@ ClickableIcon {
|
|||
device: root.adapter
|
||||
network: modelData
|
||||
width: parent.width
|
||||
onConnectionAttempted: root.adapter.scannerEnabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,17 +12,45 @@ WrapperMouseArea {
|
|||
required property NetworkDevice device
|
||||
required property WifiNetwork network
|
||||
property bool menuOpen: false
|
||||
readonly property bool showBg: false
|
||||
property bool passwordRequired: false
|
||||
readonly property bool showBg: root.passwordRequired
|
||||
hoverEnabled: true
|
||||
|
||||
signal connectionAttempted();
|
||||
|
||||
function tryConnect() {
|
||||
const connecting = root.network.connected || root.network.state == ConnectionState.Connecting;
|
||||
if (connecting) root.device.disconnect();
|
||||
else {
|
||||
root.connectionAttempted();
|
||||
if (pwField.text != "") root.network.connectWithPsk(pwField.text);
|
||||
else root.network.connect();
|
||||
}
|
||||
}
|
||||
|
||||
onClicked: menuOpen = !menuOpen
|
||||
|
||||
Connections {
|
||||
target: root.network
|
||||
function onConnectionFailed(reason) {
|
||||
console.log(reason, reason == ConnectionFailReason.NoSecrets);
|
||||
pwField.text = "";
|
||||
root.passwordRequired = reason == ConnectionFailReason.NoSecrets;
|
||||
}
|
||||
|
||||
function onStateChanged() {
|
||||
if (root.network.state == ConnectionState.Connected) {
|
||||
root.passwordRequired = false;
|
||||
pwField.text = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WrapperRectangle {
|
||||
color: root.showBg ? ShellGlobals.colors.widget : "transparent"
|
||||
color: root.showBg ? ShellGlobals.colors.widget : "transparent"
|
||||
border.width: 1
|
||||
border.color: root.showBg ? ShellGlobals.colors.widgetOutline : "transparent"
|
||||
radius: 4
|
||||
rightMargin: 2
|
||||
|
||||
ColumnLayout {
|
||||
RowLayout {
|
||||
|
|
@ -43,11 +71,7 @@ WrapperMouseArea {
|
|||
implicitHeight: 24
|
||||
implicitWidth: height
|
||||
showAction: root.network.stateChanging
|
||||
onClicked: {
|
||||
if (showAction) return;
|
||||
else if (root.network.connected) root.device.disconnect();
|
||||
else root.network.connect();
|
||||
}
|
||||
onClicked: tryConnect()
|
||||
}
|
||||
|
||||
ClickableIcon {
|
||||
|
|
@ -56,6 +80,25 @@ WrapperMouseArea {
|
|||
implicitWidth: height
|
||||
visible: root.network.known
|
||||
onClicked: root.network.forget()
|
||||
Layout.rightMargin: 2
|
||||
}
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: pwField
|
||||
visible: root.passwordRequired
|
||||
Layout.fillWidth: true
|
||||
Layout.margins: 4
|
||||
placeholderText: "Password"
|
||||
echoMode: TextInput.Password
|
||||
enabled: !(root.network.stateChanging || root.network.connected)
|
||||
onAccepted: tryConnect()
|
||||
|
||||
background: Rectangle {
|
||||
//color: "transparent" // ShellGlobals.colors.widget
|
||||
color: pwField.enabled ? "transparent" : ShellGlobals.colors.widgetActive
|
||||
border.color: ShellGlobals.colors.widgetOutline
|
||||
radius: 4
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue