Warning, /plasma/plasma-nm/kcm/qml/ConfigurationDialog.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2019 Jan Grulich <jgrulich@redhat.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 import QtQuick 2.15
0008 import QtQuick.Dialogs 1.2
0009 import QtQuick.Controls 2.5 as QQC2
0010 import org.kde.kirigami 2.5 as Kirigami
0011 import org.kde.plasma.networkmanagement 0.2 as PlasmaNM
0012 
0013 Dialog {
0014     id: configurationDialog
0015     standardButtons: Dialog.Ok | Dialog.Cancel
0016     title: i18nc("@title:window", "Configuration")
0017 
0018     contentItem: Item {
0019         implicitHeight: 230
0020         implicitWidth: 400
0021 
0022         Rectangle {
0023             id: background
0024             anchors.fill: parent
0025             focus: true
0026             color: Kirigami.Theme.backgroundColor
0027         }
0028 
0029         Kirigami.FormLayout {
0030             anchors.left: parent.left
0031             anchors.right: parent.right
0032             anchors.topMargin: Kirigami.Units.gridUnit
0033 
0034             Kirigami.Heading {
0035                 id: generalLabel
0036                 level: 2
0037                 text: i18n("General")
0038             }
0039 
0040             QQC2.CheckBox {
0041                 id: unlockModem
0042                 text: i18n("Ask for PIN on modem detection")
0043                 onClicked: configurationChanged()
0044                 Component.onCompleted: checked = PlasmaNM.Configuration.unlockModemOnDetection
0045             }
0046 
0047             QQC2.CheckBox {
0048                 id: manageVirtualConnections
0049                 text: i18n("Show virtual connections")
0050                 onClicked: configurationChanged()
0051                 Component.onCompleted: checked = PlasmaNM.Configuration.manageVirtualConnections
0052             }
0053 
0054             Kirigami.Heading {
0055                 id: hotspotLabel
0056                 level: 2
0057                 text: i18n("Hotspot")
0058                 Component.onCompleted: visible = handler.hotspotSupported
0059             }
0060 
0061             QQC2.TextField {
0062                 id: hotspotName
0063                 Kirigami.FormData.label: i18n("Hotspot name:")
0064                 onTextChanged: configurationChanged()
0065                 Component.onCompleted: {
0066                     text = PlasmaNM.Configuration.hotspotName
0067                     visible = handler.hotspotSupported
0068                 }
0069             }
0070 
0071             QQC2.TextField {
0072                 id: hotspotPassword
0073                 Kirigami.FormData.label: i18n("Hotspot password:")
0074                 validator: RegularExpressionValidator {
0075                     regularExpression: useApMode
0076                         ? /^$|^(?:.{8,64}){1}$/
0077                         : /^$|^(?:.{5}|[0-9a-fA-F]{10}|.{13}|[0-9a-fA-F]{26}){1}$/
0078                 }
0079 
0080                 onAcceptableInputChanged: configurationChanged()
0081 
0082                 Component.onCompleted: {
0083                     text = PlasmaNM.Configuration.hotspotPassword
0084                     visible = handler.hotspotSupported
0085                 }
0086             }
0087         }
0088 
0089         Row {
0090             id: buttonRow
0091             anchors {
0092                 bottom: parent.bottom
0093                 right: parent.right
0094                 margins: Kirigami.Units.smallSpacing
0095             }
0096             spacing: Kirigami.Units.mediumSpacing
0097 
0098             QQC2.Button {
0099                 id: okButton
0100                 icon.name: "dialog-ok"
0101                 enabled: false
0102                 text: i18n("OK")
0103 
0104                 onClicked: {
0105                     configurationDialog.accept()
0106                 }
0107             }
0108 
0109             QQC2.Button {
0110                 id: cancelButton
0111                 icon.name: "dialog-cancel"
0112                 text: i18n("Cancel")
0113 
0114                 onClicked: {
0115                     configurationDialog.close()
0116                 }
0117             }
0118         }
0119     }
0120 
0121     function configurationChanged() {
0122         if (handler.hotspotSupported) {
0123             okButton.enabled = hotspotPassword.acceptableInput && hotspotName.text
0124         } else {
0125             okButton.enabled = true
0126         }
0127     }
0128 
0129     onVisibleChanged: {
0130         if (visible) {
0131             unlockModem.checked = PlasmaNM.Configuration.unlockModemOnDetection
0132             manageVirtualConnections.checked = PlasmaNM.Configuration.manageVirtualConnections
0133             hotspotName.text = PlasmaNM.Configuration.hotspotName
0134             hotspotPassword.text = PlasmaNM.Configuration.hotspotPassword
0135         }
0136     }
0137 
0138     onAccepted: {
0139         PlasmaNM.Configuration.unlockModemOnDetection = unlockModem.checked
0140         PlasmaNM.Configuration.manageVirtualConnections = manageVirtualConnections.checked
0141         PlasmaNM.Configuration.hotspotName = hotspotName.text
0142         PlasmaNM.Configuration.hotspotPassword = hotspotPassword.text
0143     }
0144 }
0145