2 * Copyright (C) 2014-2016 Canonical Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18import Lomiri.Components 1.3
19import Lomiri.Components.ListItems 1.3
20import Lomiri.SystemSettings.SecurityPrivacy 1.0
21import ".." as LocalComponents
22import "../../Components"
25 * One quirk with this page: we don't actually set the password. We avoid
26 * doing it here because the user can come back to this page and change their
27 * answer. We don't run as root, so if we did set the password immediately,
28 * we'd need to prompt for their previous password when they came back and
29 * changed their answer. Which is silly UX. So instead, we just keep track
30 * of their choice and set the password at the end (see Pages.qml).
31 * Setting the password shouldn't fail, since Lomiri Touch has loose password
32 * requirements, but we'll check what we can here. Ideally we'd be able to ask
33 * the system if a password is legal without actually setting that password.
38 objectName: "passwdPage"
40 title: i18n.tr("Lock Screen")
41 forwardButtonSourceComponent: forwardButton
43 // If the user has set a password some other way (via lomiri-device-flash
44 // or this isn't the first time the wizard has been run, etc). We can't
45 // properly set the password again, so let's not pretend we can.
46 skip: securityPrivacy.securityType !== LomiriSecurityPrivacyPanel.Swipe
49 function indexToMethod(index) {
50 if (index === 0/* || index === 1*/)
51 return LomiriSecurityPrivacyPanel.Passphrase;
52 else if (index === 1/*2*/)
53 return LomiriSecurityPrivacyPanel.Passcode;
55 return LomiriSecurityPrivacyPanel.Swipe;
58// Component.onCompleted: {
59// if (root.password !== "") // the user has set a password as part of the previous page
60// selector.currentIndex = 0;
62// selector.currentIndex = 1;
68 anchors.topMargin: customMargin
69 anchors.leftMargin: wideMode ? parent.leftMargin : 0
70 anchors.rightMargin: wideMode ? parent.rightMargin : 0
74 anchors.left: parent.left
75 anchors.right: parent.right
76 boundsBehavior: Flickable.StopAtBounds
78 height: childrenRect.height
80 // this is the order we want to display it; cf indexToMethod()
81 model: [/*LomiriSecurityPrivacyPanel.Passphrase, */LomiriSecurityPrivacyPanel.Passphrase,
82 LomiriSecurityPrivacyPanel.Passcode, LomiriSecurityPrivacyPanel.Swipe]
86 objectName: "passwdDelegate" + index
87 readonly property bool isCurrent: index === ListView.view.currentIndex
88 highlightColor: backgroundColor
89 divider.colorFrom: dividerColor
90 divider.colorTo: backgroundColor
92 anchors.verticalCenter: parent.verticalCenter;
93 anchors.left: parent.left
94 anchors.leftMargin: column.anchors.leftMargin == 0 ? staticMargin : 0
97 font.weight: itemDelegate.isCurrent ? Font.Normal : Font.Light
101// return i18n.ctr("Label: Type of security method", "Lomiri administrator password");
103 return i18n.ctr("Label: Type of security method", "Create new password");
105 return i18n.ctr("Label: Type of security method", "Create passcode (numbers only)");
107 return i18n.ctr("Label: Type of security method", "No lock code");
111 wrapMode: Text.WordWrap
117 verticalCenter: parent.verticalCenter
118 rightMargin: column.anchors.rightMargin == 0 ? staticMargin : 0
120 fillMode: Image.PreserveAspectFit
121 height: units.gu(1.5)
123 source: "data/Tick@30.png"
124 visible: itemDelegate.isCurrent
128 selector.currentIndex = index;
135 anchors.left: parent.left
136 anchors.right: parent.right
137 anchors.top: selector.bottom
145 LocalComponents.StackButton {
146 text: i18n.tr("Next")
148 var method = indexToMethod(selector.currentIndex);
149 root.passwordMethod = method;
151 if (method === LomiriSecurityPrivacyPanel.Passphrase) { // any password
152 if (selector.currentIndex == 0/*1*/)
153 pageStack.load(Qt.resolvedUrl("password-set.qml")); // let the user choose a new password
155 pageStack.next(); // got the password already, go next page
156 } else if (method === LomiriSecurityPrivacyPanel.Passcode) { // passcode
158 pageStack.load(Qt.resolvedUrl("passcode-desktop.qml"));
160 pageStack.load(Qt.resolvedUrl("passcode-set.qml"));