@@ -15,9 +15,9 @@
17import QtQuick 2.4
17import QtQuick 2.4
18+import QtQuick.Layouts 1.1
18import Ubuntu.Components 1.3
19import Ubuntu.Components 1.3
19import ".." as LocalComponents
20import ".." as LocalComponents
20−import "../../Components" as UnityComponents
23 * See the main passwd-type page for an explanation of why we don't actually
23 * See the main passwd-type page for an explanation of why we don't actually
@@ -27,147 +27,88 @@ import "../../Components" as UnityComponents
27LocalComponents.Page {
27LocalComponents.Page {
28 id: passwdSetPage
28 id: passwdSetPage
29 objectName: "passwdSetPage"
29 objectName: "passwdSetPage"
31− buttonBarVisible: false
32− title: confirmPhase ? i18n.tr("Confirm Password") : i18n.tr("Choose Password")
30+ title: i18n.tr("Lock Screen Password")
31+ forwardButtonSourceComponent: forwardButton
34− property alias password: passwordField.text
33+ readonly property alias password: passwordField.text
35− property bool confirmPhase: false
34+ readonly property alias password2: password2Field.text
35+ readonly property bool passwordsMatching: password == password2 && password.trim().length > 7
37− // If we are entering this page, clear any saved password and get focus
37+ ColumnLayout {
38− onEnabledChanged: if (enabled) password = ""
40− Component.onCompleted: {
42− passwordField.forceActiveFocus();
46− root.password = password;
47− confirmTimer.start();
52− interval: UbuntuAnimation.SnapDuration
56− passwordField.forceActiveFocus();
60− function setError(text) {
62− infoLabel.hasError = true;
63− infoLabel.text = text;
67− function setInfo(text) {
68− infoLabel.hasError = false;
70− infoLabel.text = text;
72− infoLabel.text = i18n.tr("Enter at least 8 characters");
77 id: column
38 id: column
78 anchors.fill: content
39 anchors.fill: content
79 anchors.leftMargin: leftMargin
40 anchors.leftMargin: leftMargin
80 anchors.rightMargin: rightMargin
41 anchors.rightMargin: rightMargin
42+ anchors.topMargin: customMargin
83 id: infoLabel
46 id: infoLabel
84 objectName: "infoLabel"
47 objectName: "infoLabel"
85− property bool hasError: false
87 left: parent.left
49 left: parent.left
88 right: parent.right
50 right: parent.right
89− topMargin: units.gu(3)
91 wrapMode: Text.Wrap
52 wrapMode: Text.Wrap
53+ font.weight: Font.Light
92− color: hasError ? errorColor : textColor
54+ color: textColor
55+ text: i18n.tr("Enter at least 8 characters")
95− LocalComponents.WizardTextField {
58+ ColumnLayout {
96− id: passwordField
59+ id: innerLayout
97− objectName: "passwordField"
60+ Label {
98− anchors {
61+ text: i18n.tr("Choose password")
99− left: parent.left
62+ color: textColor
101− top: infoLabel.bottom
102− topMargin: units.gu(1)
104− echoMode: TextInput.Password
64+ LocalComponents.WizardTextField {
105− onTextChanged: {
65+ Layout.fillWidth: true
106− if (confirmPhase) {
66+ id: passwordField
107− if (password.length == 0) {
67+ objectName: "passwordField"
108− setInfo();
68+ echoMode: TextInput.Password
109− } else if (password !== root.password) {
69+ onAccepted: password2Field.forceActiveFocus()
110− setError(i18n.tr("Passwords do not match"));
70+ }
112− setInfo(i18n.tr("Passwords match"));
72+ Label {
113− }
73+ text: i18n.tr("Confirm password")
114− }
74+ color: textColor
75+ anchors.topMargin: units.gu(1)
77+ LocalComponents.WizardTextField {
78+ Layout.fillWidth: true
80+ objectName: "password2Field"
81+ echoMode: TextInput.Password
118 // password meter
85 // password meter
119 LocalComponents.PasswordMeter {
86 LocalComponents.PasswordMeter {
120 id: passMeter
87 id: passMeter
121− anchors.left: parent.left
122− anchors.right: parent.right
123− anchors.top: passwordField.bottom
124− anchors.topMargin: units.gu(1)
125− password: passwordField.text
131− objectName: "cancelButton"
132 anchors {
88 anchors {
133− top: passMeter.bottom
134 left: parent.left
89 left: parent.left
135− right: parent.horizontalCenter
90+ right: parent.right
136− rightMargin: units.gu(1)
91+ top: innerLayout.bottom
137− topMargin: units.gu(4)
92+ topMargin: units.gu(1)
139− text: i18n.tr("Cancel")
142− confirmPhase = false;
145− passwordField.forceActiveFocus();
95+ password: passwordField.text
96+ matching: passwordsMatching
152− Button {
99+ Item { // spacer
153− id: okButton
100+ Layout.fillHeight: true
154− objectName: "okButton"
101+ }
156− top: passMeter.bottom
103+
157− left: parent.horizontalCenter
104+ Component {
158− right: parent.right
105+ id: forwardButton
159− leftMargin: units.gu(1)
106+ LocalComponents.StackButton {
160− topMargin: units.gu(4)
162− text: i18n.tr("OK")
107+ text: i18n.tr("Next")
163− color: okColor
108+ enabled: passwordsMatching
164− enabled: confirmPhase ? password === root.password : password.length > 7 // TODO set more sensible restrictions for the length?
165 onClicked: {
109 onClicked: {
166− if (confirmPhase) {
110+ root.password = password;
167− pageStack.next();
111+ pageStack.next();
169− passwdSetPage.confirm();