@@ -39,25 +39,19 @@ LocalComponents.Page {
39 forwardButtonSourceComponent: forwardButton
39 forwardButtonSourceComponent: forwardButton
41 function indexToMethod(index) {
41 function indexToMethod(index) {
42− if (index === 1)
42+ if (index === 0 || index === 1)
43− return UbuntuSecurityPrivacyPanel.Passcode;
44− else if (index === 0)
45 return UbuntuSecurityPrivacyPanel.Passphrase;
43 return UbuntuSecurityPrivacyPanel.Passphrase;
44+ else if (index === 2)
45+ return UbuntuSecurityPrivacyPanel.Passcode;
47 return UbuntuSecurityPrivacyPanel.Swipe;
47 return UbuntuSecurityPrivacyPanel.Swipe;
50− function methodToIndex(method) {
51− if (method === UbuntuSecurityPrivacyPanel.Passcode)
53− else if (method === UbuntuSecurityPrivacyPanel.Passphrase)
59 Component.onCompleted: {
50 Component.onCompleted: {
60− selector.currentIndex = methodToIndex(root.passwordMethod);
51+ if (root.password !== "") // the user has set a password as part of the previous page
52+ selector.currentIndex = 0;
54+ selector.currentIndex = 1;
@@ -97,7 +91,8 @@ LocalComponents.Page {
97 height: childrenRect.height
91 height: childrenRect.height
99 // this is the order we want to display it; cf indexToMethod()
93 // this is the order we want to display it; cf indexToMethod()
100− model: [UbuntuSecurityPrivacyPanel.Passphrase, UbuntuSecurityPrivacyPanel.Passcode, UbuntuSecurityPrivacyPanel.Swipe]
94+ model: [UbuntuSecurityPrivacyPanel.Passphrase, UbuntuSecurityPrivacyPanel.Passphrase,
95+ UbuntuSecurityPrivacyPanel.Passcode, UbuntuSecurityPrivacyPanel.Swipe]
102 delegate: ListItem {
97 delegate: ListItem {
103 id: itemDelegate
98 id: itemDelegate
@@ -115,19 +110,16 @@ LocalComponents.Page {
115 color: textColor
110 color: textColor
116 font.weight: itemDelegate.isCurrent ? Font.Normal : Font.Light
111 font.weight: itemDelegate.isCurrent ? Font.Normal : Font.Light
118− var method = modelData
113+ switch (index) {
119− var name = ""
114+ case 0:
120− var desc = ""
115+ return i18n.ctr("Label: Type of security method", "Device account password");
121− if (method === UbuntuSecurityPrivacyPanel.Swipe) {
116+ case 1:
122− return i18n.ctr("Label: Type of security method", "None");
117+ return i18n.ctr("Label: Type of security method", "New password");
123− } else if (method === UbuntuSecurityPrivacyPanel.Passcode) {
118+ case 2:
124− name = i18n.ctr("Label: Type of security method", "Passcode");
119+ return i18n.ctr("Label: Type of security method", "Passcode");
125− desc = i18n.ctr("Label: Description of security method", "4 digits only");
120+ case 3:
126− } else {
121+ return i18n.ctr("Label: Type of security method", "Swipe");
127− name = i18n.ctr("Label: Type of security method", "Password");
128− desc = i18n.ctr("Label: Description of security method", "numbers and letters");
130− return "%1 (%2)".arg(name).arg(desc);
@@ -170,11 +162,14 @@ LocalComponents.Page {
170 root.passwordMethod = method;
162 root.passwordMethod = method;
171 print("Current method: " + root.passwordMethod);
163 print("Current method: " + root.passwordMethod);
173− if (method === UbuntuSecurityPrivacyPanel.Passphrase) {
165+ if (method === UbuntuSecurityPrivacyPanel.Passphrase) { // any password
166+ if (selector.currentIndex == 1)
174− pageStack.load(Qt.resolvedUrl("password-set.qml"));
167+ pageStack.load(Qt.resolvedUrl("password-set.qml")); // let the user choose a new password
169+ pageStack.next(); // got the password already, go next page
175− } else if (method === UbuntuSecurityPrivacyPanel.Passcode) {
170+ } else if (method === UbuntuSecurityPrivacyPanel.Passcode) { // passcode
176 pageStack.load(Qt.resolvedUrl("passcode-set.qml"));
171 pageStack.load(Qt.resolvedUrl("passcode-set.qml"));
177− } else {
172+ } else { //swipe
178 pageStack.next();
173 pageStack.next();