blob: 5dd28e02abde19150a75f2ad8a993f3abdafa970 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
|
import QtQuick 2.6
import Sailfish.Silica 1.0
import "../components"
import PWM 1.0
Dialog {
id: profileEditor
property alias profileName: profileNameField.text
property alias useProtocol: protocolField.checked
property alias useSubdomain: subdomainField.checked
property alias useDomain: domainField.checked
property alias usePortPath: portPathField.checked
property alias useUserInfo: userInfoField.checked
property alias useDefaultFallbackForProtocol : useDefaultFallbackForProtocolField.checked
property alias passwordLength: passwordLengthSlider.value
property alias hashAlgorithm: hashAlgorithmComboBox.currentIndex
property alias useLeet : useLeetComboBox.currentIndex
property alias leetLevel : leetLevelSlider.value
property alias characters : charactersField.text
property alias username : usernameField.text
property alias modifier : modifierField.text
property alias prefix : prefixField.text
property alias suffix : suffixField.text
canAccept: {
profileNameField.acceptableInput
&& charactersField.acceptableInput
&& urlPartsColumn.anySelected
}
onAcceptBlocked: {
if(!urlPartsColumn.anySelected) {
urlNotice.show();
}
else if(!profileNameField.acceptableInput) {
nameNotice.show();
}
else if(!charactersField.acceptableInput) {
charactersNotice.show();
}
}
SilicaFlickable {
anchors.fill: parent
contentHeight: column.height
VerticalScrollDecorator {}
Column {
id: column
width: parent.width
bottomPadding: Theme.paddingLarge
DialogHeader {
title: qsTr("Edit Profile")
}
TextField {
id: profileNameField
width: parent.width
errorHighlight: !acceptableInput
//description doesn't work on Sailfish 3. Use label instead if unavailable.
readonly property bool descriptionAvailable : typeof(description) !== "undefined"
label: !descriptionAvailable && errorHighlight ? qsTr("Required Field") : qsTr("Profile Name")
hideLabelOnEmptyField: descriptionAvailable
placeholderText: qsTr("Profile Name")
Binding {
target: profileNameField
property: "description"
value: profileNameField.errorHighlight ? qsTr("Required Field") : ""
when: profileNameField.descriptionAvailable
}
validator: RegExpValidator{regExp: /.+/}
//It doesn't make much sense to send the focus to the unrelated and rarely used fields waaaaay at the bottom and skip most relevant fields. Rather close the keyboard.
EnterKey.iconSource: "image://theme/icon-m-enter-close"
EnterKey.onClicked: focus = false
}
NoticeOptional {
id: nameNotice
text: qsTr("Profile name required.")
useNotificationFallback: false
}
Column {
id: urlPartsColumn
width: parent.width
topPadding: Theme.paddingLarge
bottomPadding: Theme.paddingLarge
property bool anySelected : (useProtocol || useSubdomain || useDomain || usePortPath || useUserInfo)
TextSwitch {
id: protocolField
text: qsTr("Use Protocol")
description: qsTr("Include URL protocol (e.g. \"http://\")")
palette.highlightColor : down || urlPartsColumn.anySelected ? Theme.highlightColor : Theme.errorColor
highlighted: down || !urlPartsColumn.anySelected
}
TextSwitch {
id: useDefaultFallbackForProtocolField
visible: protocolField.checked
text: qsTr("Use \"undefined\" if protocol is missing")
description: qsTr("Enable to mimic weird behaviour of PasswordMaker Pro.")
palette.highlightColor : down ? Theme.highlightColor : Theme.errorColor
highlighted: down
}
TextSwitch {
id: userInfoField
text: qsTr("Use Userinfo")
description: qsTr("Include userinfo (e.g \"jane_doe:12345\"")
palette.highlightColor : down || urlPartsColumn.anySelected ? Theme.highlightColor : Theme.errorColor
highlighted: down || !urlPartsColumn.anySelected
}
TextSwitch {
id: subdomainField
text: qsTr("Use Subomain(s)")
description: qsTr("Include URL subdomain(s) (e.g. \"www.\")")
palette.highlightColor : down || urlPartsColumn.anySelected ? Theme.highlightColor : Theme.errorColor
highlighted: down || !urlPartsColumn.anySelected
}
TextSwitch {
id: domainField
text: qsTr("Use Domain")
description: qsTr("Include URL domain (e.g. \"example.com\")")
palette.highlightColor : down || urlPartsColumn.anySelected ? Theme.highlightColor : Theme.errorColor
highlighted: down || !urlPartsColumn.anySelected
}
TextSwitch {
id: portPathField
text: qsTr("Use Port/Path")
description: qsTr("Include port and path (e.g \":8080/file\")")
palette.highlightColor : down || urlPartsColumn.anySelected ? Theme.highlightColor : Theme.errorColor
highlighted: down || !urlPartsColumn.anySelected
}
NoticeOptional {
id: urlNotice
text: qsTr("At least one URL part required.")
useNotificationFallback: false
}
}
Column {
width: parent.width
topPadding: Theme.paddingLarge
bottomPadding: Theme.paddingLarge
Slider {
id: passwordLengthSlider
minimumValue: 1
maximumValue: 50
stepSize: 1
width: parent.width
valueText : value
label: qsTr("Password Length")
}
ComboBox {
id: hashAlgorithmComboBox
label: qsTr("Hash Algorithm")
menu: ContextMenu {
MenuItem { text: "MD4" }
MenuItem { text: "HMAC-MD4" }
MenuItem { text: "MD5" }
MenuItem { text: qsTr("MD5 Version 0.6") }
MenuItem { text: "HMAC-MD5" }
MenuItem { text: qsTr("HMAC-MD5 Version 0.6") }
MenuItem { text: "SHA-1" }
MenuItem { text: "HMAC-SHA-1" }
MenuItem { text: "SHA-256" }
MenuItem { text: "HMAC-SHA-256" }
MenuItem { text: "RIPEMD-160" }
MenuItem { text: "HMAC-RIPEMD-160" }
}
}
ComboBox {
id: useLeetComboBox
label: qsTr("Use L33t")
menu: ContextMenu {
MenuItem { text: qsTr("not at all") }
MenuItem { text: qsTr("before generating") }
MenuItem { text: qsTr("after generating") }
MenuItem { text: qsTr("before and after generating") }
}
}
Slider {
id: leetLevelSlider
minimumValue: 1
maximumValue: 9
stepSize: 1
width: parent.width
valueText: value
visible: useLeetComboBox.currentIndex > 0
label: qsTr("Leet Level")
}
}
Column {
enabled: hashAlgorithmComboBox.currentIndex != 3 && hashAlgorithmComboBox.currentIndex != 5
width: parent.width
topPadding: Theme.paddingLarge
bottomPadding: Theme.paddingLarge
ListModel {
id: defaultCharacterValues
ListElement {
name: qsTr("Default Characters")
chars: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`~!@#$%^&*()_-+={}|[]\\:\";'<>?,./"
userFacing: true
}
ListElement {
name: qsTr("Alphanumeric")
chars: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
userFacing: true
}
ListElement {
name: qsTr("Letters only")
chars: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
userFacing: true
}
ListElement {
name: qsTr("Numbers only")
chars: "0123456789"
userFacing: true
}
ListElement {
name: qsTr("Special only")
chars: "`~!@#$%^&*()_-+={}|[]\\:\";'<>?,./"
userFacing: true
}
ListElement {
name: qsTr("Hex")
chars: "0123456789abcdef"
userFacing: true
}
ListElement {
name: qsTr("Custom")
chars: ""
userFacing: false
}
}
ComboBox {
id: defaultCharactersMenu
function matchIndex(text) {
for(var i=0; i < defaultCharacterValues.count - 1;++i)
if(defaultCharacterValues.get(i).chars === text)
return i;
return defaultCharacterValues.count - 1;
}
Binding {
target: defaultCharactersMenu
property: "currentIndex"
value: defaultCharactersMenu.matchIndex(charactersField.text)
}
label: qsTr("Characters Preset")
menu: ContextMenu {
Repeater {
model: defaultCharacterValues
MenuItem {
text: name
visible: userFacing
onClicked: if(userFacing) charactersField.text = chars
}
}
}
}
TextField {
id: charactersField
width: parent.width
errorHighlight: !acceptableInput
//description doesn't work on Sailfish 3. Use label instead if unavailable.
readonly property bool descriptionAvailable : typeof(description) !== "undefined"
label: !descriptionAvailable && errorHighlight ? qsTr("Need at least 2 characters.") : qsTr("Characters")
hideLabelOnEmptyField: descriptionAvailable
placeholderText: qsTr("Characters")
validator: GraphemeCountValidator { minGraphemeCount: 2 }
//The text fields below are conceptually different. Close the keyboard.
EnterKey.iconSource: "image://theme/icon-m-enter-close"
EnterKey.onClicked: focus = false
Binding {
target: charactersField
property: "description"
value: charactersField.errorHighlight ? qsTr("Need at least 2 characters.") : ""
when: charactersField.descriptionAvailable
}
states: State{
name: "locked"
when: hashAlgorithmComboBox.currentIndex === 3 || hashAlgorithmComboBox.currentIndex === 5
PropertyChanges {
target: charactersField
text: "0123456789abcdef"
}
}
}
NoticeOptional {
id: charactersNotice
text: qsTr("Need at least 2 characters.")
useNotificationFallback: false
}
}
Column {
width: parent.width
topPadding: Theme.paddingLarge
bottomPadding: Theme.paddingLarge
TextField {
id: usernameField
width: parent.width
label: qsTr("Username")
placeholderText: qsTr("Username")
EnterKey.iconSource: "image://theme/icon-m-enter-next"
EnterKey.onClicked: modifierField.focus = true
}
TextField {
id: modifierField
width: parent.width
label: qsTr("Modifier")
placeholderText: qsTr("Modifier")
EnterKey.iconSource: "image://theme/icon-m-enter-next"
EnterKey.onClicked: prefixField.focus = true
}
TextField {
id: prefixField
width: parent.width
label: qsTr("Prefix")
placeholderText: qsTr("Prefix")
EnterKey.iconSource: "image://theme/icon-m-enter-next"
EnterKey.onClicked: suffixField.focus = true
}
TextField {
id: suffixField
width: parent.width
label: qsTr("Suffix")
placeholderText: qsTr("Suffix")
//There are many non-keyboard-input switches on this page. Do not let the user confirm using keyboard.
EnterKey.iconSource: "image://theme/icon-m-enter-close"
EnterKey.onClicked: focus = false
}
}
}
}
}
|