Warning, /plasma/plasma-mobile/kcms/hotspot/ui/main.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2020 Tobias Fella <fella@posteo.de>
0002 // SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
0003 // SPDX-License-Identifier: LGPL-2.0-or-later
0004 
0005 import QtQuick
0006 import QtQuick.Layouts
0007 import QtQuick.Controls as Controls
0008 
0009 import org.kde.plasma.networkmanagement as PlasmaNM
0010 import org.kde.kirigami as Kirigami
0011 import org.kde.kcmutils
0012 import org.kde.kirigamiaddons.formcard as FormCard
0013 
0014 SimpleKCM {
0015     id: root
0016 
0017     leftPadding: 0
0018     rightPadding: 0
0019     topPadding: 0
0020     bottomPadding: 0
0021 
0022     data: [
0023         PlasmaNM.Handler {
0024             id: handler
0025         },
0026 
0027         PlasmaNM.WirelessStatus {
0028             id: wirelessStatus
0029         },
0030 
0031         Kirigami.PromptDialog {
0032             id: hotspotDialog
0033             title: i18n("Configure Hotspot")
0034             standardButtons: Kirigami.PromptDialog.Save | Kirigami.PromptDialog.Cancel
0035 
0036             onOpened: {
0037                 hotspotSsidField.text = PlasmaNM.Configuration.hotspotName;
0038                 hotspotPasswordField.text = PlasmaNM.Configuration.hotspotPassword;
0039             }
0040 
0041             onAccepted: {
0042                 PlasmaNM.Configuration.hotspotName = hotspotSsidField.text;
0043                 PlasmaNM.Configuration.hotspotPassword = hotspotPasswordField.text;
0044 
0045                 // these properties need to be manually updated since they're not NOTIFYable
0046                 hotspotSSIDText.description = PlasmaNM.Configuration.hotspotName;
0047                 hotspotPasswordText.description = PlasmaNM.Configuration.hotspotPassword;
0048             }
0049 
0050             ColumnLayout {
0051                 Controls.Label {
0052                     text: i18n('Hotspot SSID:')
0053                 }
0054                 Controls.TextField {
0055                     Layout.fillWidth: true
0056                     id: hotspotSsidField
0057                 }
0058                 Controls.Label {
0059                     text: i18n('Hotspot Password:')
0060                 }
0061                 Controls.TextField {
0062                     Layout.fillWidth: true
0063                     id: hotspotPasswordField
0064                 }
0065             }
0066         }
0067     ]
0068 
0069     ColumnLayout {
0070         spacing: 0
0071 
0072         FormCard.FormCard {
0073             Layout.topMargin: Kirigami.Units.gridUnit
0074 
0075             FormCard.FormSwitchDelegate {
0076                 id: hotspotToggle
0077                 text: i18n("Hotspot")
0078                 description: i18n("Share your internet connection with other devices as a Wi-Fi network.");
0079 
0080                 checked: wirelessStatus.hotspotSSID.length !== 0
0081 
0082                 onToggled: {
0083                     if (hotspotToggle.checked) {
0084                         handler.createHotspot();
0085                     } else {
0086                         handler.stopHotspot();
0087                     }
0088                 }
0089             }
0090         }
0091 
0092         FormCard.FormHeader {
0093             title: i18n("Settings")
0094         }
0095 
0096         FormCard.FormCard {
0097             Layout.topMargin: Kirigami.Units.largeSpacing
0098             Layout.bottomMargin: Kirigami.Units.largeSpacing
0099 
0100             FormCard.FormTextDelegate {
0101                 id: hotspotSSIDText
0102                 enabled: !hotspotToggle.checked
0103                 text: i18n("Hotspot SSID")
0104                 description: PlasmaNM.Configuration.hotspotName
0105             }
0106 
0107             FormCard.FormDelegateSeparator {}
0108 
0109             FormCard.FormTextDelegate {
0110                 id: hotspotPasswordText
0111                 enabled: !hotspotToggle.checked
0112                 text: i18n("Hotspot Password")
0113                 description: PlasmaNM.Configuration.hotspotPassword
0114             }
0115 
0116             FormCard.FormDelegateSeparator {}
0117 
0118             FormCard.FormButtonDelegate {
0119                 enabled: !hotspotToggle.checked
0120                 text: i18n('Configure')
0121                 onClicked: hotspotDialog.open()
0122             }
0123         }
0124     }
0125 }