2 * Copyright (C) 2015-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/>.
18 import QtQuick.Layouts 1.1
19 import Ubuntu.Components 1.3
20 import ".." as LocalComponents
23 * See the main passwd-type page for an explanation of why we don't actually
24 * directly set the password here.
27 LocalComponents.Page {
29 objectName: "passcodeDesktopPage"
30 title: i18n.tr("Lock Screen Passcode")
31 forwardButtonSourceComponent: forwardButton
33 readonly property alias password: passwordField.text
34 readonly property alias password2: password2Field.text
41 anchors.leftMargin: leftMargin
42 anchors.rightMargin: rightMargin
43 anchors.topMargin: customMargin
44 rowSpacing: units.gu(3)
48 objectName: "infoLabel"
54 font.weight: Font.Light
56 text: i18n.tr("Enter 4 numbers to setup your passcode")
61 columnSpacing: units.gu(2)
62 rowSpacing: units.gu(2)
65 text: i18n.tr("Choose passcode")
68 LocalComponents.WizardTextField {
69 Layout.fillWidth: true
71 objectName: "passwordField"
72 echoMode: TextInput.Password
73 inputMethodHints: Qt.ImhDigitsOnly
74 validator: RegExpValidator { regExp: /^\d{4}$/ }
76 onAccepted: password2Field.forceActiveFocus()
80 text: i18n.tr("Confirm passcode")
83 LocalComponents.WizardTextField {
84 Layout.fillWidth: true
86 objectName: "password2Field"
87 echoMode: TextInput.Password
88 inputMethodHints: Qt.ImhDigitsOnly
89 validator: RegExpValidator { regExp: /^\d{4}$/ }
97 property bool hasError: password && password != password2
99 color: hasError ? errorColor : UbuntuColors.ash
100 visible: password && password2
104 if (password2.length < password2Field.maximumLength)
105 return i18n.tr("Passcode too short");
106 else if (password == password2)
107 return i18n.tr("Passcodes match");
109 return i18n.tr("Passcodes do not match");
117 Layout.fillHeight: true
123 LocalComponents.StackButton {
124 text: i18n.tr("Next")
125 enabled: password != "" && password == password2
127 root.password = password;