added adaptive quickshell
This commit is contained in:
1 parent
6eb56d2065
commit
5b33a73fd8
189 files changed
+8678
-15
No files matched your search
@@ -0,0 +1,68 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import Quickshell.Networking
|
||||
import "../services"
|
||||
|
||||
ColumnLayout {
|
||||
id: card
|
||||
required property var network
|
||||
required property var device
|
||||
required property var controller
|
||||
property bool active: false
|
||||
property bool credentials: false
|
||||
readonly property bool wifi: device?.type === DeviceType.Wifi
|
||||
readonly property bool pskSupported: wifi && [WifiSecurityType.WpaPsk, WifiSecurityType.Wpa2Psk, WifiSecurityType.Sae].includes(network?.security)
|
||||
readonly property bool directConnect: !wifi || network?.known === true || pskSupported || [WifiSecurityType.Open, WifiSecurityType.Owe].includes(network?.security)
|
||||
signal editRequested()
|
||||
function clearSecret() { if (password) password.clear(); credentials = false; }
|
||||
onActiveChanged: if (!active) clearSecret()
|
||||
Connections {
|
||||
target: card.controller
|
||||
function onNeedsSecret(network) { if (network === card.network && card.pskSupported && card.active) card.credentials = true; }
|
||||
}
|
||||
Connections {
|
||||
target: card.network
|
||||
function onConnectedChanged() { if (card.network?.connected) card.clearSecret(); }
|
||||
}
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
text: (card.network?.name || "") + (card.network?.connected ? " · Подключено" : "") + (card.wifi ? " · " + Math.round(card.network?.signalStrength * 100) + "%" : "")
|
||||
wrapMode: Text.Wrap; color: Theme.foreground; textFormat: Text.PlainText
|
||||
}
|
||||
Label { visible: card.wifi && !!card.network; text: card.wifi && card.network ? WifiSecurityType.toString(card.network.security) : ""; color: Theme.outline }
|
||||
ActionButton {
|
||||
visible: !!card.network && !card.network.connected
|
||||
text: card.directConnect ? "Подключиться" : "Настроить подключение…"
|
||||
enabled: card.controller?.busy === false && card.device?.nmManaged === true
|
||||
onClicked: {
|
||||
if (!card.directConnect) card.editRequested();
|
||||
else if (!card.network?.known && card.pskSupported) card.credentials = true;
|
||||
else card.controller.requestConnect(card.network);
|
||||
}
|
||||
}
|
||||
TextField {
|
||||
id: password
|
||||
objectName: "networkPassword"
|
||||
visible: card.credentials
|
||||
Layout.fillWidth: true
|
||||
placeholderText: "Пароль Wi-Fi"
|
||||
echoMode: TextInput.Password
|
||||
inputMethodHints: Qt.ImhSensitiveData | Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase
|
||||
selectByMouse: false
|
||||
onAccepted: if (text.length && card.controller?.busy === false) {
|
||||
card.controller.requestConnect(card.network, text);
|
||||
clear(); card.credentials = false;
|
||||
}
|
||||
}
|
||||
RowLayout {
|
||||
visible: card.credentials
|
||||
ActionButton {
|
||||
text: "Подключить"
|
||||
enabled: password.text.length > 0 && card.controller?.busy === false
|
||||
onClicked: { card.controller.requestConnect(card.network, password.text); card.clearSecret(); }
|
||||
}
|
||||
ActionButton { text: "Отмена"; onClicked: card.clearSecret() }
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user