on xenial help sign in
enable HW keyboard usage, turn everything into proper FocusScopes
743da53Lukáš Tinkl
qml/Components/Lockscreen.qml+80−96
@@ -69,8 +69,6 @@ Showable {
69 signal emergencyCall()
69 signal emergencyCall()
70 signal infoPopupConfirmed()
70 signal infoPopupConfirmed()
71
71
72− onActiveFocusChanged: if (activeFocus && pinPadLoader.item) pinPadLoader.item.forceActiveFocus()
73−
74 function reset() {
72 function reset() {
75 // This causes the loader below to destry and recreate the source
73 // This causes the loader below to destry and recreate the source
76 pinPadLoader.resetting = true;
74 pinPadLoader.resetting = true;
@@ -121,108 +119,94 @@ Showable {
121 opacity: root.darkenBackground
119 opacity: root.darkenBackground
122 }
120 }
123
121
124− MouseArea {
122+ Loader {
125− anchors.fill: root
123+ id: pinPadLoader
126− onClicked: {
124+ objectName: "pinPadLoader"
127− if (pinPadLoader.item)
128− pinPadLoader.item.forceActiveFocus()
129− }
130− }
131−
132− FocusScope {
133− id: loaderScope
134 anchors.fill: parent
125 anchors.fill: parent
135−
136− Loader {
137− id: pinPadLoader
138− objectName: "pinPadLoader"
139− anchors.fill: parent
140− property bool resetting: false
126+ property bool resetting: false
141− property bool waiting: false
127+ property bool waiting: false
142− property bool showWrongText: false
128+ property bool showWrongText: false
143−
129+ focus: true
130+
144− source: {
131+ source: {
145− if (resetting || !root.required) {
132+ if (resetting || !root.required) {
146− return ""
133+ return ""
147− } else if (root.delayMinutes > 0) {
134+ } else if (root.delayMinutes > 0) {
148− return "DelayedLockscreen.qml"
135+ return "DelayedLockscreen.qml"
149− } else if (root.alphaNumeric) {
136+ } else if (root.alphaNumeric) {
150− return "PassphraseLockscreen.qml"
137+ return "PassphraseLockscreen.qml"
151− } else {
138+ } else {
152− return "PinLockscreen.qml"
139+ return "PinLockscreen.qml"
153− }
154 }
140 }
141+ }
155− onSourceChanged: {
142+ onSourceChanged: {
156− waiting = false
143+ waiting = false
157− showWrongText = false
144+ showWrongText = false
158− if (loaderScope.activeFocus && pinPadLoader.item)
159− pinPadLoader.item.forceActiveFocus()
160− }
145+ }
161−
162− Connections {
163− target: pinPadLoader.item
164
146
165− onEntered: {
147+ Connections {
166− pinPadLoader.waiting = true
148+ target: pinPadLoader.item
167− root.entered(passphrase);
168− }
169
149
170− onCancel: {
150+ onEntered: {
171− root.cancel()
151+ pinPadLoader.waiting = true
172− }
152+ root.entered(passphrase);
173 }
153 }
174
154
175− Binding {
155+ onCancel: {
176− target: pinPadLoader.item
156+ root.cancel()
177− property: "minPinLength"
178− value: root.minPinLength
179− }
180− Binding {
181− target: pinPadLoader.item
182− property: "maxPinLength"
183− value: root.maxPinLength
184− }
185− Binding {
186− target: pinPadLoader.item
187− property: "infoText"
188− value: root.infoText
189− }
190− Binding {
191− target: pinPadLoader.item
192− property: "retryText"
193− value: root.retryText
194− }
195− Binding {
196− target: pinPadLoader.item
197− property: "errorText"
198− value: pinPadLoader.showWrongText ? root.errorText : ""
199− }
200− Binding {
201− target: pinPadLoader.item
202− property: "entryEnabled"
203− value: !pinPadLoader.waiting
204− }
205− Binding {
206− target: pinPadLoader.item
207− property: "alphaNumeric"
208− value: root.alphaNumeric
209− }
210− Binding {
211− target: pinPadLoader.item
212− property: "delayMinutes"
213− value: root.delayMinutes
214− }
215− Binding {
216− target: pinPadLoader.item
217− property: "showCancelButton"
218− value: root.showCancelButton
219− }
220− Binding {
221− target: pinPadLoader.item
222− property: "foregroundColor"
223− value: root.foregroundColor
224 }
157 }
225 }
158 }
159+
160+ Binding {
161+ target: pinPadLoader.item
162+ property: "minPinLength"
163+ value: root.minPinLength
164+ }
165+ Binding {
166+ target: pinPadLoader.item
167+ property: "maxPinLength"
168+ value: root.maxPinLength
169+ }
170+ Binding {
171+ target: pinPadLoader.item
172+ property: "infoText"
173+ value: root.infoText
174+ }
175+ Binding {
176+ target: pinPadLoader.item
177+ property: "retryText"
178+ value: root.retryText
179+ }
180+ Binding {
181+ target: pinPadLoader.item
182+ property: "errorText"
183+ value: pinPadLoader.showWrongText ? root.errorText : ""
184+ }
185+ Binding {
186+ target: pinPadLoader.item
187+ property: "entryEnabled"
188+ value: !pinPadLoader.waiting
189+ }
190+ Binding {
191+ target: pinPadLoader.item
192+ property: "alphaNumeric"
193+ value: root.alphaNumeric
194+ }
195+ Binding {
196+ target: pinPadLoader.item
197+ property: "delayMinutes"
198+ value: root.delayMinutes
199+ }
200+ Binding {
201+ target: pinPadLoader.item
202+ property: "showCancelButton"
203+ value: root.showCancelButton
204+ }
205+ Binding {
206+ target: pinPadLoader.item
207+ property: "foregroundColor"
208+ value: root.foregroundColor
209+ }
226 }
210 }
227
211
228 Item {
212 Item {
qml/Components/PinLockscreen.qml+16−1
@@ -19,8 +19,9 @@ import Ubuntu.Components 1.3
19import Ubuntu.Components.ListItems 1.3
19import Ubuntu.Components.ListItems 1.3
20import "../Components"
20import "../Components"
21
21
22−Item {
22+FocusScope {
23 id: root
23 id: root
24+ focus: true
24
25
25 property string infoText
26 property string infoText
26 property string retryText
27 property string retryText
@@ -45,6 +46,19 @@ Item {
45 }
46 }
46 }
47 }
47
48
49+ Keys.onPressed: {
50+ if (event.key === Qt.Key_Backspace) {
51+ pinentryField.backspace();
52+ } else if (event.key === Qt.Key_Delete) {
53+ closeButton.clicked()
54+ } else {
55+ var digit = parseInt(event.text)
56+ if (!isNaN(digit) && typeof digit == "number") {
57+ pinentryField.appendNumber(digit);
58+ }
59+ }
60+ }
61+
48 Column {
62 Column {
49 anchors {
63 anchors {
50 left: parent.left;
64 left: parent.left;
@@ -204,6 +218,7 @@ Item {
204 width: numbersGrid.buttonWidth
218 width: numbersGrid.buttonWidth
205 }
219 }
206 PinPadButton {
220 PinPadButton {
221+ id: closeButton
207 iconName: "close"
222 iconName: "close"
208 height: units.gu(5) // visual spec has this row a little closer in
223 height: units.gu(5) // visual spec has this row a little closer in
209 width: numbersGrid.buttonWidth
224 width: numbersGrid.buttonWidth