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 int padWidth: units.gu(34)
29 property int padHeight: units.gu(28)
30 property int minPinLength: -1
31 property int maxPinLength: -1
33 signal entered(string passphrase)
36 property bool entryEnabled: true
38 function clear(playAnimation) {
39 pinentryField.text = "";
41 wrongPasswordAnimation.start();
47 property bool autoConfirm: root.minPinLength == root.maxPinLength && root.minPinLength != -1
52 objectName: "pinentryField"
53 anchors.horizontalCenter: parent.horizontalCenter
58 property string text: ""
59 property string placeholderText: ""
61 function appendChar(character) {
62 if (root.maxPinLength == -1 || pinentryField.text.length < root.maxPinLength) {
63 pinentryField.text = pinentryField.text + character;
68 pinentryFieldLabel.text = "";
69 for (var i = 0; i < text.length; ++i) {
70 pinentryFieldLabel.text += "•";
72 if (priv.autoConfirm && text.length === root.maxPinLength) {
78 id: pinentryFieldLabel
79 anchors.centerIn: parent
80 width: parent.width - (backspaceIcon.width + backspaceIcon.anchors.rightMargin) * 2
81 elide: Text.ElideMiddle
82 horizontalAlignment: Text.AlignHCenter
83 font.pixelSize: units.dp(44)
88 id: pinentryFieldPlaceHolder
89 objectName: "pinentryFieldPlaceHolder"
90 anchors.centerIn: parent
91 horizontalAlignment: Text.AlignHCenter
94 text: parent.placeholderText
95 visible: pinentryFieldLabel.text.length == 0
100 objectName: "backspaceIcon"
103 topMargin: units.gu(1)
105 rightMargin: units.gu(2)
106 bottom: parent.bottom
107 bottomMargin: units.gu(1)
109 visible: entryEnabled && !priv.autoConfirm
116 onClicked: pinentryField.text = pinentryField.text.substring(0, pinentryField.text.length-1);
125 margins: (parent.width - root.padWidth) / 2
127 height: root.padHeight
136 topMargin: root.padHeight / 4
143 verticalCenter: parent.verticalCenter
150 bottom: parent.bottom
151 bottomMargin: root.padHeight / 4
156 anchors.centerIn: parent
157 anchors.horizontalCenterOffset: -root.padWidth / 6
158 width: root.padHeight
162 anchors.centerIn: parent
163 anchors.horizontalCenterOffset: root.padWidth / 6
164 width: root.padHeight
172 margins: (parent.width - root.padWidth) / 2
181 objectName: "pinPadButton" + (index + 1)
182 width: root.padWidth / 3
183 height: root.padHeight / 4
185 enabled: entryEnabled
188 pinentryField.appendChar(text);
194 objectName: "pinPadButtonBack"
195 width: root.padWidth / 3
196 height: root.padHeight / 4
197 subText: i18n.tr("CANCEL")
198 onClicked: root.cancel();
202 objectName: "pinPadButton0"
203 width: root.padWidth / 3
204 height: root.padHeight / 4
206 onClicked: pinentryField.appendChar(text);
207 enabled: entryEnabled
211 objectName: "pinPadButtonErase"
212 width: root.padWidth / 3
213 height: root.padHeight / 4
214 iconName: priv.autoConfirm ? "erase" : ""
215 subText: priv.autoConfirm ? "" : i18n.tr("DONE")
217 if (priv.autoConfirm) {
218 pinentryField.text = pinentryField.text.substring(0, pinentryField.text.length-1);
220 root.entered(pinentryField.text);
223 enabled: priv.autoConfirm ? entryEnabled : pinentryField.text.length >= root.minPinLength
228 WrongPasswordAnimation {
229 id: wrongPasswordAnimation
230 objectName: "wrongPasswordAnimation"
231 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