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

Proposed by Nick Dedekind on 2015-05-11
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
Christian Dywan (community) 2015-05-11 Needs Fixing on 2015-07-06
PS Jenkins bot continuous-integration Needs Fixing on 2015-05-11
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.

Unmerged revisions

1188. By Nick Dedekind on 2015-05-11

Prevent mouse stealing while sliding

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'modules/Ubuntu/Components/Slider.qml'
2--- modules/Ubuntu/Components/Slider.qml 2015-04-10 06:52:20 +0000
3+++ modules/Ubuntu/Components/Slider.qml 2015-05-11 15:01:41 +0000
4@@ -135,26 +135,6 @@
5 property real dragInitMouseX: 0.0
6 property real dragInitNormalizedValue: 0.0
7
8- property Flickable flickable: {
9- // traverse parents to catch whether we have an ancestor Flickable
10- var pl = slider.parent;
11- while (pl) {
12- if (pl.hasOwnProperty("flicking")) {
13- return pl;
14- }
15- pl = pl.parent;
16- }
17- return null;
18- }
19-
20- states: State {
21- name: "sliding"
22- when: mouseArea.flickable && mouseArea.pressed
23- PropertyChanges {
24- target: mouseArea.flickable
25- interactive: false
26- }
27- }
28 function normalizedValueFromValue(value) {
29 if (Qt.application.layoutDirection == Qt.RightToLeft) {
30 return MathUtils.clampAndProject(value, slider.minimumValue,
31@@ -197,11 +177,13 @@
32 if (!slider.live) {
33 slider.value = liveValue;
34 }
35+ preventStealing = true;
36 }
37 onPositionChanged: {
38 // Left button dragging
39 var normalizedOffsetX = (mouseArea.mouseX - dragInitMouseX) / barMinusThumb;
40 liveValue = valueFromNormalizedValue(dragInitNormalizedValue + normalizedOffsetX);
41+ preventStealing = true;
42 }
43 onClicked: slider.requestFocus(Qt.MouseFocusReason)
44 onLiveValueChanged: if (isPressed) slider.requestFocus(Qt.MouseFocusReason)
45
46=== modified file 'tests/unit_x11/tst_components/tst_slider.qml'
47--- tests/unit_x11/tst_components/tst_slider.qml 2015-03-03 13:20:06 +0000
48+++ tests/unit_x11/tst_components/tst_slider.qml 2015-05-11 15:01:41 +0000
49@@ -32,7 +32,7 @@
50 UbuntuListView {
51 id: listView
52 width: parent.width
53- height: units.gu(20)
54+ height: units.gu(15)
55 clip: true
56 model: 10
57 delegate: Standard {
58@@ -44,7 +44,7 @@
59 UbuntuListView {
60 id: listView2
61 width: parent.width
62- height: units.gu(20)
63+ height: units.gu(15)
64 clip: true
65 model: 10
66 delegate: Slider {
67@@ -54,7 +54,7 @@
68 Flickable {
69 id: flickable
70 width: parent.width
71- height: units.gu(20)
72+ height: units.gu(15)
73 clip: true
74 contentHeight: column.height
75 Column {
76@@ -74,7 +74,7 @@
77 Flickable {
78 id: flickable2
79 width: parent.width
80- height: units.gu(20)
81+ height: units.gu(15)
82 clip: true
83 contentHeight: column2.height
84 Column {
85@@ -89,6 +89,34 @@
86 }
87 }
88 }
89+
90+ Flickable {
91+ id: flickable3
92+ width: parent.width
93+ height: units.gu(15)
94+ clip: true
95+ contentWidth: flickable4.width
96+
97+ Flickable {
98+ id: flickable4
99+ height: parent.height
100+ width: units.gu(40)
101+ clip: true
102+ contentHeight: column3.height
103+
104+ Column {
105+ id: column3
106+ width: parent.width
107+ height: childrenRect.height
108+ Repeater {
109+ model: 10
110+ Slider {
111+ objectName: "testSlider" + index
112+ }
113+ }
114+ }
115+ }
116+ }
117 }
118
119 UbuntuTestCase {
120@@ -111,6 +139,7 @@
121 {tag: "ListView with Slider alone", flickable: listView2},
122 {tag: "Flickable with Column of Slider in ListItem", flickable: flickable},
123 {tag: "Flickable with Column of Slider alone", flickable: flickable2},
124+ {tag: "Nested Flickable with Column of Slider alone", flickable: flickable3},
125 ];
126 }
127
128@@ -122,7 +151,6 @@
129 mouseDrag(data.flickable, sliderPos.x, sliderPos.y, units.gu(20), units.gu(20));
130 waitForRendering(data.flickable, 200);
131 compare(flickSpy.count, 0, "The Flickable should not move while Slider is active.");
132- compare(data.flickable.interactive, true, "The Flickable aint got back to interactive mode.");
133 }
134 }
135 }

Subscribers

People subscribed via source and target branches

to status/vote changes: