on 5bc8421 help sign in
unity8/Greeter/PinLockscreen.qml
180 lines 5.1 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 function clear(playAnimation) {
36 pinentryField.text = "";
37 if (playAnimation) {
38 wrongPasswordAnimation.start();
39 }
40 }
43 UbuntuShape {
44 id: pinentryField
45 objectName: "pinentryField"
46 anchors.horizontalCenter: parent.horizontalCenter
47 color: "#55000000"
48 width:root.padWidth
49 height: units.gu(5)
50 radius: "medium"
51 property string text: ""
52 property string placeholderText: ""
53 onTextChanged: {
54 pinentryFieldLabel.text = "";
55 for (var i = 0; i < text.length; ++i) {
56 pinentryFieldLabel.text += "•";
57 }
58 if (text.length === root.pinLength) {
59 root.entered(text);
60 }
61 }
63 Label {
64 id: pinentryFieldLabel
65 anchors.centerIn: parent
66 font.pixelSize: units.dp(44)
67 color: "#f3f3e7"
68 opacity: 0.6
69 }
70 Label {
71 id: pinentryFieldPlaceHolder
72 anchors.centerIn: parent
73 color: "grey"
74 text: parent.placeholderText
75 visible: pinentryFieldLabel.text.length == 0
76 }
77 }
79 UbuntuShape {
80 anchors {
81 left: parent.left
82 right: parent.right
83 margins: (parent.width - root.padWidth) / 2
84 }
85 height: root.padHeight
86 color: "#55000000"
87 radius: "medium"
89 ThinDivider {
90 anchors {
91 left: parent.left
92 right: parent.right
93 top: parent.top
94 topMargin: root.padHeight / 4
95 }
96 }
97 ThinDivider {
98 anchors {
99 left: parent.left
100 right: parent.right
101 verticalCenter: parent.verticalCenter
102 }
103 }
104 ThinDivider {
105 anchors {
106 left: parent.left
107 right: parent.right
108 bottom: parent.bottom
109 bottomMargin: root.padHeight / 4
110 }
111 }
113 ThinDivider {
114 anchors.centerIn: parent
115 anchors.horizontalCenterOffset: -root.padWidth / 6
116 width: root.padHeight
117 rotation: -90
118 }
119 ThinDivider {
120 anchors.centerIn: parent
121 anchors.horizontalCenterOffset: root.padWidth / 6
122 width: root.padHeight
123 rotation: -90
124 }
126 Grid {
127 anchors {
128 left: parent.left
129 right: parent.right
130 margins: (parent.width - root.padWidth) / 2
131 }
133 columns: 3
135 Repeater {
136 model: 9
138 PinPadButton {
139 objectName: "pinPadButton" + (index + 1)
140 width: root.padWidth / 3
141 height: root.padHeight / 4
142 text: index + 1
144 onClicked: {
145 pinentryField.text = pinentryField.text + text;
146 }
147 }
148 }
150 PinPadButton {
151 objectName: "pinPadButtonBack"
152 width: root.padWidth / 3
153 height: root.padHeight / 4
154 iconName: "back"
155 onClicked: root.cancel();
156 }
158 PinPadButton {
159 objectName: "pinPadButton0"
160 width: root.padWidth / 3
161 height: root.padHeight / 4
162 text: "0"
163 onClicked: pinentryField.text = pinentryField.text + text
164 }
166 PinPadButton {
167 objectName: "pinPadButtonErase"
168 width: root.padWidth / 3
169 height: root.padHeight / 4
170 iconName: "erase"
171 onClicked: pinentryField.text = pinentryField.text.substring(0, pinentryField.text.length-1)
172 }
173 }
174 }
176 WrongPasswordAnimation {
177 id: wrongPasswordAnimation
178 target: pinentryField
179 }