Merge lp:~tpeeters/ubuntu-ui-toolkit/listitem-disabled-control into lp:ubuntu-ui-toolkit

Proposed by Tim Peeters
Status: Merged
Approved by: Florian Boucault
Approved revision: 430
Merged at revision: 439
Proposed branch: lp:~tpeeters/ubuntu-ui-toolkit/listitem-disabled-control
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 242 lines (+120/-60)
4 files modified
demos/ListItems.qml (+7/-0)
modules/Ubuntu/Components/ListItems/SingleControl.qml (+3/-3)
modules/Ubuntu/Components/ListItems/Standard.qml (+4/-4)
tests/unit/tst_components/tst_listitems_standard.qml (+106/-53)
To merge this branch: bzr merge lp:~tpeeters/ubuntu-ui-toolkit/listitem-disabled-control
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Florian Boucault Pending
Review via email: mp+158998@code.launchpad.net

Commit message

Disable events on disabled controls inside list items.

Description of the change

Disable events on disabled controls inside list items.

To post a comment you must log in.
Revision history for this message
Tim Peeters (tpeeters) wrote :
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Tim Peeters (tpeeters) wrote :

On hold. Perhaps design doesn't want this in, because if the control is disabled then maybe it is better not to show it at all.

Revision history for this message
Tim Peeters (tpeeters) wrote :

We decided to include the support for disabled controls (see discussion in bug report), but it depends on the case whether it is the desired thing to use (vs. not showing a control).

Also added tests.

430. By Tim Peeters

