shift-shell/kcms/hotspot/ui/main.qml
Devin Lin bcc553325c kcms/hotspot: Change UX to use a dialog rather than direct textfields
Otherwise it's not obvious to the user whether the changes were saved.
2023-12-16 18:42:52 -08:00

122 lines
3.5 KiB
QML

// SPDX-FileCopyrightText: 2020 Tobias Fella <fella@posteo.de>
// SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
// SPDX-License-Identifier: LGPL-2.0-or-later
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls as Controls
import org.kde.plasma.networkmanagement as PlasmaNM
import org.kde.kirigami as Kirigami
import org.kde.kcmutils
import org.kde.kirigamiaddons.formcard as FormCard
SimpleKCM {
id: root
leftPadding: 0
rightPadding: 0
topPadding: 0
bottomPadding: 0
data: [
PlasmaNM.Handler {
id: handler
},
PlasmaNM.WirelessStatus {
id: wirelessStatus
},
Kirigami.PromptDialog {
id: hotspotDialog
title: i18n("Configure Hotspot")
standardButtons: Kirigami.PromptDialog.Save | Kirigami.PromptDialog.Cancel
onOpened: {
hotspotSsidField.text = PlasmaNM.Configuration.hotspotName;
hotspotPasswordField.text = PlasmaNM.Configuration.hotspotPassword;
}
onAccepted: {
PlasmaNM.Configuration.hotspotName = hotspotSsidField.text;
PlasmaNM.Configuration.hotspotPassword = hotspotPasswordField.text;
// these properties need to be manually updated since they're not NOTIFYable
hotspotSSIDText.description = PlasmaNM.Configuration.hotspotName;
hotspotPasswordText.description = PlasmaNM.Configuration.hotspotPassword;
}
ColumnLayout {
Controls.Label {
text: i18n('Hotspot SSID:')
}
Controls.TextField {
Layout.fillWidth: true
id: hotspotSsidField
}
Controls.Label {
text: i18n('Hotspot Password:')
}
Controls.TextField {
Layout.fillWidth: true
id: hotspotPasswordField
}
}
}
]
ColumnLayout {
spacing: 0
FormCard.FormCard {
Layout.topMargin: Kirigami.Units.gridUnit
FormCard.FormSwitchDelegate {
id: hotspotToggle
text: i18n("Hotspot")
description: i18n("Share your internet connection with other devices as a Wi-Fi network.");
checked: wirelessStatus.hotspotSSID.length !== 0
onToggled: {
if (hotspotToggle.checked) {
handler.createHotspot();
} else {
handler.stopHotspot();
}
}
}
}
FormCard.FormHeader {
title: i18n("Settings")
}
FormCard.FormCard {
Layout.topMargin: Kirigami.Units.largeSpacing
Layout.bottomMargin: Kirigami.Units.largeSpacing
FormCard.FormTextDelegate {
id: hotspotSSIDText
text: i18n("Hotspot SSID")
description: PlasmaNM.Configuration.hotspotName
}
FormCard.FormDelegateSeparator {}
FormCard.FormTextDelegate {
id: hotspotPasswordText
text: i18n("Hotspot Password")
description: PlasmaNM.Configuration.hotspotPassword
}
FormCard.FormDelegateSeparator {}
FormCard.FormButtonDelegate {
text: i18n('Configure')
onClicked: hotspotDialog.open()
}
}
}
}