Merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/spaceTriggerButton into lp:ubuntu-ui-toolkit/staging

Proposed by Christian Dywan
Status: Merged
Approved by: Zsombor Egri
Approved revision: 1747
Merged at revision: 1756
Proposed branch: lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/spaceTriggerButton
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 66 lines (+23/-3)
3 files modified
src/Ubuntu/Components/plugin/ucabstractbutton.cpp (+2/-3)
src/Ubuntu/Components/plugin/ucactionitem.cpp (+1/-0)
tests/unit_x11/tst_components/tst_focus.qml (+20/-0)
To merge this branch: bzr merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/spaceTriggerButton
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Zsombor Egri Approve
Review via email: mp+279898@code.launchpad.net

Commit message

Enter/Return/Space should trigger() Button

To post a comment you must log in.
Revision history for this message
Zsombor Egri (zsombi) wrote :

One small thing inline. It's pretty crap that moc compiler doesn't warn you when emit on a slot.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1744. By Christian Dywan

Emit the triggered signal, not the slot

This is the same as we do in UCActionItem

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1745. By Christian Dywan

Allow overriding trigger function in AbstractButton

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Zsombor Egri (zsombi) wrote :

More.

review: Needs Fixing
1746. By Christian Dywan

Call ActionItem.trigger directly

1747. By Christian Dywan

Add FIXME with bug number for trigger

Revision history for this message
Zsombor Egri (zsombi) wrote :

Ok, I'll patch it once I'm ready with the fix.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Ubuntu/Components/plugin/ucabstractbutton.cpp'
2--- src/Ubuntu/Components/plugin/ucabstractbutton.cpp 2015-12-05 05:59:07 +0000
3+++ src/Ubuntu/Components/plugin/ucabstractbutton.cpp 2015-12-11 12:39:17 +0000
4@@ -138,10 +138,9 @@
5 switch (event->key()) {
6 case Qt::Key_Enter:
7 case Qt::Key_Return:
8- // FIXME: space may also come here, however that depends on the button type
9- // (i.e default Dialog btn) so we may need to add that to Button
10+ case Qt::Key_Space:
11 {
12- Q_EMIT clicked();
13+ trigger();
14 break;
15 }
16 }
17
18=== modified file 'src/Ubuntu/Components/plugin/ucactionitem.cpp'
19--- src/Ubuntu/Components/plugin/ucactionitem.cpp 2015-09-16 05:26:36 +0000
20+++ src/Ubuntu/Components/plugin/ucactionitem.cpp 2015-12-11 12:39:17 +0000
21@@ -336,6 +336,7 @@
22 void UCActionItem::trigger(const QVariant &value)
23 {
24 if (isEnabled()) {
25+ // FIXME: bug #1524234: invoke function from QMetaObject (zsombi)
26 Q_EMIT triggered(value);
27 }
28 }
29
30=== modified file 'tests/unit_x11/tst_components/tst_focus.qml'
31--- tests/unit_x11/tst_components/tst_focus.qml 2015-11-25 15:09:07 +0000
32+++ tests/unit_x11/tst_components/tst_focus.qml 2015-12-11 12:39:17 +0000
33@@ -140,6 +140,11 @@
34 when: windowShown
35
36 SignalSpy {
37+ id: buttonTriggerSpy
38+ signalName: "onTriggered"
39+ }
40+
41+ SignalSpy {
42 id: popupCloseSpy
43 signalName: "onDestruction"
44 }
45@@ -266,6 +271,21 @@
46 verify(popoverTest.focus, "Button focus not restored.");
47 }
48
49+ function test_button_trigger_via_keyboard_data() {
50+ return [
51+ {tag: "Enter", key: Qt.Key_Enter},
52+ {tag: "Return", key: Qt.Key_Return},
53+ {tag: "Space", key: Qt.Key_Space},
54+ ];
55+ }
56+ function test_button_trigger_via_keyboard(data) {
57+ buttonTriggerSpy.target = button;
58+ button.forceActiveFocus();
59+ keyClick(data.key);
60+ waitForRendering(button);
61+ buttonTriggerSpy.wait();
62+ }
63+
64 function test_disabled_component_does_not_focus() {
65 mousePress(disabledButton, centerOf(disabledButton).x, centerOf(disabledButton).y);
66 compare(disabledButton.focus, false, "Disabled component shoudl not focus");

Subscribers

People subscribed via source and target branches