Merge lp:~mikemc/ubuntuone-credentials/fix-tabloop into lp:ubuntuone-credentials

Proposed by Mike McCracken
Status: Merged
Approved by: dobey
Approved revision: 61
Merged at revision: 61
Proposed branch: lp:~mikemc/ubuntuone-credentials/fix-tabloop
Merge into: lp:ubuntuone-credentials
Diff against target: 138 lines (+25/-5)
4 files modified
online-accounts-provider/LoginForm.qml (+8/-1)
online-accounts-provider/Main.qml (+1/-2)
online-accounts-provider/NewAccount.qml (+6/-2)
online-accounts-provider/RegisterForm.qml (+10/-0)
To merge this branch: bzr merge lp:~mikemc/ubuntuone-credentials/fix-tabloop
Reviewer Review Type Date Requested Status
dobey (community) Approve
Roberto Alsina (community) Approve
Review via email: mp+185566@code.launchpad.net

Commit message

- Fix key focus handling.

Description of the change

- Fix key focus handling.

Fixes initial key focus on email text field
Fixes tab loop between text fields
Fixes focus switching when changing between login/register modes.

NOTE: this just always sets the focus to the first field below the switch when you change the switch.
that might be annoying if you haven't finished typing your email yet, but I think if you've hit the switch you're probably done with the email.
I'm open to dissenting opinions...

To post a comment you must log in.
Revision history for this message
Roberto Alsina (ralsina) :
review: Approve
Revision history for this message
dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'online-accounts-provider/LoginForm.qml'
2--- online-accounts-provider/LoginForm.qml 2013-09-06 16:55:47 +0000
3+++ online-accounts-provider/LoginForm.qml 2013-09-13 18:34:16 +0000
4@@ -5,6 +5,10 @@
5 id: loginFormColumn
6 spacing: units.gu(2)
7
8+ /* export two aliases for KeyNavigation access*/
9+ property alias passwordTextField: passwordTextField
10+ property alias twoFactorTextField: twoFactorTextField
11+
12 property alias password: passwordTextField.text
13 property alias twoFactorVisible: twoFactorUI.visible
14 property alias twoFactorCode: twoFactorTextField.text
15@@ -21,6 +25,8 @@
16 width: main.width - (2 * main.anchors.margins)
17
18 Keys.onReturnPressed: main.processForm();
19+ KeyNavigation.tab: twoFactorUI.visible ? twoFactorTextField : emailTextField /* from main */
20+ KeyNavigation.backtab: emailTextField /* from main */
21 }
22
23 Label {
24@@ -50,11 +56,12 @@
25 id: twoFactorTextField
26 placeholderText: "2-factor device code"
27 echoMode: TextInput.Password
28- focus: true
29 width: main.width - (2 * main.anchors.margins)
30 Keys.onReturnPressed: {
31 main.processForm();
32 }
33+ KeyNavigation.tab: emailTextField
34+ KeyNavigation.backtab: passwordTextField
35 }
36
37 Label {
38
39=== modified file 'online-accounts-provider/Main.qml'
40--- online-accounts-provider/Main.qml 2013-09-12 14:59:06 +0000
41+++ online-accounts-provider/Main.qml 2013-09-13 18:34:16 +0000
42@@ -50,13 +50,12 @@
43 This will not be necessary once Bug #1221845 is fixed.
44 */
45 rootFlickable.parent.parent.flickable = rootFlickable;
46-
47 }
48
49 Connections {
50 target: account
51 onSynced: {
52- console.debug("Account id " + account.accountId + "synced. account.displayName: " + account.displayName)
53+ console.debug("Account id " + account.accountId + " synced. account.displayName: " + account.displayName)
54 }
55 }
56
57
58=== modified file 'online-accounts-provider/NewAccount.qml'
59--- online-accounts-provider/NewAccount.qml 2013-09-12 14:59:06 +0000
60+++ online-accounts-provider/NewAccount.qml 2013-09-13 18:34:16 +0000
61@@ -76,12 +76,13 @@
62 TextField {
63 id: emailTextField
64 placeholderText: "Your email"
65- focus: true;
66-
67 width: main.width - (2 * main.anchors.margins)
68 anchors.left: parent.left
69 anchors.margins: parent.anchors.margins
70 validator: RegExpValidator { regExp: /.+@.+/ }
71+ focus: true
72+ KeyNavigation.tab: loginForm.visible ? loginForm.passwordTextField : registerForm.nameTextField
73+ KeyNavigation.backtab: loginForm.visible ? ( loginForm.twoFactorVisible ? loginForm.twoFactorTextField : loginForm.passwordTextField) : registerForm.confirmPasswordTextField
74 }
75
76 Row {
77@@ -154,6 +155,7 @@
78 state = "login";
79 switchTo(loginForm);
80 formValid = false;
81+ emailTextField.forceActiveFocus();
82 }
83
84 function showError(message) {
85@@ -172,9 +174,11 @@
86 if(state == "login") {
87 switchTo(registerForm)
88 state = "register";
89+ registerForm.nameTextField.focus = true;
90 } else if(state == "register") {
91 switchTo(loginForm)
92 state = "login";
93+ loginForm.passwordTextField.focus = true;
94 } else {
95 console.debug("unexpected state" + state + "in toggleNewUser");
96 }
97
98=== modified file 'online-accounts-provider/RegisterForm.qml'
99--- online-accounts-provider/RegisterForm.qml 2013-09-06 16:55:47 +0000
100+++ online-accounts-provider/RegisterForm.qml 2013-09-13 18:34:16 +0000
101@@ -5,6 +5,10 @@
102 id: registerFormColumn
103 spacing: units.gu(2)
104
105+ /* export two aliases for KeyNavigation access*/
106+ property alias nameTextField: nameTextField
107+ property alias confirmPasswordTextField: confirmPasswordTextField
108+
109 property alias password: passwordTextField.text
110 property alias display_name: nameTextField.text
111
112@@ -17,6 +21,8 @@
113 id: nameTextField
114 placeholderText: "Your name"
115 width: main.width - (2 * main.anchors.margins)
116+ KeyNavigation.tab: passwordTextField
117+ KeyNavigation.backtab: emailTextField /* from main */
118 }
119
120 TextField {
121@@ -24,6 +30,8 @@
122 placeholderText: "Password with at least 8 characters"
123 echoMode: TextInput.Password
124 width: main.width - (2 * main.anchors.margins)
125+ KeyNavigation.tab: confirmPasswordTextField
126+ KeyNavigation.backtab: nameTextField
127 }
128
129 TextField {
130@@ -31,6 +39,8 @@
131 placeholderText: "Re-type password"
132 echoMode: TextInput.Password
133 width: main.width - (2 * main.anchors.margins)
134+ KeyNavigation.tab: emailTextField /* from main */
135+ KeyNavigation.backtab: passwordTextField
136 }
137
138 Row {

Subscribers

People subscribed via source and target branches

to all changes: