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
27 property string infoText
28 property string retryText
29 property string errorText
30 property int padWidth: units.gu(34)
31 property int padHeight: units.gu(28)
32 property int minPinLength: -1
33 property int maxPinLength: -1
34 property bool showCancelButton: true
36 signal entered(string passphrase)
39 property bool entryEnabled: true
41 function clear(showAnimation) {
42 pinentryField.text = "";
44 pinentryField.incorrectOverride = true;
45 wrongPasswordAnimation.start();
51 anchors.horizontalCenter: parent.horizontalCenter
57 objectName: "infoTextLabel"
60 anchors.horizontalCenter: parent.horizontalCenter
66 anchors { left: parent.left; right: parent.right; margins: units.gu(2) }
71 objectName: "pinentryField"
72 anchors.horizontalCenter: parent.horizontalCenter
73 anchors.verticalCenter: parent.verticalCenter
74 spacing: Math.max(0, Math.min(units.gu(3), (parent.width / root.maxPinLength) - units.gu(3)))
77 property bool incorrectOverride: false
80 model: pinentryField.text.length
83 width: Math.min(units.gu(2), (pinContainer.width - pinContainer.height*2 ) / (root.maxPinLength >= 0 ? root.maxPinLength : 16))
89 function appendNumber(number) {
90 if (incorrectOverride) {
91 incorrectOverride = false;
94 pinentryField.text = pinentryField.text + number
96 if (root.minPinLength > 0 && root.maxPinLength > 0
97 && root.minPinLength == root.maxPinLength && pinentryField.text.length == root.minPinLength) {
98 root.entered(pinentryField.text)
102 function backspace() {
103 pinentryField.text = pinentryField.text.substring(0, pinentryField.text.length-1)
108 objectName: "wrongNoticeLabel"
111 anchors.horizontalCenter: parent.horizontalCenter
112 horizontalAlignment: Text.AlignHCenter
114 visible: pinentryField.incorrectOverride
118 objectName: "backspaceIcon"
119 anchors { right: parent.right; top: parent.top; bottom: parent.bottom }
128 opacity: (pinentryField.text.length && !pinentryField.incorrectOverride) > 0 ? 1 : 0
130 Behavior on opacity {
131 UbuntuNumberAnimation {}
134 onClicked: pinentryField.backspace()
139 objectName: "retryLabel"
142 anchors.horizontalCenter: parent.horizontalCenter
143 text: root.retryText || " "
148 anchors { left: parent.left; right: parent.right; margins: units.gu(2) }
153 anchors { horizontalCenter: parent.horizontalCenter }
156 property int buttonHeight: units.gu(8)
157 property int buttonWidth: units.gu(12)
163 objectName: "pinPadButton" + text
165 height: numbersGrid.buttonHeight
166 width: numbersGrid.buttonWidth
167 enabled: root.entryEnabled && (root.maxPinLength == -1 ||
168 pinentryField.text.length < root.maxPinLength ||
169 pinentryField.incorrectOverride)
172 pinentryField.appendNumber(index + 1)
177 height: numbersGrid.buttonHeight
178 width: numbersGrid.buttonWidth
182 height: numbersGrid.buttonHeight
183 width: numbersGrid.buttonWidth
184 enabled: root.entryEnabled && (root.maxPinLength == -1 ||
185 pinentryField.text.length < root.maxPinLength ||
186 pinentryField.incorrectOverride)
189 pinentryField.appendNumber(0)
193 height: numbersGrid.buttonHeight
194 width: numbersGrid.buttonWidth
198 height: numbersGrid.buttonHeight
199 width: numbersGrid.buttonWidth
201 onClicked: root.cancel()
202 visible: root.showCancelButton
205 height: numbersGrid.buttonHeight
206 width: numbersGrid.buttonWidth
210 objectName: "confirmButton"
211 height: numbersGrid.buttonHeight
212 width: numbersGrid.buttonWidth
213 enabled: root.enabled && pinentryField.text.length >= root.minPinLength
214 visible: root.minPinLength == -1 || root.minPinLength !== root.maxPinLength
216 onClicked: root.entered(pinentryField.text)
219 WrongPasswordAnimation {
220 id: wrongPasswordAnimation
221 objectName: "wrongPasswordAnimation"
222 target: shakeContainer
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