on 384164e help sign in
unity8/Greeter/PinLockscreen.qml
111 lines 3.0 kB history raw
1/*
2 * Copyright (C) 2013 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 */
17import QtQuick 2.0
18import Ubuntu.Components 0.1
19import "../Components"
21Column {
22 id: root
23 anchors.centerIn: parent
24 spacing: units.gu(2.5)
26 property alias placeholderText: pinentryField.placeholderText
27 property int padWidth: units.gu(32)
28 property int pinLength: 4
30 signal entered(string passphrase)
31 signal cancel()
33 function clear(playAnimation) {
34 pinentryField.text = "";
35 if (playAnimation) {
36 wrongPasswordAnimation.start();
37 }
38 }
40 TextField {
41 id: pinentryField
42 objectName: "pinentryField"
43 anchors.horizontalCenter: parent.horizontalCenter
44 width: units.gu(32)
45 height: units.gu(5)
46 echoMode: TextInput.Password
47 font.pixelSize: units.dp(44)
48 color: "white"
49 opacity: 0.9
50 hasClearButton: false
51 horizontalAlignment: Text.AlignHCenter
53 onTextChanged: {
54 if (pinentryField.text.length === root.pinLength) {
55 root.entered(pinentryField.text);
56 }
57 }
59 // Using a MouseArea to eat clicks. We don't want to disable the TextField for styling reasons
60 MouseArea {
61 anchors.fill: parent
62 }
63 }
65 Grid {
66 anchors {
67 left: parent.left
68 right: parent.right
69 margins: (parent.width - root.padWidth) / 2
70 }
72 columns: 3
73 spacing: units.gu(1)
75 Repeater {
76 model: 9
78 PinPadButton {
79 objectName: "pinPadButton" + (index + 1)
80 text: index + 1
82 onClicked: {
83 pinentryField.text = pinentryField.text + text
84 }
85 }
86 }
88 PinPadButton {
89 objectName: "pinPadButtonBack"
90 iconName: "back"
91 onClicked: root.cancel();
93 }
94 PinPadButton {
95 objectName: "pinPadButton0"
96 text: "0"
97 onClicked: pinentryField.text = pinentryField.text + text
99 }
100 PinPadButton {
101 objectName: "pinPadButtonErase"
102 iconName: "erase"
103 onClicked: pinentryField.text = pinentryField.text.substring(0, pinentryField.text.length-1)
104 }
105 }
107 WrongPasswordAnimation {
108 id: wrongPasswordAnimation
109 target: pinentryField
110 }