Merge lp:~azzar1/unity8/launcher-tooltips into lp:unity8

Proposed by Andrea Azzarone
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
Reviewer Review Type Date Requested Status
Unity Team Pending
Review via email: mp+306344@code.launchpad.net

This proposal has been superseded by a proposal from 2016-09-26.

To post a comment you must log in.
lp:~azzar1/unity8/launcher-tooltips updated
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

waitForRendering(launcher) when using revealyByEdgePush

2625. By Andrea Azzarone

Add deps to qml-module-qtqml-statemachine.

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

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== removed file 'qml/Components/UbuntuShapeForItem.qml'
--- qml/Components/UbuntuShapeForItem.qml 2016-03-23 20:05:10 +0000
+++ qml/Components/UbuntuShapeForItem.qml 1970-01-01 00:00:00 +0000
@@ -1,47 +0,0 @@
1/*
2 * Copyright (C) 2012 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.4
18import Ubuntu.Components 1.3
19
20/* FIXME: This component is duplicating the UbuntuShape from the SDK, but shapes more
21 * general (Item-based) components. This ability should be incorporated into the SDK's
22 * UbuntuShape so this file can be removed.
23 * Bug: https://bugs.launchpad.net/tavastia/+bug/1089595
24 */
25
26Item {
27 id: root
28
29 property alias radius: shape.radius
30 property alias image: source.sourceItem
31 property alias aspect: shape.aspect
32
33 ShaderEffectSource {
34 id: source
35 anchors.centerIn: parent // Placed under shape, so it's hidden
36 width: 1
37 height: 1
38 hideSource: true
39 }
40
41 Shape {
42 id: shape
43 image: source
44
45 anchors.fill: parent
46 }
47}
480
=== modified file 'qml/Launcher/LauncherDelegate.qml'
--- qml/Launcher/LauncherDelegate.qml 2016-06-03 11:13:46 +0000
+++ qml/Launcher/LauncherDelegate.qml 2016-09-26 13:07:23 +0000
@@ -22,6 +22,7 @@
2222
23 property int itemIndex: 023 property int itemIndex: 0
24 property string iconName24 property string iconName
25 property string name
25 property int count: 026 property int count: 0
26 property bool countVisible: false27 property bool countVisible: false
27 property int progress: -128 property int progress: -1
2829
=== modified file 'qml/Launcher/LauncherPanel.qml'
--- qml/Launcher/LauncherPanel.qml 2016-07-27 14:51:26 +0000
+++ qml/Launcher/LauncherPanel.qml 2016-09-26 13:07:23 +0000
@@ -15,6 +15,7 @@
15 */15 */
1616
17import QtQuick 2.417import QtQuick 2.4
18import QtQml.StateMachine 1.0 as DSM
18import Ubuntu.Components 1.319import Ubuntu.Components 1.3
19import Unity.Launcher 0.120import Unity.Launcher 0.1
20import Ubuntu.Components.Popups 1.321import Ubuntu.Components.Popups 1.3
@@ -41,7 +42,7 @@
41 signal kbdNavigationCancelled()42 signal kbdNavigationCancelled()
4243
43 onXChanged: {44 onXChanged: {
44 if (quickList.state == "open") {45 if (quickList.state === "open") {
45 quickList.state = ""46 quickList.state = ""
46 }47 }
47 }48 }
@@ -226,6 +227,7 @@
226 // the right app when running autopilot tests for227 // the right app when running autopilot tests for
227 // multiple apps.228 // multiple apps.
228 readonly property string appId: model.appId229 readonly property string appId: model.appId
230 name: model.name
229 itemIndex: index231 itemIndex: index
230 itemHeight: launcherListView.itemHeight232 itemHeight: launcherListView.itemHeight
231 itemWidth: launcherListView.itemWidth233 itemWidth: launcherListView.itemWidth
@@ -399,6 +401,7 @@
399 id: dndArea401 id: dndArea
400 objectName: "dndArea"402 objectName: "dndArea"
401 acceptedButtons: Qt.LeftButton | Qt.RightButton403 acceptedButtons: Qt.LeftButton | Qt.RightButton
404 hoverEnabled: true
402 anchors {405 anchors {
403 fill: parent406 fill: parent
404 topMargin: launcherListView.topMargin407 topMargin: launcherListView.topMargin
@@ -632,7 +635,7 @@
632 }635 }
633 }636 }
634637
635 UbuntuShapeForItem {638 UbuntuShape {
636 id: quickListShape639 id: quickListShape
637 objectName: "quickListShape"640 objectName: "quickListShape"
638 anchors.fill: quickList641 anchors.fill: quickList
@@ -645,7 +648,10 @@
645 UbuntuNumberAnimation {}648 UbuntuNumberAnimation {}
646 }649 }
647650
648 image: quickList651 source: ShaderEffectSource {
652 sourceItem: quickList
653 hideSource: true
654 }
649655
650 Image {656 Image {
651 anchors {657 anchors {
@@ -825,4 +831,145 @@
825 }831 }
826 }832 }
827 }833 }
834
835 UbuntuShape {
836 id: tooltipShape
837 objectName: "tooltipShape"
838 anchors.fill: tooltip
839 opacity: tooltipShownState.active ? 0.95 : 0
840 visible: opacity > 0
841 rotation: root.rotation
842 aspect: UbuntuShape.Flat
843
844 Behavior on opacity {
845 UbuntuNumberAnimation {
846 duration: UbuntuAnimation.BriskDuration
847 }
848 }
849
850 source: ShaderEffectSource {
851 sourceItem: tooltip
852 hideSource: true
853 }
854
855 Image {
856 anchors {
857 right: parent.left
858 rightMargin: -units.dp(4)
859 verticalCenter: parent.verticalCenter
860 verticalCenterOffset: -tooltip.offset * (root.inverted ? -1 : 1)
861 }
862 height: units.gu(1)
863 width: units.gu(2)
864 source: "graphics/quicklist_tooltip.png"
865 rotation: 90
866 }
867 }
868
869 Rectangle {
870 id: tooltip
871 objectName: "tooltip"
872
873 color: theme.palette.normal.background
874 visible: tooltipShape.visible
875
876 width: tooltipLabel.contentWidth + units.gu(4)
877 height: tooltipLabel.contentHeight + units.gu(2)
878
879 y: itemCenter - (height / 2) + offset
880 rotation: root.rotation
881
882 anchors {
883 left: root.inverted ? undefined : parent.right
884 right: root.inverted ? parent.left : undefined
885 margins: units.gu(1)
886 }
887
888 property var hoveredItem: dndArea.containsMouse ? launcherListView.itemAt(dndArea.mouseX, dndArea.mouseY + launcherListView.realContentY) : null
889
890 property int itemCenter
891 property int offset: itemCenter + (height/2) + units.gu(1) > parent.height ? -itemCenter - (height/2) - units.gu(1) + parent.height :
892 itemCenter - (height/2) < units.gu(1) ? (height/2) - itemCenter + units.gu(1) : 0
893
894 // This avoids artifacts on fade-out animation
895 onHoveredItemChanged : {
896 if (hoveredItem != null && !root.moving) {
897 itemCenter = root.mapFromItem(hoveredItem, 0, 0).y + (hoveredItem.height / 2) + hoveredItem.offset
898 tooltipLabel.text = tooltip.hoveredItem.name
899 }
900 }
901
902 Label {
903 id: tooltipLabel
904 height: parent.height
905 anchors.centerIn: parent
906 verticalAlignment: Label.AlignVCenter
907 color: theme.palette.normal.backgroundText
908 }
909
910 DSM.StateMachine {
911 id: tooltipStateMachine
912 initialState: tooltipHiddenState
913 running: true
914
915 DSM.State {
916 id: tooltipHiddenState
917
918 DSM.SignalTransition {
919 targetState: tooltipShownState
920 signal: tooltip.hoveredItemChanged
921 // !dndArea.pressed allows us to filter out touch input events
922 guard: tooltip.hoveredItem != null && !dndArea.pressed && !root.moving
923 }
924 }
925
926 DSM.State {
927 id: tooltipShownState
928
929 DSM.SignalTransition {
930 targetState: tooltipHiddenState
931 signal: tooltip.hoveredItemChanged
932 guard: tooltip.hoveredItem == null
933 }
934
935 DSM.SignalTransition {
936 targetState: tooltipHiddenState
937 signal: dndArea.exited
938 }
939
940 DSM.SignalTransition {
941 targetState: tooltipDismissedState
942 signal: dndArea.onPressed
943 }
944
945 DSM.SignalTransition {
946 targetState: tooltipDismissedState
947 signal: quickList.stateChanged
948 guard: quickList.state === "open"
949 }
950
951 DSM.SignalTransition {
952 targetState: tooltipDismissedState
953 signal: root.movingChanged
954 guard: root.moving
955 }
956 }
957
958 DSM.State {
959 id: tooltipDismissedState
960
961 DSM.SignalTransition {
962 targetState: tooltipHiddenState
963 signal: dndArea.positionChanged
964 guard: quickList.state != "open" && !dndArea.pressed && !dndArea.moving
965 }
966
967 DSM.SignalTransition {
968 targetState: tooltipHiddenState
969 signal: dndArea.exited
970 guard: quickList.state != "open"
971 }
972 }
973 }
974 }
828}975}
829976
=== modified file 'qml/Stages/DesktopSpread.qml'
--- qml/Stages/DesktopSpread.qml 2016-06-15 14:08:18 +0000
+++ qml/Stages/DesktopSpread.qml 2016-09-26 13:07:23 +0000
@@ -311,10 +311,10 @@
311 anchors { left: parent.left; top: parent.top; right: parent.right }311 anchors { left: parent.left; top: parent.top; right: parent.right }
312 spacing: units.gu(1)312 spacing: units.gu(1)
313313
314 UbuntuShapeForItem {314 UbuntuShape {
315 Layout.preferredHeight: Math.min(units.gu(6), root.height * .05)315 Layout.preferredHeight: Math.min(units.gu(6), root.height * .05)
316 Layout.preferredWidth: height * 8 / 7.6316 Layout.preferredWidth: height * 8 / 7.6
317 image: Image {317 source: Image {
318 anchors.fill: parent318 anchors.fill: parent
319 source: model.application.icon319 source: model.application.icon
320 Rectangle {320 Rectangle {
321321
=== modified file 'tests/qmltests/Launcher/tst_Launcher.qml'
--- tests/qmltests/Launcher/tst_Launcher.qml 2016-08-01 11:23:49 +0000
+++ tests/qmltests/Launcher/tst_Launcher.qml 2016-09-26 13:07:23 +0000
@@ -1353,5 +1353,91 @@
1353 mouseWheel(launcherPanel, launcherPanel.width/2, launcherPanel.height/2, Qt.RightButton);1353 mouseWheel(launcherPanel, launcherPanel.width/2, launcherPanel.height/2, Qt.RightButton);
1354 tryCompare(clickThroughSpy, "count", 0);1354 tryCompare(clickThroughSpy, "count", 0);
1355 }1355 }
1356
1357 function test_tooltip() {
1358 launcher.lockedVisible = true;
1359 dragLauncherIntoView();
1360
1361 var item = findChild(launcher, "launcherDelegate0");
1362 var tooltipShape = findChild(launcher, "tooltipShape");
1363
1364 // Make sure we don't start the test with the mouse hovering the launcher
1365 mouseMove(root, root.width, root.height / 2);
1366
1367 // Initial state
1368 tryCompare(tooltipShape, "visible", false);
1369
1370 // Move the mouse on the launcher icon
1371 mouseMove(item, item.width / 2, item.height / 2);
1372 mouseMove(item, item.width / 2 + 1, item.height / 2);
1373 tryCompare(tooltipShape, "visible", true);
1374
1375 // Move the mouse away
1376 mouseMove(root, root.width, root.height / 2);
1377 tryCompare(tooltipShape, "visible", false);
1378 }
1379
1380 function test_quicklist_dismisses_tooltip() {
1381 launcher.lockedVisible = true;
1382 dragLauncherIntoView();
1383
1384 var item = findChild(launcher, "launcherDelegate0");
1385 var tooltipShape = findChild(launcher, "tooltipShape");
1386 var quickListShape = findChild(launcher, "quickListShape");
1387
1388 // Make sure we don't start the test with the mouse hovering the launcher
1389 mouseMove(root, root.width, root.height / 2);
1390
1391 // Initial state
1392 tryCompare(tooltipShape, "visible", false);
1393
1394 // Move the mouse on the launcher icon
1395 mouseMove(item, item.width / 2, item.height / 2);
1396 mouseMove(item, item.width / 2 + 1, item.height / 2);
1397 tryCompare(tooltipShape, "visible", true);
1398
1399 // Right click to show the quicklist
1400 mouseClick(item, item.width / 2, item.height / 2, Qt.RightButton);
1401 tryCompare(quickListShape, "visible", true);
1402 tryCompare(tooltipShape, "visible", false);
1403
1404 // Left click hides the quicklist, tooltip is still dismissed
1405 mouseClick(item, item.width / 2, item.height / 2, Qt.LefftButton);
1406 tryCompare(quickListShape, "visible", false);
1407 tryCompare(tooltipShape, "visible", false);
1408
1409 // Mouse motion should should show tooltip again
1410 mouseMove(item, item.width / 2, item.height / 2);
1411 mouseMove(item, item.width / 2 + 1, item.height / 2);
1412 tryCompare(tooltipShape, "visible", true);
1413 }
1414
1415 function test_click_dismisses_tooltip() {
1416 launcher.lockedVisible = true;
1417 dragLauncherIntoView();
1418
1419 var item = findChild(launcher, "launcherDelegate0");
1420 var tooltipShape = findChild(launcher, "tooltipShape");
1421
1422 // Make sure we don't start the test with the mouse hovering the launcher
1423 mouseMove(root, root.width, root.height / 2);
1424
1425 // Initial state
1426 compare(tooltipShape.visible, false);
1427
1428 // Move the mouse on the launcher icon
1429 mouseMove(item, item.width / 2, item.height / 2);
1430 mouseMove(item, item.width / 2 + 1, item.height / 2);
1431 tryCompare(tooltipShape, "visible", true);
1432
1433 // Left click should dismiss the tooltip
1434 mouseClick(item, item.width / 2 + 1, item.height / 2, Qt.LeftButton);
1435 tryCompare(tooltipShape, "visible", false);
1436
1437 // Mouse motion should should show tooltip again
1438 mouseMove(item, item.width / 2, item.height / 2);
1439 mouseMove(item, item.width / 2 + 1, item.height / 2);
1440 tryCompare(tooltipShape, "visible", true);
1441 }
1356 }1442 }
1357}1443}

Subscribers

People subscribed via source and target branches