18 import Ubuntu.Components 0.1
19 import Ubuntu.Components.ListItems 0.1
20 import
"../Components"
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