Merge lp:~azzar1/unity8/launcher-tooltips into lp:unity8
- launcher-tooltips
- Merge into trunk
Status: | Superseded |
---|---|
Proposed branch: | lp:~azzar1/unity8/launcher-tooltips |
Merge into: | lp:unity8 |
Diff against target: |
380 lines (+239/-52) 5 files modified
qml/Components/UbuntuShapeForItem.qml (+0/-47) qml/Launcher/LauncherDelegate.qml (+1/-0) qml/Launcher/LauncherPanel.qml (+150/-3) qml/Stages/DesktopSpread.qml (+2/-2) tests/qmltests/Launcher/tst_Launcher.qml (+86/-0) |
To merge this branch: | bzr merge lp:~azzar1/unity8/launcher-tooltips |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Unity Team | Pending | ||
Review via email:
|
This proposal has been superseded by a proposal from 2016-09-26.
Commit message
Description of the change
- 2607. By Andrea Azzarone
-
Use a s StateMachine to handle tooltip logic.
- 2608. By Andrea Azzarone
-
Update tests.
- 2609. By Andrea Azzarone
-
Merge with trunk.
- 2610. By Andrea Azzarone
-
Add comment.
- 2611. By Andrea Azzarone
-
Merge with lp:~azzar1/unity8/remove-UbuntuShapeForItem
- 2612. By Andrea Azzarone
-
Refactor and simplify tooltip layout logic.
- 2613. By Andrea Azzarone
-
Merge with trunk.
- 2614. By Andrea Azzarone
-
Use conditional bindings.
- 2615. By Andrea Azzarone
-
Rebase on unified-stages branch.
- 2616. By Andrea Azzarone
-
Remove trailing space.
- 2617. By Andrea Azzarone
-
Resync with lp:~azzar1/unity8/remove-UbuntuShapeForItem
- 2618. By Andrea Azzarone
-
Remove mouseEventEater as we have hoverEnabled equals to true in dndArea.
- 2619. By Andrea Azzarone
-
Move Tooltip in a different component.
- 2620. By Andrea Azzarone
-
Remove useless code in Tooltip.qml
- 2621. By Andrea Azzarone
-
Add a delay in mouseMove.
- 2622. By Andrea Azzarone
-
Refactor the way we deal with tooltip delay timer.
- 2623. By Andrea Azzarone
-
Use revealByPush.
- 2624. By Andrea Azzarone
-
waitForRenderin
g(launcher) when using revealyByEdgePush - 2625. By Andrea Azzarone
-
Add deps to qml-module-
qtqml-statemach ine. - 2626. By Andrea Azzarone
-
Revert change to revealByEdgePush
- 2627. By Andrea Azzarone
-
Disable the tests.
- 2628. By Andrea Azzarone
-
Disable enableHovered to debug test failures.
- 2629. By Andrea Azzarone
-
Re-enable tooltips and tests.
- 2630. By Andrea Azzarone
-
Resync with lp:~azzar1/unity8/remove-UbuntuShapeForItem
- 2631. By Andrea Azzarone
-
Mark hoveredItem and itemCenter as readonly
- 2632. By Andrea Azzarone
-
Avoid type conversion.
- 2633. By Andrea Azzarone
-
Merge with trunk.
- 2634. By Andrea Azzarone
-
Fix broken test.
Unmerged revisions
Preview Diff
1 | === removed file 'qml/Components/UbuntuShapeForItem.qml' |
2 | --- qml/Components/UbuntuShapeForItem.qml 2016-03-23 20:05:10 +0000 |
3 | +++ qml/Components/UbuntuShapeForItem.qml 1970-01-01 00:00:00 +0000 |
4 | @@ -1,47 +0,0 @@ |
5 | -/* |
6 | - * Copyright (C) 2012 Canonical, Ltd. |
7 | - * |
8 | - * This program is free software; you can redistribute it and/or modify |
9 | - * it under the terms of the GNU General Public License as published by |
10 | - * the Free Software Foundation; version 3. |
11 | - * |
12 | - * This program is distributed in the hope that it will be useful, |
13 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | - * GNU General Public License for more details. |
16 | - * |
17 | - * You should have received a copy of the GNU General Public License |
18 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | - */ |
20 | - |
21 | -import QtQuick 2.4 |
22 | -import Ubuntu.Components 1.3 |
23 | - |
24 | -/* FIXME: This component is duplicating the UbuntuShape from the SDK, but shapes more |
25 | - * general (Item-based) components. This ability should be incorporated into the SDK's |
26 | - * UbuntuShape so this file can be removed. |
27 | - * Bug: https://bugs.launchpad.net/tavastia/+bug/1089595 |
28 | - */ |
29 | - |
30 | -Item { |
31 | - id: root |
32 | - |
33 | - property alias radius: shape.radius |
34 | - property alias image: source.sourceItem |
35 | - property alias aspect: shape.aspect |
36 | - |
37 | - ShaderEffectSource { |
38 | - id: source |
39 | - anchors.centerIn: parent // Placed under shape, so it's hidden |
40 | - width: 1 |
41 | - height: 1 |
42 | - hideSource: true |
43 | - } |
44 | - |
45 | - Shape { |
46 | - id: shape |
47 | - image: source |
48 | - |
49 | - anchors.fill: parent |
50 | - } |
51 | -} |
52 | |
53 | === modified file 'qml/Launcher/LauncherDelegate.qml' |
54 | --- qml/Launcher/LauncherDelegate.qml 2016-06-03 11:13:46 +0000 |
55 | +++ qml/Launcher/LauncherDelegate.qml 2016-09-26 13:07:23 +0000 |
56 | @@ -22,6 +22,7 @@ |
57 | |
58 | property int itemIndex: 0 |
59 | property string iconName |
60 | + property string name |
61 | property int count: 0 |
62 | property bool countVisible: false |
63 | property int progress: -1 |
64 | |
65 | === modified file 'qml/Launcher/LauncherPanel.qml' |
66 | --- qml/Launcher/LauncherPanel.qml 2016-07-27 14:51:26 +0000 |
67 | +++ qml/Launcher/LauncherPanel.qml 2016-09-26 13:07:23 +0000 |
68 | @@ -15,6 +15,7 @@ |
69 | */ |
70 | |
71 | import QtQuick 2.4 |
72 | +import QtQml.StateMachine 1.0 as DSM |
73 | import Ubuntu.Components 1.3 |
74 | import Unity.Launcher 0.1 |
75 | import Ubuntu.Components.Popups 1.3 |
76 | @@ -41,7 +42,7 @@ |
77 | signal kbdNavigationCancelled() |
78 | |
79 | onXChanged: { |
80 | - if (quickList.state == "open") { |
81 | + if (quickList.state === "open") { |
82 | quickList.state = "" |
83 | } |
84 | } |
85 | @@ -226,6 +227,7 @@ |
86 | // the right app when running autopilot tests for |
87 | // multiple apps. |
88 | readonly property string appId: model.appId |
89 | + name: model.name |
90 | itemIndex: index |
91 | itemHeight: launcherListView.itemHeight |
92 | itemWidth: launcherListView.itemWidth |
93 | @@ -399,6 +401,7 @@ |
94 | id: dndArea |
95 | objectName: "dndArea" |
96 | acceptedButtons: Qt.LeftButton | Qt.RightButton |
97 | + hoverEnabled: true |
98 | anchors { |
99 | fill: parent |
100 | topMargin: launcherListView.topMargin |
101 | @@ -632,7 +635,7 @@ |
102 | } |
103 | } |
104 | |
105 | - UbuntuShapeForItem { |
106 | + UbuntuShape { |
107 | id: quickListShape |
108 | objectName: "quickListShape" |
109 | anchors.fill: quickList |
110 | @@ -645,7 +648,10 @@ |
111 | UbuntuNumberAnimation {} |
112 | } |
113 | |
114 | - image: quickList |
115 | + source: ShaderEffectSource { |
116 | + sourceItem: quickList |
117 | + hideSource: true |
118 | + } |
119 | |
120 | Image { |
121 | anchors { |
122 | @@ -825,4 +831,145 @@ |
123 | } |
124 | } |
125 | } |
126 | + |
127 | + UbuntuShape { |
128 | + id: tooltipShape |
129 | + objectName: "tooltipShape" |
130 | + anchors.fill: tooltip |
131 | + opacity: tooltipShownState.active ? 0.95 : 0 |
132 | + visible: opacity > 0 |
133 | + rotation: root.rotation |
134 | + aspect: UbuntuShape.Flat |
135 | + |
136 | + Behavior on opacity { |
137 | + UbuntuNumberAnimation { |
138 | + duration: UbuntuAnimation.BriskDuration |
139 | + } |
140 | + } |
141 | + |
142 | + source: ShaderEffectSource { |
143 | + sourceItem: tooltip |
144 | + hideSource: true |
145 | + } |
146 | + |
147 | + Image { |
148 | + anchors { |
149 | + right: parent.left |
150 | + rightMargin: -units.dp(4) |
151 | + verticalCenter: parent.verticalCenter |
152 | + verticalCenterOffset: -tooltip.offset * (root.inverted ? -1 : 1) |
153 | + } |
154 | + height: units.gu(1) |
155 | + width: units.gu(2) |
156 | + source: "graphics/quicklist_tooltip.png" |
157 | + rotation: 90 |
158 | + } |
159 | + } |
160 | + |
161 | + Rectangle { |
162 | + id: tooltip |
163 | + objectName: "tooltip" |
164 | + |
165 | + color: theme.palette.normal.background |
166 | + visible: tooltipShape.visible |
167 | + |
168 | + width: tooltipLabel.contentWidth + units.gu(4) |
169 | + height: tooltipLabel.contentHeight + units.gu(2) |
170 | + |
171 | + y: itemCenter - (height / 2) + offset |
172 | + rotation: root.rotation |
173 | + |
174 | + anchors { |
175 | + left: root.inverted ? undefined : parent.right |
176 | + right: root.inverted ? parent.left : undefined |
177 | + margins: units.gu(1) |
178 | + } |
179 | + |
180 | + property var hoveredItem: dndArea.containsMouse ? launcherListView.itemAt(dndArea.mouseX, dndArea.mouseY + launcherListView.realContentY) : null |
181 | + |
182 | + property int itemCenter |
183 | + property int offset: itemCenter + (height/2) + units.gu(1) > parent.height ? -itemCenter - (height/2) - units.gu(1) + parent.height : |
184 | + itemCenter - (height/2) < units.gu(1) ? (height/2) - itemCenter + units.gu(1) : 0 |
185 | + |
186 | + // This avoids artifacts on fade-out animation |
187 | + onHoveredItemChanged : { |
188 | + if (hoveredItem != null && !root.moving) { |
189 | + itemCenter = root.mapFromItem(hoveredItem, 0, 0).y + (hoveredItem.height / 2) + hoveredItem.offset |
190 | + tooltipLabel.text = tooltip.hoveredItem.name |
191 | + } |
192 | + } |
193 | + |
194 | + Label { |
195 | + id: tooltipLabel |
196 | + height: parent.height |
197 | + anchors.centerIn: parent |
198 | + verticalAlignment: Label.AlignVCenter |
199 | + color: theme.palette.normal.backgroundText |
200 | + } |
201 | + |
202 | + DSM.StateMachine { |
203 | + id: tooltipStateMachine |
204 | + initialState: tooltipHiddenState |
205 | + running: true |
206 | + |
207 | + DSM.State { |
208 | + id: tooltipHiddenState |
209 | + |
210 | + DSM.SignalTransition { |
211 | + targetState: tooltipShownState |
212 | + signal: tooltip.hoveredItemChanged |
213 | + // !dndArea.pressed allows us to filter out touch input events |
214 | + guard: tooltip.hoveredItem != null && !dndArea.pressed && !root.moving |
215 | + } |
216 | + } |
217 | + |
218 | + DSM.State { |
219 | + id: tooltipShownState |
220 | + |
221 | + DSM.SignalTransition { |
222 | + targetState: tooltipHiddenState |
223 | + signal: tooltip.hoveredItemChanged |
224 | + guard: tooltip.hoveredItem == null |
225 | + } |
226 | + |
227 | + DSM.SignalTransition { |
228 | + targetState: tooltipHiddenState |
229 | + signal: dndArea.exited |
230 | + } |
231 | + |
232 | + DSM.SignalTransition { |
233 | + targetState: tooltipDismissedState |
234 | + signal: dndArea.onPressed |
235 | + } |
236 | + |
237 | + DSM.SignalTransition { |
238 | + targetState: tooltipDismissedState |
239 | + signal: quickList.stateChanged |
240 | + guard: quickList.state === "open" |
241 | + } |
242 | + |
243 | + DSM.SignalTransition { |
244 | + targetState: tooltipDismissedState |
245 | + signal: root.movingChanged |
246 | + guard: root.moving |
247 | + } |
248 | + } |
249 | + |
250 | + DSM.State { |
251 | + id: tooltipDismissedState |
252 | + |
253 | + DSM.SignalTransition { |
254 | + targetState: tooltipHiddenState |
255 | + signal: dndArea.positionChanged |
256 | + guard: quickList.state != "open" && !dndArea.pressed && !dndArea.moving |
257 | + } |
258 | + |
259 | + DSM.SignalTransition { |
260 | + targetState: tooltipHiddenState |
261 | + signal: dndArea.exited |
262 | + guard: quickList.state != "open" |
263 | + } |
264 | + } |
265 | + } |
266 | + } |
267 | } |
268 | |
269 | === modified file 'qml/Stages/DesktopSpread.qml' |
270 | --- qml/Stages/DesktopSpread.qml 2016-06-15 14:08:18 +0000 |
271 | +++ qml/Stages/DesktopSpread.qml 2016-09-26 13:07:23 +0000 |
272 | @@ -311,10 +311,10 @@ |
273 | anchors { left: parent.left; top: parent.top; right: parent.right } |
274 | spacing: units.gu(1) |
275 | |
276 | - UbuntuShapeForItem { |
277 | + UbuntuShape { |
278 | Layout.preferredHeight: Math.min(units.gu(6), root.height * .05) |
279 | Layout.preferredWidth: height * 8 / 7.6 |
280 | - image: Image { |
281 | + source: Image { |
282 | anchors.fill: parent |
283 | source: model.application.icon |
284 | Rectangle { |
285 | |
286 | === modified file 'tests/qmltests/Launcher/tst_Launcher.qml' |
287 | --- tests/qmltests/Launcher/tst_Launcher.qml 2016-08-01 11:23:49 +0000 |
288 | +++ tests/qmltests/Launcher/tst_Launcher.qml 2016-09-26 13:07:23 +0000 |
289 | @@ -1353,5 +1353,91 @@ |
290 | mouseWheel(launcherPanel, launcherPanel.width/2, launcherPanel.height/2, Qt.RightButton); |
291 | tryCompare(clickThroughSpy, "count", 0); |
292 | } |
293 | + |
294 | + function test_tooltip() { |
295 | + launcher.lockedVisible = true; |
296 | + dragLauncherIntoView(); |
297 | + |
298 | + var item = findChild(launcher, "launcherDelegate0"); |
299 | + var tooltipShape = findChild(launcher, "tooltipShape"); |
300 | + |
301 | + // Make sure we don't start the test with the mouse hovering the launcher |
302 | + mouseMove(root, root.width, root.height / 2); |
303 | + |
304 | + // Initial state |
305 | + tryCompare(tooltipShape, "visible", false); |
306 | + |
307 | + // Move the mouse on the launcher icon |
308 | + mouseMove(item, item.width / 2, item.height / 2); |
309 | + mouseMove(item, item.width / 2 + 1, item.height / 2); |
310 | + tryCompare(tooltipShape, "visible", true); |
311 | + |
312 | + // Move the mouse away |
313 | + mouseMove(root, root.width, root.height / 2); |
314 | + tryCompare(tooltipShape, "visible", false); |
315 | + } |
316 | + |
317 | + function test_quicklist_dismisses_tooltip() { |
318 | + launcher.lockedVisible = true; |
319 | + dragLauncherIntoView(); |
320 | + |
321 | + var item = findChild(launcher, "launcherDelegate0"); |
322 | + var tooltipShape = findChild(launcher, "tooltipShape"); |
323 | + var quickListShape = findChild(launcher, "quickListShape"); |
324 | + |
325 | + // Make sure we don't start the test with the mouse hovering the launcher |
326 | + mouseMove(root, root.width, root.height / 2); |
327 | + |
328 | + // Initial state |
329 | + tryCompare(tooltipShape, "visible", false); |
330 | + |
331 | + // Move the mouse on the launcher icon |
332 | + mouseMove(item, item.width / 2, item.height / 2); |
333 | + mouseMove(item, item.width / 2 + 1, item.height / 2); |
334 | + tryCompare(tooltipShape, "visible", true); |
335 | + |
336 | + // Right click to show the quicklist |
337 | + mouseClick(item, item.width / 2, item.height / 2, Qt.RightButton); |
338 | + tryCompare(quickListShape, "visible", true); |
339 | + tryCompare(tooltipShape, "visible", false); |
340 | + |
341 | + // Left click hides the quicklist, tooltip is still dismissed |
342 | + mouseClick(item, item.width / 2, item.height / 2, Qt.LefftButton); |
343 | + tryCompare(quickListShape, "visible", false); |
344 | + tryCompare(tooltipShape, "visible", false); |
345 | + |
346 | + // Mouse motion should should show tooltip again |
347 | + mouseMove(item, item.width / 2, item.height / 2); |
348 | + mouseMove(item, item.width / 2 + 1, item.height / 2); |
349 | + tryCompare(tooltipShape, "visible", true); |
350 | + } |
351 | + |
352 | + function test_click_dismisses_tooltip() { |
353 | + launcher.lockedVisible = true; |
354 | + dragLauncherIntoView(); |
355 | + |
356 | + var item = findChild(launcher, "launcherDelegate0"); |
357 | + var tooltipShape = findChild(launcher, "tooltipShape"); |
358 | + |
359 | + // Make sure we don't start the test with the mouse hovering the launcher |
360 | + mouseMove(root, root.width, root.height / 2); |
361 | + |
362 | + // Initial state |
363 | + compare(tooltipShape.visible, false); |
364 | + |
365 | + // Move the mouse on the launcher icon |
366 | + mouseMove(item, item.width / 2, item.height / 2); |
367 | + mouseMove(item, item.width / 2 + 1, item.height / 2); |
368 | + tryCompare(tooltipShape, "visible", true); |
369 | + |
370 | + // Left click should dismiss the tooltip |
371 | + mouseClick(item, item.width / 2 + 1, item.height / 2, Qt.LeftButton); |
372 | + tryCompare(tooltipShape, "visible", false); |
373 | + |
374 | + // Mouse motion should should show tooltip again |
375 | + mouseMove(item, item.width / 2, item.height / 2); |
376 | + mouseMove(item, item.width / 2 + 1, item.height / 2); |
377 | + tryCompare(tooltipShape, "visible", true); |
378 | + } |
379 | } |
380 | } |