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

Proposed by Cris 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 Cris 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 Cris 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 Cris Dywan

Call ActionItem.trigger directly

1747. By Cris 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
=== modified file 'src/Ubuntu/Components/plugin/ucabstractbutton.cpp'
--- src/Ubuntu/Components/plugin/ucabstractbutton.cpp 2015-12-05 05:59:07 +0000
+++ src/Ubuntu/Components/plugin/ucabstractbutton.cpp 2015-12-11 12:39:17 +0000
@@ -138,10 +138,9 @@
138 switch (event->key()) {138 switch (event->key()) {
139 case Qt::Key_Enter:139 case Qt::Key_Enter:
140 case Qt::Key_Return:140 case Qt::Key_Return:
141 // FIXME: space may also come here, however that depends on the button type141 case Qt::Key_Space:
142 // (i.e default Dialog btn) so we may need to add that to Button
143 {142 {
144 Q_EMIT clicked();143 trigger();
145 break;144 break;
146 }145 }
147 }146 }
148147
=== modified file 'src/Ubuntu/Components/plugin/ucactionitem.cpp'
--- src/Ubuntu/Components/plugin/ucactionitem.cpp 2015-09-16 05:26:36 +0000
+++ src/Ubuntu/Components/plugin/ucactionitem.cpp 2015-12-11 12:39:17 +0000
@@ -336,6 +336,7 @@
336void UCActionItem::trigger(const QVariant &value)336void UCActionItem::trigger(const QVariant &value)
337{337{
338 if (isEnabled()) {338 if (isEnabled()) {
339 // FIXME: bug #1524234: invoke function from QMetaObject (zsombi)
339 Q_EMIT triggered(value);340 Q_EMIT triggered(value);
340 }341 }
341}342}
342343
=== modified file 'tests/unit_x11/tst_components/tst_focus.qml'
--- tests/unit_x11/tst_components/tst_focus.qml 2015-11-25 15:09:07 +0000
+++ tests/unit_x11/tst_components/tst_focus.qml 2015-12-11 12:39:17 +0000
@@ -140,6 +140,11 @@
140 when: windowShown140 when: windowShown
141141
142 SignalSpy {142 SignalSpy {
143 id: buttonTriggerSpy
144 signalName: "onTriggered"
145 }
146
147 SignalSpy {
143 id: popupCloseSpy148 id: popupCloseSpy
144 signalName: "onDestruction"149 signalName: "onDestruction"
145 }150 }
@@ -266,6 +271,21 @@
266 verify(popoverTest.focus, "Button focus not restored.");271 verify(popoverTest.focus, "Button focus not restored.");
267 }272 }
268273
274 function test_button_trigger_via_keyboard_data() {
275 return [
276 {tag: "Enter", key: Qt.Key_Enter},
277 {tag: "Return", key: Qt.Key_Return},
278 {tag: "Space", key: Qt.Key_Space},
279 ];
280 }
281 function test_button_trigger_via_keyboard(data) {
282 buttonTriggerSpy.target = button;
283 button.forceActiveFocus();
284 keyClick(data.key);
285 waitForRendering(button);
286 buttonTriggerSpy.wait();
287 }
288
269 function test_disabled_component_does_not_focus() {289 function test_disabled_component_does_not_focus() {
270 mousePress(disabledButton, centerOf(disabledButton).x, centerOf(disabledButton).y);290 mousePress(disabledButton, centerOf(disabledButton).x, centerOf(disabledButton).y);
271 compare(disabledButton.focus, false, "Disabled component shoudl not focus");291 compare(disabledButton.focus, false, "Disabled component shoudl not focus");

Subscribers

People subscribed via source and target branches