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/>.
18import QtQuick.Layouts 1.1
19import Lomiri.Components 1.3
20import ".." as LocalComponents
21import "../../Components"
24 * See the main passwd-type page for an explanation of why we don't actually
25 * directly set the password here.
30 objectName: "passwdSetPage"
31 title: i18n.tr("Lock Screen Password")
32 focusItem: passwordField
33 forwardButtonSourceComponent: forwardButton
35 readonly property alias password: passwordField.text
36 readonly property alias password2: password2Field.text
37 readonly property bool passwordsMatching: password == password2 && password.trim().length > 7
39 function savePasswordAndGoNext() {
40 root.password = password;
47 flickableDirection: Flickable.VerticalFlick
49 anchors.leftMargin: parent.leftMargin
50 anchors.rightMargin: parent.rightMargin
51 anchors.topMargin: customMargin
53 bottomMargin: Qt.inputMethod.keyboardRectangle.height - height
55 Behavior on contentY { LomiriNumberAnimation {} }
60 objectName: "infoLabel"
66 font.weight: Font.Light
68 text: i18n.tr("Enter at least 8 characters")
78 topMargin: units.gu(3)
80 text: i18n.tr("Choose password")
83 LocalComponents.WizardTextField {
88 top: pass1Label.bottom
89 topMargin: units.gu(1)
91 objectName: "passwordField"
92 echoMode: TextInput.Password
93 onAccepted: password2Field.forceActiveFocus()
94 onActiveFocusChanged: {
96 column.contentY = pass1Label.y
107 top: passwordField.bottom
108 topMargin: units.gu(3)
110 text: i18n.tr("Confirm password")
113 LocalComponents.WizardTextField {
117 top: pass2Label.bottom
118 topMargin: units.gu(1)
121 objectName: "password2Field"
122 echoMode: TextInput.Password
124 if (passwordsMatching) {
125 savePasswordAndGoNext();
128 onActiveFocusChanged: {
130 column.contentY = pass2Label.y
136 LocalComponents.PasswordMeter {
141 top: password2Field.bottom
142 topMargin: units.gu(1)
145 password: passwordField.text
146 matching: passwordsMatching ? true : (password2.trim().length > 0 ? false : undefined)
152 LocalComponents.StackButton {
153 text: i18n.tr("Next")
154 enabled: passwordsMatching
155 onClicked: savePasswordAndGoNext()