59
id: changeSecurityDialog
61
property int oldMethod: securityPrivacy.securityType
62
property int newMethod: indexToMethod(unlockMethod.selectedIndex)
64
function clearInputs() {
65
currentInput.text = ""
67
confirmInput.text = ""
68
incorrect.visible = false
69
notMatching.visible = false
70
confirmButton.enabled = false
74
if (changeSecurityDialog.newMethod ==
75
changeSecurityDialog.oldMethod) { // Changing existing
76
switch (changeSecurityDialog.newMethod) {
77
case UbuntuSecurityPrivacyPanel.Passcode:
78
return i18n.tr("Change passcode")
79
case UbuntuSecurityPrivacyPanel.Passphrase:
80
return i18n.tr("Change passphrase")
81
default: // To stop the runtime complaining
85
switch (changeSecurityDialog.newMethod) {
86
case UbuntuSecurityPrivacyPanel.Swipe:
87
return i18n.tr("Switch to swipe")
88
case UbuntuSecurityPrivacyPanel.Passcode:
89
return i18n.tr("Switch to passcode")
90
case UbuntuSecurityPrivacyPanel.Passphrase:
91
return i18n.tr("Switch to passphrase")
98
switch (changeSecurityDialog.oldMethod) {
99
case UbuntuSecurityPrivacyPanel.Passcode:
100
return i18n.tr("Existing passcode")
101
case UbuntuSecurityPrivacyPanel.Passphrase:
102
return i18n.tr("Existing passphrase")
103
// Shouldn't be reached when visible but still evaluated
109
visible: currentInput.visible
114
echoMode: TextInput.Password
116
if (changeSecurityDialog.oldMethod ===
117
UbuntuSecurityPrivacyPanel.Passphrase)
118
return Qt.ImhNoAutoUppercase | Qt.ImhSensitiveData
119
else if (changeSecurityDialog.oldMethod ===
120
UbuntuSecurityPrivacyPanel.Passcode)
121
return Qt.ImhNoAutoUppercase |
122
Qt.ImhSensitiveData |
128
if (changeSecurityDialog.oldMethod ===
129
UbuntuSecurityPrivacyPanel.Passcode)
134
visible: changeSecurityDialog.oldMethod ===
135
UbuntuSecurityPrivacyPanel.Passphrase ||
136
changeSecurityDialog.oldMethod ===
137
UbuntuSecurityPrivacyPanel.Passcode
139
if (changeSecurityDialog.newMethod ===
140
UbuntuSecurityPrivacyPanel.Swipe)
141
confirmButton.enabled = text.length > 0
148
if (changeSecurityDialog.oldMethod ===
149
UbuntuSecurityPrivacyPanel.Passcode)
150
return i18n.tr("Incorrect passcode. Try again.")
151
if (changeSecurityDialog.oldMethod ===
152
UbuntuSecurityPrivacyPanel.Passphrase)
153
return i18n.tr("Incorrect passphrase. Try again.")
155
//Fallback to prevent warnings. Not displayed.
164
switch (changeSecurityDialog.newMethod) {
165
case UbuntuSecurityPrivacyPanel.Passcode:
166
return i18n.tr("Choose passcode")
167
case UbuntuSecurityPrivacyPanel.Passphrase:
168
return i18n.tr("Choose passphrase")
169
// Shouldn't be reached when visible but still evaluated
174
visible: newInput.visible
179
echoMode: TextInput.Password
181
if (changeSecurityDialog.newMethod ===
182
UbuntuSecurityPrivacyPanel.Passphrase)
183
return Qt.ImhNoAutoUppercase | Qt.ImhSensitiveData
184
else if (changeSecurityDialog.newMethod ===
185
UbuntuSecurityPrivacyPanel.Passcode)
186
return Qt.ImhNoAutoUppercase |
187
Qt.ImhSensitiveData |
193
if (changeSecurityDialog.newMethod ===
194
UbuntuSecurityPrivacyPanel.Passcode)
199
visible: changeSecurityDialog.newMethod ===
200
UbuntuSecurityPrivacyPanel.Passcode ||
201
changeSecurityDialog.newMethod ===
202
UbuntuSecurityPrivacyPanel.Passphrase
203
// Doesn't get updated if you set this in enabled of confirmButton
204
onTextChanged: confirmButton.enabled =
205
(acceptableInput && (!visible || text.length > 0))
210
switch (changeSecurityDialog.newMethod) {
211
case UbuntuSecurityPrivacyPanel.Passcode:
212
return i18n.tr("Confirm passcode")
213
case UbuntuSecurityPrivacyPanel.Passphrase:
214
return i18n.tr("Confirm passphrase")
215
// Shouldn't be reached when visible but still evaluated
220
visible: confirmInput.visible
225
echoMode: TextInput.Password
227
if (changeSecurityDialog.newMethod ===
228
UbuntuSecurityPrivacyPanel.Passphrase)
229
return Qt.ImhNoAutoUppercase | Qt.ImhSensitiveData
230
else if (changeSecurityDialog.newMethod ===
231
UbuntuSecurityPrivacyPanel.Passcode)
232
return Qt.ImhNoAutoUppercase |
233
Qt.ImhSensitiveData |
239
if (changeSecurityDialog.newMethod ===
240
UbuntuSecurityPrivacyPanel.Passcode)
245
visible: changeSecurityDialog.newMethod ===
246
UbuntuSecurityPrivacyPanel.Passcode ||
247
changeSecurityDialog.newMethod ===
248
UbuntuSecurityPrivacyPanel.Passphrase
254
if (changeSecurityDialog.newMethod ===
255
UbuntuSecurityPrivacyPanel.Passcode)
256
return i18n.tr("Those passcodes don't match. Try again.")
257
if (changeSecurityDialog.newMethod ===
258
UbuntuSecurityPrivacyPanel.Passphrase)
259
return i18n.tr("Those passphrases don't match. Try again.")
261
//Fallback to prevent warnings. Not displayed.
271
text: changeSecurityDialog.newMethod ===
272
UbuntuSecurityPrivacyPanel.Swipe ?
277
var correct = !currentInput.visible ||
278
(currentInput.text == securityPrivacy.securityValue)
279
var match = (newInput.text == confirmInput.text)
281
incorrect.visible = !correct
283
if (correct) // one problem at a time
284
notMatching.visible = !match
286
if (correct && match) {
287
PopupUtils.close(changeSecurityDialog)
288
securityPrivacy.securityType =
289
indexToMethod(unlockMethod.selectedIndex)
290
securityPrivacy.securityValue = newInput.text
291
changeSecurityDialog.clearInputs()
295
currentInput.forceActiveFocus()
296
currentInput.selectAll()
302
newInput.forceActiveFocus()
310
text: i18n.tr("Cancel")
312
PopupUtils.close(changeSecurityDialog)
313
unlockMethod.skip = true
314
unlockMethod.selectedIndex =
315
methodToIndex(securityPrivacy.securityType)
316
changeSecurityDialog.clearInputs()
60
function openDialog() {
61
var dlg = PopupUtils.open(dialogComponent)
62
// Set manually rather than have these be dynamically bound, since
63
// the security type can change out from under us, but we don't
64
// want dialog to change in that case.
65
dlg.oldMethod = securityPrivacy.securityType
66
dlg.newMethod = indexToMethod(unlockMethod.selectedIndex)
73
id: changeSecurityDialog
75
// This is a bit hacky, but the contents of this dialog get so tall
76
// that on a mako device, they don't fit with the OSK also visible.
77
// So we scrunch up spacing.
80
property: "itemSpacing"
84
property int oldMethod
85
property int newMethod
88
if (changeSecurityDialog.newMethod ==
89
changeSecurityDialog.oldMethod) { // Changing existing
90
switch (changeSecurityDialog.newMethod) {
91
case UbuntuSecurityPrivacyPanel.Passcode:
92
return i18n.tr("Change passcode")
93
case UbuntuSecurityPrivacyPanel.Passphrase:
94
return i18n.tr("Change passphrase")
95
default: // To stop the runtime complaining
99
switch (changeSecurityDialog.newMethod) {
100
case UbuntuSecurityPrivacyPanel.Swipe:
101
return i18n.tr("Switch to swipe")
102
case UbuntuSecurityPrivacyPanel.Passcode:
103
return i18n.tr("Switch to passcode")
104
case UbuntuSecurityPrivacyPanel.Passphrase:
105
return i18n.tr("Switch to passphrase")
112
switch (changeSecurityDialog.oldMethod) {
113
case UbuntuSecurityPrivacyPanel.Passcode:
114
return i18n.tr("Existing passcode")
115
case UbuntuSecurityPrivacyPanel.Passphrase:
116
return i18n.tr("Existing passphrase")
117
// Shouldn't be reached when visible but still evaluated
123
visible: currentInput.visible
128
echoMode: TextInput.Password
130
if (changeSecurityDialog.oldMethod ===
131
UbuntuSecurityPrivacyPanel.Passphrase)
132
return Qt.ImhNoAutoUppercase | Qt.ImhSensitiveData
133
else if (changeSecurityDialog.oldMethod ===
134
UbuntuSecurityPrivacyPanel.Passcode)
135
return Qt.ImhNoAutoUppercase |
136
Qt.ImhSensitiveData |
142
if (changeSecurityDialog.oldMethod ===
143
UbuntuSecurityPrivacyPanel.Passcode)
148
visible: changeSecurityDialog.oldMethod ===
149
UbuntuSecurityPrivacyPanel.Passphrase ||
150
changeSecurityDialog.oldMethod ===
151
UbuntuSecurityPrivacyPanel.Passcode
153
if (changeSecurityDialog.newMethod ===
154
UbuntuSecurityPrivacyPanel.Swipe)
155
confirmButton.enabled = text.length > 0
168
switch (changeSecurityDialog.newMethod) {
169
case UbuntuSecurityPrivacyPanel.Passcode:
170
return i18n.tr("Choose passcode")
171
case UbuntuSecurityPrivacyPanel.Passphrase:
172
return i18n.tr("Choose passphrase")
173
// Shouldn't be reached when visible but still evaluated
178
visible: newInput.visible
183
echoMode: TextInput.Password
185
if (changeSecurityDialog.newMethod ===
186
UbuntuSecurityPrivacyPanel.Passphrase)
187
return Qt.ImhNoAutoUppercase | Qt.ImhSensitiveData
188
else if (changeSecurityDialog.newMethod ===
189
UbuntuSecurityPrivacyPanel.Passcode)
190
return Qt.ImhNoAutoUppercase |
191
Qt.ImhSensitiveData |
197
if (changeSecurityDialog.newMethod ===
198
UbuntuSecurityPrivacyPanel.Passcode)
203
visible: changeSecurityDialog.newMethod ===
204
UbuntuSecurityPrivacyPanel.Passcode ||
205
changeSecurityDialog.newMethod ===
206
UbuntuSecurityPrivacyPanel.Passphrase
207
// Doesn't get updated if you set this in enabled of confirmButton
208
onTextChanged: confirmButton.enabled =
209
(acceptableInput && (!visible || text.length > 0))
214
switch (changeSecurityDialog.newMethod) {
215
case UbuntuSecurityPrivacyPanel.Passcode:
216
return i18n.tr("Confirm passcode")
217
case UbuntuSecurityPrivacyPanel.Passphrase:
218
return i18n.tr("Confirm passphrase")
219
// Shouldn't be reached when visible but still evaluated
224
visible: confirmInput.visible
229
echoMode: TextInput.Password
231
if (changeSecurityDialog.newMethod ===
232
UbuntuSecurityPrivacyPanel.Passphrase)
233
return Qt.ImhNoAutoUppercase | Qt.ImhSensitiveData
234
else if (changeSecurityDialog.newMethod ===
235
UbuntuSecurityPrivacyPanel.Passcode)
236
return Qt.ImhNoAutoUppercase |
237
Qt.ImhSensitiveData |
243
if (changeSecurityDialog.newMethod ===
244
UbuntuSecurityPrivacyPanel.Passcode)
249
visible: changeSecurityDialog.newMethod ===
250
UbuntuSecurityPrivacyPanel.Passcode ||
251
changeSecurityDialog.newMethod ===
252
UbuntuSecurityPrivacyPanel.Passphrase
258
if (changeSecurityDialog.newMethod ===
259
UbuntuSecurityPrivacyPanel.Passcode)
260
return i18n.tr("Those passcodes don't match. Try again.")
261
if (changeSecurityDialog.newMethod ===
262
UbuntuSecurityPrivacyPanel.Passphrase)
263
return i18n.tr("Those passphrases don't match. Try again.")
265
//Fallback to prevent warnings. Not displayed.
276
Layout.fillWidth: true
277
text: i18n.tr("Cancel")
279
PopupUtils.close(changeSecurityDialog)
280
unlockMethod.selectedIndex =
281
methodToIndex(securityPrivacy.securityType)
287
Layout.fillWidth: true
290
if (changeSecurityDialog.newMethod ===
291
UbuntuSecurityPrivacyPanel.Swipe)
292
return i18n.tr("Unset")
293
else if (changeSecurityDialog.oldMethod ===
294
changeSecurityDialog.newMethod)
295
return i18n.tr("Change")
297
return i18n.tr("Set")
301
changeSecurityDialog.enabled = false
303
var match = (newInput.text == confirmInput.text)
304
notMatching.visible = !match
306
changeSecurityDialog.enabled = true
307
newInput.forceActiveFocus()
312
var errorText = securityPrivacy.setSecurity(
313
currentInput.visible ? currentInput.text : "",
315
changeSecurityDialog.newMethod)
316
incorrect.text = errorText
317
if (errorText !== "") {
318
changeSecurityDialog.enabled = true
319
currentInput.forceActiveFocus()
320
currentInput.selectAll()
324
changeSecurityDialog.enabled = true
325
PopupUtils.close(changeSecurityDialog)