Changeset View
Changeset View
Standalone View
Standalone View
kcm/qml/ConfigurationDialog.qml
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | Copyright 2019 Jan Grulich <jgrulich@redhat.com> | ||||
3 | | ||||
4 | This library is free software; you can redistribute it and/or | ||||
5 | modify it under the terms of the GNU Lesser General Public | ||||
6 | License as published by the Free Software Foundation; either | ||||
7 | version 2.1 of the License, or (at your option) version 3, or any | ||||
8 | later version accepted by the membership of KDE e.V. (or its | ||||
9 | successor approved by the membership of KDE e.V.), which shall | ||||
10 | act as a proxy defined in Section 6 of version 3 of the license. | ||||
11 | | ||||
12 | This library is distributed in the hope that it will be useful, | ||||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
15 | Lesser General Public License for more details. | ||||
16 | | ||||
17 | You should have received a copy of the GNU Lesser General Public | ||||
18 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | */ | ||||
20 | | ||||
21 | import QtQuick 2.5 | ||||
22 | import QtQuick.Dialogs 1.2 | ||||
23 | import QtQuick.Controls 2.5 as QQC2 | ||||
24 | import org.kde.kirigami 2.5 as Kirigami | ||||
25 | import org.kde.plasma.networkmanagement 0.2 as PlasmaNM | ||||
26 | | ||||
27 | Dialog { | ||||
28 | id: configurationDialog | ||||
29 | standardButtons: Dialog.Ok | Dialog.Cancel | ||||
30 | title: i18nc("@title:window", "Configuration") | ||||
31 | | ||||
32 | PlasmaNM.Configuration { | ||||
33 | id: configuration | ||||
34 | } | ||||
35 | | ||||
36 | contentItem: Item { | ||||
37 | implicitHeight: 200 | ||||
38 | implicitWidth: 400 | ||||
39 | | ||||
40 | Rectangle { | ||||
41 | id: background | ||||
42 | anchors.fill: parent | ||||
43 | focus: true | ||||
44 | color: baseColor | ||||
45 | } | ||||
46 | | ||||
47 | Kirigami.FormLayout { | ||||
48 | anchors.left: parent.left | ||||
49 | anchors.right: parent.right | ||||
50 | anchors.topMargin: units.gridUnit | ||||
51 | | ||||
52 | Kirigami.Heading { | ||||
53 | id: generalLabel | ||||
54 | level: 2 | ||||
55 | text: i18n("General") | ||||
56 | } | ||||
57 | | ||||
58 | QQC2.CheckBox { | ||||
59 | id: unlockModem | ||||
60 | text: i18n("Ask for PIN on modem detection") | ||||
61 | onClicked: configurationChanged() | ||||
62 | Component.onCompleted: checked = configuration.unlockModemOnDetection | ||||
63 | } | ||||
64 | | ||||
65 | QQC2.CheckBox { | ||||
66 | id: manageVirtualConnections | ||||
67 | text: i18n("Show virtual connections") | ||||
68 | onClicked: configurationChanged() | ||||
69 | Component.onCompleted: checked = configuration.manageVirtualConnections | ||||
70 | } | ||||
71 | | ||||
72 | Kirigami.Heading { | ||||
73 | id: hotspotLabel | ||||
74 | level: 2 | ||||
75 | text: i18n("Hotspot") | ||||
76 | Component.onCompleted: visible = handler.hotspotSupported | ||||
77 | } | ||||
78 | | ||||
79 | QQC2.TextField { | ||||
80 | id: hotspotName | ||||
81 | Kirigami.FormData.label: i18n("Hotspot name:") | ||||
82 | onTextChanged: configurationChanged() | ||||
83 | Component.onCompleted: { | ||||
84 | text = configuration.hotspotName | ||||
85 | visible = handler.hotspotSupported | ||||
86 | } | ||||
87 | } | ||||
88 | | ||||
89 | QQC2.TextField { | ||||
90 | id: hotspotPassword | ||||
91 | Kirigami.FormData.label: i18n("Hotspot password:") | ||||
92 | validator: RegExpValidator { | ||||
93 | regExp: if (useApMode) { | ||||
94 | /^$|^(?:.{8,64}){1}$/ | ||||
95 | } else { | ||||
96 | /^$|^(?:.{5}|[0-9a-fA-F]{10}|.{13}|[0-9a-fA-F]{26}){1}$/ | ||||
97 | } | ||||
98 | } | ||||
99 | | ||||
100 | onAcceptableInputChanged: configurationChanged() | ||||
101 | | ||||
102 | Component.onCompleted: { | ||||
103 | text = configuration.hotspotPassword | ||||
104 | visible = handler.hotspotSupported | ||||
105 | } | ||||
106 | } | ||||
107 | } | ||||
108 | | ||||
109 | Row { | ||||
110 | id: buttonRow | ||||
111 | anchors { | ||||
112 | bottom: parent.bottom | ||||
113 | right: parent.right | ||||
114 | margins: units.smallSpacing | ||||
115 | } | ||||
116 | spacing: units.smallSpacing | ||||
117 | | ||||
118 | QQC2.Button { | ||||
119 | id: okButton | ||||
120 | enabled: false | ||||
121 | text: i18n("Ok") | ||||
122 | | ||||
123 | onClicked: { | ||||
124 | configurationDialog.accept() | ||||
125 | } | ||||
126 | } | ||||
127 | | ||||
128 | QQC2.Button { | ||||
129 | id: cancelButton | ||||
130 | text: i18n("Cancel") | ||||
131 | | ||||
132 | onClicked: { | ||||
133 | configurationDialog.close() | ||||
134 | } | ||||
135 | } | ||||
136 | } | ||||
137 | } | ||||
138 | | ||||
139 | function configurationChanged() { | ||||
140 | if (handler.hotspotSupported) { | ||||
141 | okButton.enabled = hotspotPassword.acceptableInput && hotspotName.text | ||||
142 | } else { | ||||
143 | okButton.enabled = true | ||||
144 | } | ||||
145 | } | ||||
146 | | ||||
147 | onVisibleChanged: { | ||||
148 | if (visible) { | ||||
149 | unlockModem.checked = configuration.unlockModemOnDetection | ||||
150 | manageVirtualConnections.checked = configuration.manageVirtualConnections | ||||
151 | hotspotName.text = configuration.hotspotName | ||||
152 | hotspotPassword.text = configuration.hotspotPassword | ||||
153 | } | ||||
154 | } | ||||
155 | | ||||
156 | onAccepted: { | ||||
157 | configuration.unlockModemOnDetection = unlockModem.checked | ||||
158 | configuration.manageVirtualConnections = manageVirtualConnections.checked | ||||
159 | configuration.hotspotName = hotspotName.text | ||||
160 | configuration.hotspotPassword = hotspotPassword.text | ||||
161 | } | ||||
162 | } | ||||
163 | |