2 * Copyright (C) 2013 Canonical, Ltd.
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.
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.
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/>.
18import Ubuntu.Components 0.1
19import Ubuntu.Components.ListItems 0.1
24 anchors.centerIn: parent
25 spacing: units.gu(3.5)
27 property alias placeholderText: pinentryField.placeholderText
28 property alias wrongPlaceholderText: pinentryField.wrongPlaceholderText
29 property int padWidth: units.gu(34)
30 property int padHeight: units.gu(28)
31 property int minPinLength: -1
32 property int maxPinLength: -1
34 signal entered(string passphrase)
37 property bool entryEnabled: true
39 function clear(playAnimation) {
40 pinentryField.text = "";
42 wrongPasswordAnimation.start();
48 property bool autoConfirm: root.minPinLength == root.maxPinLength && root.minPinLength != -1
53 objectName: "pinentryField"
54 anchors.horizontalCenter: parent.horizontalCenter
59 property string text: ""
60 property string placeholderText: ""
61 property string wrongPlaceholderText: ""
63 function appendChar(character) {
64 if (root.maxPinLength == -1 || pinentryField.text.length < root.maxPinLength) {
65 pinentryField.text = pinentryField.text + character;
70 pinentryFieldLabel.text = "";
71 for (var i = 0; i < text.length; ++i) {
72 pinentryFieldLabel.text += "•";
74 if (priv.autoConfirm && text.length === root.maxPinLength) {
80 id: pinentryFieldLabel
81 anchors.centerIn: parent
82 width: parent.width - (backspaceIcon.width + backspaceIcon.anchors.rightMargin) * 2
83 elide: Text.ElideMiddle
84 horizontalAlignment: Text.AlignHCenter
85 font.pixelSize: units.dp(44)
90 id: pinentryFieldPlaceHolder
91 objectName: "pinentryFieldPlaceHolder"
92 anchors.centerIn: parent
95 text: wrongPasswordAnimation.running ? parent.wrongPlaceholderText : parent.placeholderText
96 visible: pinentryFieldLabel.text.length == 0
101 objectName: "backspaceIcon"
104 topMargin: units.gu(1)
106 rightMargin: units.gu(2)
107 bottom: parent.bottom
108 bottomMargin: units.gu(1)
110 visible: !priv.autoConfirm
117 onClicked: pinentryField.text = pinentryField.text.substring(0, pinentryField.text.length-1);
126 margins: (parent.width - root.padWidth) / 2
128 height: root.padHeight
137 topMargin: root.padHeight / 4
144 verticalCenter: parent.verticalCenter
151 bottom: parent.bottom
152 bottomMargin: root.padHeight / 4
157 anchors.centerIn: parent
158 anchors.horizontalCenterOffset: -root.padWidth / 6
159 width: root.padHeight
163 anchors.centerIn: parent
164 anchors.horizontalCenterOffset: root.padWidth / 6
165 width: root.padHeight
173 margins: (parent.width - root.padWidth) / 2
182 objectName: "pinPadButton" + (index + 1)
183 width: root.padWidth / 3
184 height: root.padHeight / 4
186 enabled: entryEnabled
189 pinentryField.appendChar(text);
195 objectName: "pinPadButtonBack"
196 width: root.padWidth / 3
197 height: root.padHeight / 4
198 subText: i18n.tr("CANCEL")
199 onClicked: root.cancel();
203 objectName: "pinPadButton0"
204 width: root.padWidth / 3
205 height: root.padHeight / 4
207 onClicked: pinentryField.appendChar(text);
208 enabled: entryEnabled
212 objectName: "pinPadButtonErase"
213 width: root.padWidth / 3
214 height: root.padHeight / 4
215 iconName: priv.autoConfirm ? "erase" : ""
216 subText: priv.autoConfirm ? "" : i18n.tr("DONE")
218 if (priv.autoConfirm) {
219 pinentryField.text = pinentryField.text.substring(0, pinentryField.text.length-1);
221 root.entered(pinentryField.text);
224 enabled: priv.autoConfirm ? entryEnabled : pinentryField.text.length >= root.minPinLength
229 WrongPasswordAnimation {
230 id: wrongPasswordAnimation
231 objectName: "wrongPasswordAnimation"
232 target: pinentryField
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list