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
|
import QtQuick 2.6
import Sailfish.Silica 1.0
import "../components"
Page {
id: profilesSelector
SilicaListView {
id : profilesView
anchors.fill: parent
model : passwordmaker.profiles
function store_profile_with_error_message() {
var worked = profilesView.model.store();
if(!worked) {
storeFailureNotice.show();
}
}
PullDownMenu {
MenuItem {
text: qsTr("Add profile")
onClicked: {
profilesView.model.insertRows(profilesView.model.rowCount(),1);
profilesView.store_profile_with_error_message();
}
}
}
header: PageHeader {
title: qsTr("Select/edit profiles")
}
delegate: ListItem {
id: delegate
width: parent.width
ListView.onAdd: AddAnimation {
target: delegate
}
ListView.onRemove: RemoveAnimation {
target: delegate
}
Label {
x: Theme.horizontalPageMargin
text: name
anchors.verticalCenter: parent.verticalCenter
color: index === profilesView.model.current_profile ? Theme.highlightColor : Theme.primaryColor
}
menu: ContextMenu {
MenuItem {
text: qsTr("Edit")
onClicked: {
var pg = pageStack.animatorPush(Qt.resolvedUrl("ProfileEditor.qml"),
{
profileName : name,
useProtocol : use_protocol,
useSubdomain : use_subdomains,
useDomain : use_domain,
usePortPath : use_port_path,
passwordLength : password_length,
hashAlgorithm : hash_algorithm,
useLeet : use_leet,
leetLevel : leet_level > 0 ? leet_level : 1,
characters : characters,
username : username,
modifier : modifier,
prefix : prefix,
suffix : suffix,
useUserInfo : use_user_info,
useDefaultFallbackForProtocol : use_undefined_as_protocol_fallback
});
pg.pageCompleted.connect(function(pg) {
pg.accepted.connect(function() {
name = pg.profileName;
use_protocol = pg.useProtocol;
use_subdomains = pg.useSubdomain;
use_domain = pg.useDomain;
use_port_path = pg.usePortPath;
password_length = pg.passwordLength;
hash_algorithm = pg.hashAlgorithm;
use_leet = pg.useLeet;
leet_level = pg.leetLevel;
characters = pg.characters;
username = pg.username;
modifier = pg.modifier;
prefix = pg.prefix;
suffix = pg.suffix;
use_user_info = pg.useUserInfo;
use_undefined_as_protocol_fallback = pg.useDefaultFallbackForProtocol;
if(index === profilesView.model.current_profile)
passwordmaker.profile_changed();
profilesView.store_profile_with_error_message();
})
})
}
}
MenuItem {
text: qsTr("Remove")
enabled: profilesView.count > 1
onClicked: {
delegate.remorseDelete(function() {
var bWasCurrentProfile = index === profilesView.model.current_profile;
profilesView.model.removeRows(index,1);
profilesView.store_profile_with_error_message();
if(bWasCurrentProfile)
passwordmaker.profile_changed();
})
}
}
}
onClicked: {
if(profilesView.model.current_profile !== index)
{
profilesView.model.current_profile = index;
passwordmaker.profile_changed();
}
pageContainer.navigateBack(PageStackAction.Animated);
}
}
NoticeOptional {
id: storeFailureNotice
text: qsTr("Saving profiles failed.")
useNotificationFallback: true
}
VerticalScrollDecorator {}
}
}
|