Files
illogical-impulse/.config/quickshell/ii/modules/sidebarRight/wifiNetworks/WifiNetworkItem.qml
T

113 lines
3.6 KiB
QML

import qs
import qs.modules.common
import qs.modules.common.functions
import qs.modules.common.widgets
import qs.services
import qs.services.network
import QtQuick
import QtQuick.Layouts
import Quickshell
RippleButton {
id: root
required property WifiAccessPoint wifiNetwork
horizontalPadding: Appearance.rounding.large
verticalPadding: 12
implicitWidth: mainLayout.implicitWidth + horizontalPadding * 2
implicitHeight: mainLayout.implicitHeight + verticalPadding * 2
Behavior on implicitHeight {
animation: Appearance.animation.elementMove.numberAnimation.createObject(this)
}
clip: true
buttonRadius: 0
colBackground: ColorUtils.transparentize(Appearance.colors.colLayer3)
colBackgroundHover: wifiNetwork?.askingPassword ? colBackground : Appearance.colors.colLayer3Hover
colRipple: Appearance.colors.colLayer3Active
onClicked: {
Network.connectToWifiNetwork(wifiNetwork)
}
contentItem: ColumnLayout {
id: mainLayout
anchors {
fill: parent
topMargin: root.verticalPadding
bottomMargin: root.verticalPadding
leftMargin: root.horizontalPadding
rightMargin: root.horizontalPadding
}
spacing: 0
RowLayout {
spacing: 10
MaterialSymbol {
iconSize: Appearance.font.pixelSize.larger
property int strength: root.wifiNetwork?.strength ?? 0
text: strength > 80 ? "signal_wifi_4_bar" :
strength > 60 ? "network_wifi_3_bar" :
strength > 40 ? "network_wifi_2_bar" :
strength > 20 ? "network_wifi_1_bar" :
"signal_wifi_0_bar"
color: Appearance.colors.colOnSurfaceVariant
}
StyledText {
Layout.fillWidth: true
text: root.wifiNetwork?.ssid ?? Translation.tr("Unknown")
color: Appearance.colors.colOnSurfaceVariant
}
MaterialSymbol {
visible: (root.wifiNetwork?.isSecure || root.wifiNetwork?.active) ?? false
text: root.wifiNetwork?.active ? "check" : Network.wifiConnectTarget === root.wifiNetwork ? "settings_ethernet" : "lock"
iconSize: Appearance.font.pixelSize.larger
color: Appearance.colors.colOnSurfaceVariant
}
}
ColumnLayout {
id: passwordPrompt
visible: root.wifiNetwork?.askingPassword ?? false
Layout.topMargin: 12
MaterialTextField {
id: passwordField
Layout.fillWidth: true
placeholderText: Translation.tr("Password")
// Password
echoMode: TextInput.Password
inputMethodHints: Qt.ImhSensitiveData
onAccepted: {
Network.changePassword(root.wifiNetwork, passwordField.text)
}
}
RowLayout {
Layout.fillWidth: true
Item {
Layout.fillWidth: true
}
DialogButton {
buttonText: Translation.tr("Cancel")
onClicked: {
root.wifiNetwork.askingPassword = false
}
}
DialogButton {
buttonText: Translation.tr("Connect")
onClicked: {
Network.changePassword(root.wifiNetwork, passwordField.text)
}
}
}
}
}
}