on 5b03213 help sign in
unity8/Greeter/PinLockscreen.qml
185 lines 5.3 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 Ubuntu.Components.ListItems 0.1
20import "../Components"
22Column {
23 id: root
24 anchors.centerIn: parent
25 spacing: units.gu(3.5)
27 property alias placeholderText: pinentryField.placeholderText
28 property int padWidth: units.gu(34)
29 property int padHeight: units.gu(28)
30 property int pinLength: 4
32 signal entered(string passphrase)
33 signal cancel()
35 property bool entryEnabled: true
37 function clear(playAnimation) {
38 pinentryField.text = "";
39 if (playAnimation) {
40 wrongPasswordAnimation.start();
41 }
42 }
45 UbuntuShape {
46 id: pinentryField
47 objectName: "pinentryField"
48 anchors.horizontalCenter: parent.horizontalCenter
49 color: "#55000000"
50 width:root.padWidth
51 height: units.gu(5)
52 radius: "medium"
53 property string text: ""
54 property string placeholderText: ""
55 onTextChanged: {
56 pinentryFieldLabel.text = "";
57 for (var i = 0; i < text.length; ++i) {
58 pinentryFieldLabel.text += "•";
59 }
60 if (text.length === root.pinLength) {
61 root.entered(text);
62 }
63 }
65 Label {
66 id: pinentryFieldLabel
67 anchors.centerIn: parent
68 font.pixelSize: units.dp(44)
69 color: "#f3f3e7"
70 opacity: 0.6
71 }
72 Label {
73 id: pinentryFieldPlaceHolder
74 anchors.centerIn: parent
75 color: "grey"
76 text: parent.placeholderText
77 visible: pinentryFieldLabel.text.length == 0
78 }
79 }
81 UbuntuShape {
82 anchors {
83 left: parent.left
84 right: parent.right
85 margins: (parent.width - root.padWidth) / 2
86 }
87 height: root.padHeight
88 color: "#55000000"
89 radius: "medium"
91 ThinDivider {
92 anchors {
93 left: parent.left
94 right: parent.right
95 top: parent.top
96 topMargin: root.padHeight / 4
97 }
98 }
99 ThinDivider {
100 anchors {
101 left: parent.left
102 right: parent.right
103 verticalCenter: parent.verticalCenter
104 }
105 }
106 ThinDivider {
107 anchors {
108 left: parent.left
109 right: parent.right
110 bottom: parent.bottom
111 bottomMargin: root.padHeight / 4
112 }
113 }
115 ThinDivider {
116 anchors.centerIn: parent
117 anchors.horizontalCenterOffset: -root.padWidth / 6
118 width: root.padHeight
119 rotation: -90
120 }
121 ThinDivider {
122 anchors.centerIn: parent
123 anchors.horizontalCenterOffset: root.padWidth / 6
124 width: root.padHeight
125 rotation: -90
126 }
128 Grid {
129 anchors {
130 left: parent.left
131 right: parent.right
132 margins: (parent.width - root.padWidth) / 2
133 }
135 columns: 3
137 Repeater {
138 model: 9
140 PinPadButton {
141 objectName: "pinPadButton" + (index + 1)
142 width: root.padWidth / 3
143 height: root.padHeight / 4
144 text: index + 1
145 enabled: entryEnabled
147 onClicked: {
148 pinentryField.text = pinentryField.text + text;
149 }
150 }
151 }
153 PinPadButton {
154 objectName: "pinPadButtonBack"
155 width: root.padWidth / 3
156 height: root.padHeight / 4
157 iconName: "back"
158 onClicked: root.cancel();
159 }
161 PinPadButton {
162 objectName: "pinPadButton0"
163 width: root.padWidth / 3
164 height: root.padHeight / 4
165 text: "0"
166 onClicked: pinentryField.text = pinentryField.text + text
167 enabled: entryEnabled
168 }
170 PinPadButton {
171 objectName: "pinPadButtonErase"
172 width: root.padWidth / 3
173 height: root.padHeight / 4
174 iconName: "erase"
175 onClicked: pinentryField.text = pinentryField.text.substring(0, pinentryField.text.length-1)
176 enabled: entryEnabled
177 }
178 }
179 }
181 WrongPasswordAnimation {
182 id: wrongPasswordAnimation
183 target: pinentryField
184 }