Merge lp:~nick-dedekind/ubuntu-ui-toolkit/prevent-slider-mouse-stealing into lp:ubuntu-ui-toolkit

Proposed by Nick Dedekind
Status: Work in progress
Proposed branch: lp:~nick-dedekind/ubuntu-ui-toolkit/prevent-slider-mouse-stealing
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 135 lines (+35/-25)
2 files modified
modules/Ubuntu/Components/Slider.qml (+2/-20)
tests/unit_x11/tst_components/tst_slider.qml (+33/-5)
To merge this branch: bzr merge lp:~nick-dedekind/ubuntu-ui-toolkit/prevent-slider-mouse-stealing
Reviewer Review Type Date Requested Status
Cris Dywan Needs Fixing
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+258785@code.launchpad.net

Commit message

Prevent the mouse events from being stolen while dragging the slider.

Description of the change

Prevent the mouse events from being stolen while dragging the slider.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Cris Dywan (kalikiana) wrote :

I'm a bit suspicious of the unit test.. why are you removing the interactive check?

review: Needs Fixing

Unmerged revisions

1188. By Nick Dedekind

Prevent mouse stealing while sliding

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'modules/Ubuntu/Components/Slider.qml'
--- modules/Ubuntu/Components/Slider.qml 2015-04-10 06:52:20 +0000
+++ modules/Ubuntu/Components/Slider.qml 2015-05-11 15:01:41 +0000
@@ -135,26 +135,6 @@
135 property real dragInitMouseX: 0.0135 property real dragInitMouseX: 0.0
136 property real dragInitNormalizedValue: 0.0136 property real dragInitNormalizedValue: 0.0
137137
138 property Flickable flickable: {
139 // traverse parents to catch whether we have an ancestor Flickable
140 var pl = slider.parent;
141 while (pl) {
142 if (pl.hasOwnProperty("flicking")) {
143 return pl;
144 }
145 pl = pl.parent;
146 }
147 return null;
148 }
149
150 states: State {
151 name: "sliding"
152 when: mouseArea.flickable && mouseArea.pressed
153 PropertyChanges {
154 target: mouseArea.flickable
155 interactive: false
156 }
157 }
158 function normalizedValueFromValue(value) {138 function normalizedValueFromValue(value) {
159 if (Qt.application.layoutDirection == Qt.RightToLeft) {139 if (Qt.application.layoutDirection == Qt.RightToLeft) {
160 return MathUtils.clampAndProject(value, slider.minimumValue,140 return MathUtils.clampAndProject(value, slider.minimumValue,
@@ -197,11 +177,13 @@
197 if (!slider.live) {177 if (!slider.live) {
198 slider.value = liveValue;178 slider.value = liveValue;
199 }179 }
180 preventStealing = true;
200 }181 }
201 onPositionChanged: {182 onPositionChanged: {
202 // Left button dragging183 // Left button dragging
203 var normalizedOffsetX = (mouseArea.mouseX - dragInitMouseX) / barMinusThumb;184 var normalizedOffsetX = (mouseArea.mouseX - dragInitMouseX) / barMinusThumb;
204 liveValue = valueFromNormalizedValue(dragInitNormalizedValue + normalizedOffsetX);185 liveValue = valueFromNormalizedValue(dragInitNormalizedValue + normalizedOffsetX);
186 preventStealing = true;
205 }187 }
206 onClicked: slider.requestFocus(Qt.MouseFocusReason)188 onClicked: slider.requestFocus(Qt.MouseFocusReason)
207 onLiveValueChanged: if (isPressed) slider.requestFocus(Qt.MouseFocusReason)189 onLiveValueChanged: if (isPressed) slider.requestFocus(Qt.MouseFocusReason)
208190
=== modified file 'tests/unit_x11/tst_components/tst_slider.qml'
--- tests/unit_x11/tst_components/tst_slider.qml 2015-03-03 13:20:06 +0000
+++ tests/unit_x11/tst_components/tst_slider.qml 2015-05-11 15:01:41 +0000
@@ -32,7 +32,7 @@
32 UbuntuListView {32 UbuntuListView {
33 id: listView33 id: listView
34 width: parent.width34 width: parent.width
35 height: units.gu(20)35 height: units.gu(15)
36 clip: true36 clip: true
37 model: 1037 model: 10
38 delegate: Standard {38 delegate: Standard {
@@ -44,7 +44,7 @@
44 UbuntuListView {44 UbuntuListView {
45 id: listView245 id: listView2
46 width: parent.width46 width: parent.width
47 height: units.gu(20)47 height: units.gu(15)
48 clip: true48 clip: true
49 model: 1049 model: 10
50 delegate: Slider {50 delegate: Slider {
@@ -54,7 +54,7 @@
54 Flickable {54 Flickable {
55 id: flickable55 id: flickable
56 width: parent.width56 width: parent.width
57 height: units.gu(20)57 height: units.gu(15)
58 clip: true58 clip: true
59 contentHeight: column.height59 contentHeight: column.height
60 Column {60 Column {
@@ -74,7 +74,7 @@
74 Flickable {74 Flickable {
75 id: flickable275 id: flickable2
76 width: parent.width76 width: parent.width
77 height: units.gu(20)77 height: units.gu(15)
78 clip: true78 clip: true
79 contentHeight: column2.height79 contentHeight: column2.height
80 Column {80 Column {
@@ -89,6 +89,34 @@
89 }89 }
90 }90 }
91 }91 }
92
93 Flickable {
94 id: flickable3
95 width: parent.width
96 height: units.gu(15)
97 clip: true
98 contentWidth: flickable4.width
99
100 Flickable {
101 id: flickable4
102 height: parent.height
103 width: units.gu(40)
104 clip: true
105 contentHeight: column3.height
106
107 Column {
108 id: column3
109 width: parent.width
110 height: childrenRect.height
111 Repeater {
112 model: 10
113 Slider {
114 objectName: "testSlider" + index
115 }
116 }
117 }
118 }
119 }
92 }120 }
93121
94 UbuntuTestCase {122 UbuntuTestCase {
@@ -111,6 +139,7 @@
111 {tag: "ListView with Slider alone", flickable: listView2},139 {tag: "ListView with Slider alone", flickable: listView2},
112 {tag: "Flickable with Column of Slider in ListItem", flickable: flickable},140 {tag: "Flickable with Column of Slider in ListItem", flickable: flickable},
113 {tag: "Flickable with Column of Slider alone", flickable: flickable2},141 {tag: "Flickable with Column of Slider alone", flickable: flickable2},
142 {tag: "Nested Flickable with Column of Slider alone", flickable: flickable3},
114 ];143 ];
115 }144 }
116145
@@ -122,7 +151,6 @@
122 mouseDrag(data.flickable, sliderPos.x, sliderPos.y, units.gu(20), units.gu(20));151 mouseDrag(data.flickable, sliderPos.x, sliderPos.y, units.gu(20), units.gu(20));
123 waitForRendering(data.flickable, 200);152 waitForRendering(data.flickable, 200);
124 compare(flickSpy.count, 0, "The Flickable should not move while Slider is active.");153 compare(flickSpy.count, 0, "The Flickable should not move while Slider is active.");
125 compare(data.flickable.interactive, true, "The Flickable aint got back to interactive mode.");
126 }154 }
127 }155 }
128}156}

Subscribers

People subscribed via source and target branches

to status/vote changes: