nosignal-shell/modules/controlcenter/network/Details.qml
ATMDA d8de7c7e4b controlcenter: wifi passphrase input
fix: dependability issues with nmcli
2025-11-09 21:43:51 -05:00

224 lines
7.7 KiB
QML

pragma ComponentBehavior: Bound
import ".."
import qs.components
import qs.components.controls
import qs.components.effects
import qs.components.containers
import qs.services
import qs.config
import QtQuick
import QtQuick.Layouts
Item {
id: root
required property Session session
readonly property var network: session.network.active
StyledFlickable {
anchors.fill: parent
flickableDirection: Flickable.VerticalFlick
contentHeight: layout.height
ColumnLayout {
id: layout
anchors.left: parent.left
anchors.right: parent.right
spacing: Appearance.spacing.normal
MaterialIcon {
Layout.alignment: Qt.AlignHCenter
animate: true
text: root.network?.isSecure ? "lock" : "wifi"
font.pointSize: Appearance.font.size.extraLarge * 3
font.bold: true
}
StyledText {
Layout.alignment: Qt.AlignHCenter
animate: true
text: root.network?.ssid ?? qsTr("Unknown")
font.pointSize: Appearance.font.size.large
font.bold: true
}
StyledText {
Layout.topMargin: Appearance.spacing.large
text: qsTr("Connection status")
font.pointSize: Appearance.font.size.larger
font.weight: 500
}
StyledText {
text: qsTr("Connection settings for this network")
color: Colours.palette.m3outline
}
StyledRect {
Layout.fillWidth: true
implicitHeight: networkStatus.implicitHeight + Appearance.padding.large * 2
radius: Appearance.rounding.normal
color: Colours.tPalette.m3surfaceContainer
ColumnLayout {
id: networkStatus
anchors.left: parent.left
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.margins: Appearance.padding.large
spacing: Appearance.spacing.larger
Toggle {
label: qsTr("Connected")
checked: root.network?.active ?? false
toggle.onToggled: {
if (checked) {
// If already connected to a different network, disconnect first
if (Network.active && Network.active.ssid !== root.network.ssid) {
Network.disconnectFromNetwork();
// Wait a moment before connecting to new network
Qt.callLater(() => {
connectToNetwork();
});
} else {
connectToNetwork();
}
} else {
Network.disconnectFromNetwork();
}
}
function connectToNetwork(): void {
if (root.network.isSecure) {
// Try connecting without password first (in case it's saved)
Network.connectToNetworkWithPasswordCheck(
root.network.ssid,
root.network.isSecure,
() => {
// Callback: connection failed, show password dialog
root.session.network.showPasswordDialog = true;
root.session.network.pendingNetwork = root.network;
}
);
} else {
Network.connectToNetwork(root.network.ssid, "");
}
}
}
}
}
StyledText {
Layout.topMargin: Appearance.spacing.large
text: qsTr("Network properties")
font.pointSize: Appearance.font.size.larger
font.weight: 500
}
StyledText {
text: qsTr("Additional information")
color: Colours.palette.m3outline
}
StyledRect {
Layout.fillWidth: true
implicitHeight: networkProps.implicitHeight + Appearance.padding.large * 2
radius: Appearance.rounding.normal
color: Colours.tPalette.m3surfaceContainer
ColumnLayout {
id: networkProps
anchors.left: parent.left
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.margins: Appearance.padding.large
spacing: Appearance.spacing.small / 2
StyledText {
text: qsTr("SSID")
}
StyledText {
text: root.network?.ssid ?? qsTr("Unknown")
color: Colours.palette.m3outline
font.pointSize: Appearance.font.size.small
}
StyledText {
Layout.topMargin: Appearance.spacing.normal
text: qsTr("BSSID")
}
StyledText {
text: root.network?.bssid ?? qsTr("Unknown")
color: Colours.palette.m3outline
font.pointSize: Appearance.font.size.small
}
StyledText {
Layout.topMargin: Appearance.spacing.normal
text: qsTr("Signal strength")
}
StyledText {
text: root.network ? qsTr("%1%").arg(root.network.strength) : qsTr("N/A")
color: Colours.palette.m3outline
font.pointSize: Appearance.font.size.small
}
StyledText {
Layout.topMargin: Appearance.spacing.normal
text: qsTr("Frequency")
}
StyledText {
text: root.network ? qsTr("%1 MHz").arg(root.network.frequency) : qsTr("N/A")
color: Colours.palette.m3outline
font.pointSize: Appearance.font.size.small
}
StyledText {
Layout.topMargin: Appearance.spacing.normal
text: qsTr("Security")
}
StyledText {
text: root.network ? (root.network.isSecure ? root.network.security : qsTr("Open")) : qsTr("N/A")
color: Colours.palette.m3outline
font.pointSize: Appearance.font.size.small
}
}
}
}
}
component Toggle: RowLayout {
required property string label
property alias checked: toggle.checked
property alias toggle: toggle
Layout.fillWidth: true
spacing: Appearance.spacing.normal
StyledText {
Layout.fillWidth: true
text: parent.label
}
StyledSwitch {
id: toggle
cLayer: 2
}
}
}