on xenial help sign in
enable HW keyboard usage, turn everything into proper FocusScopes
commit743da53aadcaf7165df31e171f506d53bee84b58 authorLukáš Tinkl <lukas.tinkl@canonical.com> dateFri 26 Feb 2016, 16:47 (11 years ago) parentcab5d9c
2 files changed+96−97
qml/Components/Lockscreen.qml+80−96 qml/Components/PinLockscreen.qml+16−1
qml/Components/Lockscreen.qml+80−96
@@ -69,8 +69,6 @@ Showable {
6969 signal emergencyCall()
7070 signal infoPopupConfirmed()
7171
72− onActiveFocusChanged: if (activeFocus && pinPadLoader.item) pinPadLoader.item.forceActiveFocus()
73−
7472 function reset() {
7573 // This causes the loader below to destry and recreate the source
7674 pinPadLoader.resetting = true;
@@ -121,108 +119,94 @@ Showable {
121119 opacity: root.darkenBackground
122120 }
123121
124− MouseArea {
125− anchors.fill: root
126− onClicked: {
127− if (pinPadLoader.item)
128− pinPadLoader.item.forceActiveFocus()
129− }
130− }
131−
132− FocusScope {
133− id: loaderScope
122+ Loader {
123+ id: pinPadLoader
124+ objectName: "pinPadLoader"
134125 anchors.fill: parent
135−
136− Loader {
137− id: pinPadLoader
138− objectName: "pinPadLoader"
139− anchors.fill: parent
140− property bool resetting: false
141− property bool waiting: false
142− property bool showWrongText: false
143−
144− source: {
145− if (resetting || !root.required) {
146− return ""
147− } else if (root.delayMinutes > 0) {
148− return "DelayedLockscreen.qml"
149− } else if (root.alphaNumeric) {
150− return "PassphraseLockscreen.qml"
151− } else {
152− return "PinLockscreen.qml"
153− }
126+ property bool resetting: false
127+ property bool waiting: false
128+ property bool showWrongText: false
129+ focus: true
130+
131+ source: {
132+ if (resetting || !root.required) {
133+ return ""
134+ } else if (root.delayMinutes > 0) {
135+ return "DelayedLockscreen.qml"
136+ } else if (root.alphaNumeric) {
137+ return "PassphraseLockscreen.qml"
138+ } else {
139+ return "PinLockscreen.qml"
154140 }
155− onSourceChanged: {
156− waiting = false
157− showWrongText = false
158− if (loaderScope.activeFocus && pinPadLoader.item)
159− pinPadLoader.item.forceActiveFocus()
160− }
161−
162− Connections {
163− target: pinPadLoader.item
141+ }
142+ onSourceChanged: {
143+ waiting = false
144+ showWrongText = false
145+ }
164146
165− onEntered: {
166− pinPadLoader.waiting = true
167− root.entered(passphrase);
168− }
147+ Connections {
148+ target: pinPadLoader.item
169149
170− onCancel: {
171− root.cancel()
172− }
150+ onEntered: {
151+ pinPadLoader.waiting = true
152+ root.entered(passphrase);
173153 }
174154
175− Binding {
176− target: pinPadLoader.item
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
155+ onCancel: {
156+ root.cancel()
224157 }
225158 }
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+ }
226210 }
227211
228212 Item {
qml/Components/PinLockscreen.qml+16−1
@@ -19,8 +19,9 @@ import Ubuntu.Components 1.3
1919import Ubuntu.Components.ListItems 1.3
2020import "../Components"
2121
22−Item {
22+FocusScope {
2323 id: root
24+ focus: true
2425
2526 property string infoText
2627 property string retryText
@@ -45,6 +46,19 @@ Item {
4546 }
4647 }
4748
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+
4862 Column {
4963 anchors {
5064 left: parent.left;
@@ -204,6 +218,7 @@ Item {
204218 width: numbersGrid.buttonWidth
205219 }
206220 PinPadButton {
221+ id: closeButton
207222 iconName: "close"
208223 height: units.gu(5) // visual spec has this row a little closer in
209224 width: numbersGrid.buttonWidth