Unity 8
passwd-confirm.qml
1 /*
2  * Copyright (C) 2014 Canonical, Ltd.
3  *
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.
7  *
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.
12  *
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/>.
15  */
16 
17 import QtQuick 2.4
18 import Ubuntu.Components 1.3
19 import Ubuntu.SystemSettings.SecurityPrivacy 1.0
20 import ".." as LocalComponents
21 import "../../Components" as UnityComponents
22 
23 /**
24  * See the main passwd-type page for an explanation of why we don't actually
25  * directly set the password here.
26  */
27 
28 LocalComponents.Page {
29  id: passwdConfirmPage
30  objectName: "passwdConfirmPage"
31  forwardButtonSourceComponent: forwardButton
32 
33  skip: root.passwordMethod === UbuntuSecurityPrivacyPanel.Swipe
34 
35  // If we are entering this page, clear any saved password and get focus
36  onEnabledChanged: if (enabled) lockscreen.clear(false)
37 
38  UnityComponents.Lockscreen {
39  id: lockscreen
40  anchors {
41  fill: parent
42  topMargin: topMargin
43  leftMargin: leftMargin
44  rightMargin: rightMargin
45  bottomMargin: buttonMargin
46  }
47 
48  infoText: root.passwordMethod === UbuntuSecurityPrivacyPanel.Passphrase ?
49  i18n.tr("Confirm passphrase") :
50  i18n.tr("Confirm passcode")
51 
52  errorText: root.passwordMethod === UbuntuSecurityPrivacyPanel.Passphrase ?
53  i18n.tr("Sorry, incorrect passphrase.") + "\n" + i18n.tr("Please try again.") :
54  i18n.tr("Sorry, incorrect passcode.") + "\n" + i18n.tr("Please try again.")
55 
56  showEmergencyCallButton: false
57  showCancelButton: false
58  alphaNumeric: root.passwordMethod === UbuntuSecurityPrivacyPanel.Passphrase
59  minPinLength: 4
60  maxPinLength: 4
61 
62  onEntered: {
63  if (passphrase === root.password) {
64  confirmTimer.start()
65  } else {
66  clear(true)
67  }
68  }
69 
70  Timer {
71  id: confirmTimer
72  interval: UbuntuAnimation.SnapDuration
73  onTriggered: pageStack.next()
74  }
75  }
76 
77  Component {
78  id: forwardButton
79  LocalComponents.StackButton {
80  visible: root.passwordMethod === UbuntuSecurityPrivacyPanel.Passphrase
81  enabled: root.password === lockscreen.passphrase
82  text: i18n.tr("Continue")
83  onClicked: pageStack.next()
84  }
85  }
86 }