@@ -19,19 +19,16 @@ import Ubuntu.Components 0.1
19import Ubuntu.Components.ListItems 0.1
19import Ubuntu.Components.ListItems 0.1
20import "../Components"
20import "../Components"
27 property string infoText
25 property string infoText
28 property string retryText
26 property string retryText
29 property string errorText
27 property string errorText
30− property int padWidth: units.gu(34)
31− property int padHeight: units.gu(28)
32 property int minPinLength: -1
28 property int minPinLength: -1
33 property int maxPinLength: -1
29 property int maxPinLength: -1
34 property bool showCancelButton: true
30 property bool showCancelButton: true
31+ property color foregroundColor: "#000000"
36 readonly property string passphrase: pinentryField.text
33 readonly property string passphrase: pinentryField.text
@@ -49,180 +46,195 @@ Column {
52− id: shakeContainer
49+ anchors {
53− anchors.horizontalCenter: parent.horizontalCenter
50+ left: parent.left;
54− width: parent.width
51+ right: parent.right;
55− spacing: units.gu(1)
52+ verticalCenter: parent.verticalCenter;
56−
53+ verticalCenterOffset: Math.max(-units.gu(10), -(root.height - height) / 2) + units.gu(4)
59− objectName: "infoTextLabel"
62− anchors.horizontalCenter: parent.horizontalCenter
67− id: pinContainer
58+ id: shakeContainer
68− anchors { left: parent.left; right: parent.right; margins: units.gu(2) }
59+ anchors.horizontalCenter: parent.horizontalCenter
69− height: units.gu(4)
61+ spacing: units.gu(1)
72− id: pinentryField
64+ id: infoField
73− objectName: "pinentryField"
65+ objectName: "infoTextLabel"
67+ color: root.foregroundColor
74 anchors.horizontalCenter: parent.horizontalCenter
68 anchors.horizontalCenter: parent.horizontalCenter
75− anchors.verticalCenter: parent.verticalCenter
69+ text: root.infoText
76− spacing: Math.max(0, Math.min(units.gu(3), (parent.width / root.maxPinLength) - units.gu(3)))
79− property bool incorrectOverride: false
82− model: pinentryField.text.length
83− delegate: Rectangle {
85− width: Math.min(units.gu(2), (pinContainer.width - pinContainer.height*2 ) / (root.maxPinLength >= 0 ? root.maxPinLength : 16))
91− function appendNumber(number) {
72+ Item {
92− if (incorrectOverride) {
73+ id: pinContainer
93− incorrectOverride = false;
74+ anchors { left: parent.left; right: parent.right; margins: units.gu(2) }
79+ objectName: "pinentryField"
80+ anchors.horizontalCenter: parent.horizontalCenter
81+ anchors.verticalCenter: parent.verticalCenter
82+ spacing: Math.max(0, Math.min(units.gu(3), (parent.width / root.maxPinLength) - units.gu(3)))
85+ property bool incorrectOverride: false
88+ model: pinentryField.text.length
89+ delegate: Rectangle {
90+ color: root.foregroundColor
91+ width: Math.min(units.gu(2), (pinContainer.width - pinContainer.height*2 ) / (root.maxPinLength >= 0 ? root.maxPinLength : 16))
96− pinentryField.text = pinentryField.text + number
97+ function appendNumber(number) {
98+ if (incorrectOverride) {
99+ incorrectOverride = false;
102+ pinentryField.text = pinentryField.text + number
98− if (root.minPinLength > 0 && root.maxPinLength > 0
104+ if (root.minPinLength > 0 && root.maxPinLength > 0
99− && root.minPinLength == root.maxPinLength && pinentryField.text.length == root.minPinLength) {
105+ && root.minPinLength == root.maxPinLength && pinentryField.text.length == root.minPinLength) {
100− root.entered(pinentryField.text)
106+ root.entered(pinentryField.text)
104− function backspace() {
110+ function backspace() {
105− pinentryField.text = pinentryField.text.substring(0, pinentryField.text.length-1)
111+ pinentryField.text = pinentryField.text.substring(0, pinentryField.text.length-1)
115+ id: wrongNoticeLabel
116+ objectName: "wrongNoticeLabel"
118+ color: root.foregroundColor
119+ anchors.horizontalCenter: parent.horizontalCenter
120+ horizontalAlignment: Text.AlignHCenter
121+ text: root.errorText
122+ visible: pinentryField.incorrectOverride
123+ scale: Math.min(1, parent.width / width)
109− id: wrongNoticeLabel
110− objectName: "wrongNoticeLabel"
113− anchors.horizontalCenter: parent.horizontalCenter
114− horizontalAlignment: Text.AlignHCenter
115− text: root.errorText
116− visible: pinentryField.incorrectOverride
117− scale: Math.min(1, parent.width / width)
120− AbstractButton {
126+ AbstractButton {
121− objectName: "backspaceIcon"
127+ objectName: "backspaceIcon"
122− anchors { right: parent.right; top: parent.top; bottom: parent.bottom }
128+ anchors { right: parent.right; top: parent.top; bottom: parent.bottom }
123− width: height
129+ width: height
124− enabled: root.entryEnabled
130+ enabled: root.entryEnabled
127− anchors.fill: parent
133+ anchors.fill: parent
128− name: "erase"
134+ name: "erase"
129− color: "#f3f3e7"
135+ color: root.foregroundColor
132− opacity: (pinentryField.text.length > 0 && !pinentryField.incorrectOverride) ? 1 : 0
138+ opacity: (pinentryField.text.length > 0 && !pinentryField.incorrectOverride) ? 1 : 0
134− Behavior on opacity {
140+ Behavior on opacity {
135− UbuntuNumberAnimation {}
141+ UbuntuNumberAnimation {}
144+ onClicked: pinentryField.backspace()
138− onClicked: pinentryField.backspace()
148+ Label {
149+ objectName: "retryLabel"
151+ color: root.foregroundColor
152+ anchors.horizontalCenter: parent.horizontalCenter
153+ text: root.retryText || " "
142− Label {
157+ ThinDivider {
143− objectName: "retryLabel"
158+ anchors { left: parent.left; right: parent.right; margins: units.gu(2) }
146− anchors.horizontalCenter: parent.horizontalCenter
147− text: root.retryText || " "
152− anchors { left: parent.left; right: parent.right; margins: units.gu(2) }
157− anchors { horizontalCenter: parent.horizontalCenter }
160− property int buttonHeight: units.gu(8)
161− property int buttonWidth: units.gu(12)
163+ objectName: "numbersGrid"
164+ anchors { horizontalCenter: parent.horizontalCenter }
167+ property int maxWidth: Math.min(units.gu(50), root.width - units.gu(8))
168+ property int buttonWidth: maxWidth / 3
169+ property int buttonHeight: buttonWidth * 2 / 3
175+ objectName: "pinPadButton" + text
177+ height: numbersGrid.buttonHeight
178+ width: numbersGrid.buttonWidth
179+ foregroundColor: root.foregroundColor
180+ enabled: root.entryEnabled && (root.maxPinLength == -1 ||
181+ pinentryField.text.length < root.maxPinLength ||
182+ pinentryField.incorrectOverride)
185+ pinentryField.appendNumber(index + 1)
190+ height: numbersGrid.buttonHeight
191+ width: numbersGrid.buttonWidth
166 PinPadButton {
193 PinPadButton {
167− objectName: "pinPadButton" + text
194+ text: "0"
169 height: numbersGrid.buttonHeight
195 height: numbersGrid.buttonHeight
170 width: numbersGrid.buttonWidth
196 width: numbersGrid.buttonWidth
197+ foregroundColor: root.foregroundColor
171 enabled: root.entryEnabled && (root.maxPinLength == -1 ||
198 enabled: root.entryEnabled && (root.maxPinLength == -1 ||
172 pinentryField.text.length < root.maxPinLength ||
199 pinentryField.text.length < root.maxPinLength ||
173 pinentryField.incorrectOverride)
200 pinentryField.incorrectOverride)
175 onClicked: {
202 onClicked: {
176− pinentryField.appendNumber(index + 1)
203+ pinentryField.appendNumber(0)
181− height: numbersGrid.buttonHeight
182− width: numbersGrid.buttonWidth
186− height: numbersGrid.buttonHeight
207+ height: numbersGrid.buttonHeight
187− width: numbersGrid.buttonWidth
208+ width: numbersGrid.buttonWidth
188− enabled: root.entryEnabled && (root.maxPinLength == -1 ||
189− pinentryField.text.length < root.maxPinLength ||
190− pinentryField.incorrectOverride)
193− pinentryField.appendNumber(0)
197− height: numbersGrid.buttonHeight
198− width: numbersGrid.buttonWidth
200− PinPadButton {
210+ PinPadButton {
201− iconName: "close"
211+ iconName: "close"
202− height: units.gu(5) // visual spec has this row a little closer in
212+ height: units.gu(5) // visual spec has this row a little closer in
213+ width: numbersGrid.buttonWidth
214+ foregroundColor: root.foregroundColor
215+ onClicked: root.cancel()
216+ visible: root.showCancelButton
203− width: numbersGrid.buttonWidth
220+ width: numbersGrid.buttonWidth
224+ objectName: "confirmButton"
226+ width: numbersGrid.buttonWidth
227+ foregroundColor: root.foregroundColor
228+ enabled: root.enabled && pinentryField.text.length >= root.minPinLength
229+ visible: root.minPinLength == -1 || root.minPinLength !== root.maxPinLength
205− onClicked: root.cancel()
231+ onClicked: root.entered(pinentryField.text)
206− visible: root.showCancelButton
210− width: numbersGrid.buttonWidth
212− PinPadButton {
234+ WrongPasswordAnimation {
213− iconName: "tick"
235+ id: wrongPasswordAnimation
214− objectName: "confirmButton"
236+ objectName: "wrongPasswordAnimation"
215− height: units.gu(5)
237+ target: shakeContainer
216− width: numbersGrid.buttonWidth
217− enabled: root.enabled && pinentryField.text.length >= root.minPinLength
218− visible: root.minPinLength == -1 || root.minPinLength !== root.maxPinLength
220− onClicked: root.entered(pinentryField.text)
223− WrongPasswordAnimation {
224− id: wrongPasswordAnimation
225− objectName: "wrongPasswordAnimation"
226− target: shakeContainer