remove blank line

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
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 'demos/ListItems.qml'
--- demos/ListItems.qml 2013-04-15 13:43:19 +0000
+++ demos/ListItems.qml 2013-04-22 12:39:26 +0000
@@ -319,6 +319,13 @@
319 control: controlExample.createObject(parent)319 control: controlExample.createObject(parent)
320 }320 }
321 ListItem.Standard {321 ListItem.Standard {
322 text: i18n.tr("Control disabled")
323 control: Switch {
324 anchors.verticalCenter: parent.verticalCenter
325 enabled: false
326 }
327 }
328 ListItem.Standard {
322 selected: true329 selected: true
323 text: i18n.tr("Selected")330 text: i18n.tr("Selected")
324 control: controlExample.createObject(parent)331 control: controlExample.createObject(parent)
325332
=== modified file 'modules/Ubuntu/Components/ListItems/SingleControl.qml'
--- modules/Ubuntu/Components/ListItems/SingleControl.qml 2013-04-16 10:59:28 +0000
+++ modules/Ubuntu/Components/ListItems/SingleControl.qml 2013-04-22 12:39:26 +0000
@@ -55,10 +55,10 @@
55 property AbstractButton control55 property AbstractButton control
5656
57 /*! \internal */57 /*! \internal */
58 onClicked: control.clicked()58 onClicked: if (control && control.enabled) control.clicked()
59 pressed: __mouseArea.pressed || control.__mouseArea.pressed59 pressed: __mouseArea.pressed || (control && control.__mouseArea.pressed)
60 /*! \internal */60 /*! \internal */
61 onPressedChanged: control.pressed = singleControlListItem.pressed61 onPressedChanged: if (control && control.enabled) control.pressed = singleControlListItem.pressed
6262
63 /*!63 /*!
64 \internal64 \internal
6565
=== modified file 'modules/Ubuntu/Components/ListItems/Standard.qml'
--- modules/Ubuntu/Components/ListItems/Standard.qml 2013-04-15 18:49:12 +0000
+++ modules/Ubuntu/Components/ListItems/Standard.qml 2013-04-22 12:39:26 +0000
@@ -241,7 +241,7 @@
241 margins: units.gu(2)241 margins: units.gu(2)
242 }242 }
243 onControlChanged: {243 onControlChanged: {
244 control.parent = controlContainer;244 if (control) control.parent = controlContainer;
245 }245 }
246246
247 Connections {247 Connections {
@@ -249,14 +249,14 @@
249249
250 onClicked: {250 onClicked: {
251 if (control && __mouseArea.mouseX < progressionHelper.x) {251 if (control && __mouseArea.mouseX < progressionHelper.x) {
252 control.clicked();252 if (control.enabled) control.clicked();
253 } else {253 } else {
254 listItem.clicked();254 listItem.clicked();
255 }255 }
256 }256 }
257257
258 onPressAndHold: {258 onPressAndHold: {
259 if (control && __mouseArea.mouseX < progressionHelper.x) {259 if (control && control.enabled && __mouseArea.mouseX < progressionHelper.x) {
260 control.pressAndHold();260 control.pressAndHold();
261 } else {261 } else {
262 listItem.pressAndHold();262 listItem.pressAndHold();
@@ -269,7 +269,7 @@
269 \internal269 \internal
270 */270 */
271 onPressedChanged: {271 onPressedChanged: {
272 if (listItem.pressed && control && (__mouseArea.mouseX < progressionHelper.x)) {272 if (listItem.pressed && control && control.enabled && (__mouseArea.mouseX < progressionHelper.x)) {
273 listItem.__controlAreaPressed = true273 listItem.__controlAreaPressed = true
274 } else {274 } else {
275 listItem.__controlAreaPressed = false275 listItem.__controlAreaPressed = false
276276
=== modified file 'tests/unit/tst_components/tst_listitems_standard.qml'
--- tests/unit/tst_components/tst_listitems_standard.qml 2012-12-10 09:12:46 +0000
+++ tests/unit/tst_components/tst_listitems_standard.qml 2013-04-22 12:39:26 +0000
@@ -19,57 +19,110 @@
19import Ubuntu.Components 0.119import Ubuntu.Components 0.1
20import Ubuntu.Components.ListItems 0.1 as ListItem20import Ubuntu.Components.ListItems 0.1 as ListItem
2121
22TestCase {22Item {
23 name: "ListItemsStandardAPI"23 width: 400
2424 height: 400
25 function test_fallbackIconSource() {25
26 expectFail("","https://bugs.launchpad.net/tavastia/+bug/1076762")26 Rectangle {
27 compare(listItemStandard.fallbackIconSource,undefined,"fallbackIconSource is not set by default")27 id: testItem
28 }28 }
2929
30 function test_control() {30 AbstractButton {
31 compare(listItemStandard.control,null,"control is null by default")31 id: testControl
32 listItemStandard.control = testControl32 visible: false
33 compare(listItemStandard.control,testControl,"set/get")33 }
34 }34
3535 ListItem.Standard {
36 function test_icon() {36 id: listItemStandard
37 compare(listItemStandard.icon,undefined,"icon is not set by default")37 anchors.fill: parent
3838 }
39 // test with item39
40 listItemStandard.icon = testItem40 TestCase {
41 compare(listItemStandard.icon,testItem,"set/get from Item")41 name: "ListItemsStandardAPI"
4242 when: windowShown
43 // test with url43
44 var newIcon = "../../../demos/small_avatar.png"44 function test_fallbackIconSource() {
45 listItemStandard.icon = newIcon45 expectFail("","https://bugs.launchpad.net/tavastia/+bug/1076762")
46 compare(listItemStandard.icon,newIcon,"set/get from url")46 compare(listItemStandard.fallbackIconSource,undefined,"fallbackIconSource is not set by default")
47 }47 }
4848
49 function test_iconFrame() {49 function test_control() {
50 compare(listItemStandard.iconFrame,true,"iconFrame is true by default")50 listItemStandard.control = testControl
51 }51 compare(listItemStandard.control,testControl,"set/get")
5252 listItemStandard.control = null
53 function test_progression() {53 compare(listItemStandard.control, null, "unset")
54 compare(listItemStandard.progression,false,"progression is false by default")54 }
55 }55
5656 function test_clicked() {
57 function test_text() {57 compare(listItemClickedSpy.valid, true, "clicked signal exists")
58 compare(listItemStandard.text,"","text is '' by default")58 compare(controlClickedSpy.valid, true, "control has clicked signal")
59 var newText = "Hello World!"59 var listItemClickedCount = listItemClickedSpy.count
60 listItemStandard.text = newText60 var controlClickedCount = controlClickedSpy.count
61 compare(listItemStandard.text,newText,"set/get")61 mouseMove(listItemStandard, 10, 10)
62 }62 mouseClick(listItemStandard, 10, 10, Qt.LeftButton)
6363 listItemClickedCount++;
64 Rectangle {64 compare(listItemClickedSpy.count, listItemClickedCount, "List item clicked triggered")
65 id: testItem65 listItemStandard.control = testControl;
66 }66 mouseMove(listItemStandard, 10, 10)
6767 mouseClick(listItemStandard, 10, 10, Qt.LeftButton)
68 AbstractButton {68 compare(listItemStandard.control, testControl, "control can be set")
69 id: testControl69 controlClickedCount++;
70 }70 compare(controlClickedSpy.count, controlClickedCount, "Control clicked triggered")
7171 compare(listItemClickedSpy.count, listItemClickedCount, "List item clicked not triggered when there is a control")
72 ListItem.Standard {72 listItemStandard.control = null;
73 id: listItemStandard73 }
74 }74
75 function test_bug1166982_disabled_control_clicked() {
76 var listItemClickedCount = listItemClickedSpy.count
77 var controlClickedCount = controlClickedSpy.count
78 listItemStandard.control = testControl
79 testControl.enabled = false
80 mouseMove(listItemStandard, 10, 10)
81 mouseClick(listItemStandard, 10, 10, Qt.LeftButton)
82 compare(listItemClickedSpy.count, listItemClickedCount, "List item clicked not triggered with disabled control")
83 compare(controlClickedSpy.count, controlClickedCount, "Control clicked not triggered with disabled control")
84 testControl.enabled = true
85 listItemStandard.control = null
86 }
87
88 function test_icon() {
89 compare(listItemStandard.icon,undefined,"icon is not set by default")
90
91 // test with item
92 listItemStandard.icon = testItem
93 compare(listItemStandard.icon,testItem,"set/get from Item")
94
95 // test with url
96 var newIcon = "../../../demos/small_avatar.png"
97 listItemStandard.icon = newIcon
98 compare(listItemStandard.icon,newIcon,"set/get from url")
99 }
100
101 function test_iconFrame() {
102 compare(listItemStandard.iconFrame,true,"iconFrame is true by default")
103 }
104
105 function test_progression() {
106 compare(listItemStandard.progression,false,"progression is false by default")
107 }
108
109 function test_text() {
110 compare(listItemStandard.text,"","text is '' by default")
111 var newText = "Hello World!"
112 listItemStandard.text = newText
113 compare(listItemStandard.text,newText,"set/get")
114 }
115
116 SignalSpy {
117 id: listItemClickedSpy
118 target: listItemStandard
119 signalName: "clicked"
120 }
121
122 SignalSpy {
123 id: controlClickedSpy
124 target: testControl
125 signalName: "clicked"
126 }
127 }
75}128}

Subscribers

People subscribed via source and target branches

to status/vote changes: