kcms/hotspot: Port to mobileform components

This commit is contained in:
Devin Lin 2023-03-14 22:08:01 -07:00
parent 56d530f855
commit fa2f34ca41

View file

@ -1,17 +1,27 @@
/* // SPDX-FileCopyrightText: 2020 Tobias Fella <fella@posteo.de>
SPDX-FileCopyrightText: 2020 Tobias Fella <fella@posteo.de> // SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
// SPDX-License-Identifier: LGPL-2.0-or-later
SPDX-License-Identifier: LGPL-2.0-or-later import QtQuick
*/ import QtQuick.Layouts
import QtQuick.Controls as Controls
import QtQuick 2.6 import org.kde.plasma.networkmanagement as PlasmaNM
import QtQuick.Layouts 1.2 import org.kde.kirigami as Kirigami
import QtQuick.Controls 2.2 as Controls import org.kde.kcm
import org.kde.plasma.networkmanagement 0.2 as PlasmaNM import org.kde.kirigamiaddons.labs.mobileform as MobileForm
import org.kde.kirigami 2.10 as Kirigami
import org.kde.kcm 1.2
SimpleKCM { SimpleKCM {
id: root
leftPadding: 0
rightPadding: 0
topPadding: Kirigami.Units.gridUnit
bottomPadding: Kirigami.Units.gridUnit
ColumnLayout {
spacing: 0
width: root.width
PlasmaNM.Handler { PlasmaNM.Handler {
id: handler id: handler
@ -21,11 +31,19 @@ SimpleKCM {
id: wirelessStatus id: wirelessStatus
} }
Kirigami.FormLayout { MobileForm.FormCard {
Controls.Switch { Layout.fillWidth: true
contentItem: ColumnLayout {
spacing: 0
MobileForm.FormSwitchDelegate {
id: hotspotToggle id: hotspotToggle
Kirigami.FormData.label: i18n("Enabled:") text: i18n("Hotspot")
description: i18n("Whether the wireless hotspot is enabled.");
checked: wirelessStatus.hotspotSSID.length !== 0 checked: wirelessStatus.hotspotSSID.length !== 0
onToggled: { onToggled: {
if (hotspotToggle.checked) { if (hotspotToggle.checked) {
handler.createHotspot(); handler.createHotspot();
@ -34,27 +52,31 @@ SimpleKCM {
} }
} }
} }
}
}
Controls.TextField { MobileForm.FormCard {
id: hotspotName Layout.fillWidth: true
Kirigami.FormData.label: i18n("SSID:") Layout.topMargin: Kirigami.Units.largeSpacing
contentItem: ColumnLayout {
spacing: 0
MobileForm.FormTextFieldDelegate {
label: i18n("Hotspot SSID")
enabled: !hotspotToggle.checked
text: PlasmaNM.Configuration.hotspotName text: PlasmaNM.Configuration.hotspotName
onTextChanged: PlasmaNM.Configuration.hotspotName = text
} }
Kirigami.PasswordField { MobileForm.FormDelegateSeparator {}
id: hotspotPassword
Kirigami.FormData.label: i18n("Password:") MobileForm.FormTextFieldDelegate {
label: i18n("Hotspot Password")
enabled: !hotspotToggle.checked
echoMode: MobileForm.FormTextFieldDelegate.Password
text: PlasmaNM.Configuration.hotspotPassword text: PlasmaNM.Configuration.hotspotPassword
} onTextChanged: PlasmaNM.Configuration.hotspotPassword = text
Controls.Button {
text: i18n("Save")
onClicked: {
PlasmaNM.Configuration.hotspotName = hotspotName.text
PlasmaNM.Configuration.hotspotPassword = hotspotPassword.text
if (hotspotToggle.checked) {
handler.stopHotspot()
handler.createHotspot()
} }
} }
} }