on xenial help sign in
Refactor the way we deal with tooltip delay timer.
c2796abAndrea Azzarone
qml/Launcher/LauncherPanel.qml+2−21
@@ -845,18 +845,10 @@ Rectangle {
845 margins: units.gu(1)
845 margins: units.gu(1)
846 }
846 }
847
847
848− Binding on text {
849− when: !!tooltipShape.hoveredItem
850− value: !!tooltipShape.hoveredItem ? tooltipShape.hoveredItem.name : ""
851− }
852−
853 property var hoveredItem: dndArea.containsMouse ? launcherListView.itemAt(dndArea.mouseX, dndArea.mouseY + launcherListView.realContentY) : null
848 property var hoveredItem: dndArea.containsMouse ? launcherListView.itemAt(dndArea.mouseX, dndArea.mouseY + launcherListView.realContentY) : null
854− property int itemCenter: 0
849+ property int itemCenter: hoveredItem ? root.mapFromItem(hoveredItem, 0, 0).y + (hoveredItem.height / 2) + hoveredItem.offset : 0
855
850
856− Binding on itemCenter {
851+ text: hoveredItem ? hoveredItem.name : ""
857− when: !!tooltipShape.hoveredItem
858− value: !!tooltipShape.hoveredItem ? root.mapFromItem(tooltipShape.hoveredItem, 0, 0).y + (tooltipShape.hoveredItem.height / 2) + tooltipShape.hoveredItem.offset : 0
859− }
860 }
852 }
861
853
862 DSM.StateMachine {
854 DSM.StateMachine {
@@ -884,11 +876,6 @@ Rectangle {
884 guard: tooltipShape.hoveredItem == null
876 guard: tooltipShape.hoveredItem == null
885 }
877 }
886
878
887− DSM.SignalTransition {
888− targetState: tooltipHiddenState
889− signal: dndArea.exited
890− }
891−
892 DSM.SignalTransition {
879 DSM.SignalTransition {
893 targetState: tooltipDismissedState
880 targetState: tooltipDismissedState
894 signal: dndArea.onPressed
881 signal: dndArea.onPressed
@@ -899,12 +886,6 @@ Rectangle {
899 signal: quickList.stateChanged
886 signal: quickList.stateChanged
900 guard: quickList.state === "open"
887 guard: quickList.state === "open"
901 }
888 }
902−
903− DSM.SignalTransition {
904− targetState: tooltipDismissedState
905− signal: root.movingChanged
906− guard: root.moving
907− }
908 }
889 }
909
890
910 DSM.State {
891 DSM.State {
qml/Launcher/Tooltip.qml+24−21
@@ -21,8 +21,8 @@ UbuntuShape {
21 id: root
21 id: root
22
22
23 // This property holds the delay (milliseconds) after which the tool tip is shown.
23 // This property holds the delay (milliseconds) after which the tool tip is shown.
24− // A tooltip with a negative delay is shown immediately. The default value is UbuntuAnimation.SlowDuration.
24+ // A tooltip with a negative delay is shown immediately. The default value is 500 ms.
25− property alias delay: delayTimer.interval
25+ property int delay: 500
26
26
27 // This property holds the text shown on the tool tip.
27 // This property holds the text shown on the tool tip.
28 property alias text: label.text
28 property alias text: label.text
@@ -31,25 +31,7 @@ UbuntuShape {
31 color: theme.palette.normal.background
31 color: theme.palette.normal.background
32 width: label.implicitWidth + units.gu(4)
32 width: label.implicitWidth + units.gu(4)
33 height: label.implicitHeight + units.gu(2)
33 height: label.implicitHeight + units.gu(2)
34−
35− Behavior on opacity {
34+ opacity: 0
36− UbuntuNumberAnimation {
37− duration: UbuntuAnimation.BriskDuration
38− }
39− }
40−
41− Binding on opacity {
42− when: !visible
43− value: 0
44− }
45−
46− Timer {
47− id: delayTimer
48− running: root.visible
49− triggeredOnStart: true
50− interval: UbuntuAnimation.SlowDuration
51− onTriggered: root.opacity = (running ? .0 : .95)
52− }
53
35
54 Image {
36 Image {
55 anchors {
37 anchors {
@@ -66,4 +48,25 @@ UbuntuShape {
66 anchors.centerIn: parent
48 anchors.centerIn: parent
67 color: theme.palette.normal.backgroundText
49 color: theme.palette.normal.backgroundText
68 }
50 }
51+
52+ states: [
53+ State {
54+ name: "visible"
55+ when: root.visible
56+ PropertyChanges {
57+ target: root
58+ opacity: 0.95
59+ }
60+ }
61+ ]
62+
63+ transitions: [
64+ Transition {
65+ from: ""; to: "visible"
66+ SequentialAnimation {
67+ PauseAnimation { duration: root.delay }
68+ UbuntuNumberAnimation { target: root; property: "opacity"; duration: UbuntuAnimation.BriskDuration }
69+ }
70+ }
71+ ]
69}
72}
tests/qmltests/Launcher/tst_Launcher.qml+13−1
@@ -1366,15 +1366,18 @@ Rectangle {
1366
1366
1367 // Initial state
1367 // Initial state
1368 tryCompare(tooltipShape, "visible", false);
1368 tryCompare(tooltipShape, "visible", false);
1369+ tryCompare(tooltipShape, "opacity", .0);
1369
1370
1370 // Move the mouse on the launcher icon
1371 // Move the mouse on the launcher icon
1371 mouseMove(item, item.width / 2, item.height / 2, 10);
1372 mouseMove(item, item.width / 2, item.height / 2, 10);
1372 mouseMove(item, item.width / 2 + 1, item.height / 2, 10);
1373 mouseMove(item, item.width / 2 + 1, item.height / 2, 10);
1373 tryCompare(tooltipShape, "visible", true);
1374 tryCompare(tooltipShape, "visible", true);
1375+ tryCompare(tooltipShape, "opacity", .95);
1374
1376
1375 // Move the mouse away
1377 // Move the mouse away
1376 mouseMove(root, root.width, root.height / 2, 10);
1378 mouseMove(root, root.width, root.height / 2, 10);
1377 tryCompare(tooltipShape, "visible", false);
1379 tryCompare(tooltipShape, "visible", false);
1380+ tryCompare(tooltipShape, "opacity", .0);
1378 }
1381 }
1379
1382
1380 function test_quicklist_dismisses_tooltip() {
1383 function test_quicklist_dismisses_tooltip() {
@@ -1390,26 +1393,31 @@ Rectangle {
1390
1393
1391 // Initial state
1394 // Initial state
1392 tryCompare(tooltipShape, "visible", false);
1395 tryCompare(tooltipShape, "visible", false);
1396+ tryCompare(tooltipShape, "opacity", .0);
1393
1397
1394 // Move the mouse on the launcher icon
1398 // Move the mouse on the launcher icon
1395 mouseMove(item, item.width / 2, item.height / 2, 10);
1399 mouseMove(item, item.width / 2, item.height / 2, 10);
1396 mouseMove(item, item.width / 2 + 1, item.height / 2, 10);
1400 mouseMove(item, item.width / 2 + 1, item.height / 2, 10);
1397 tryCompare(tooltipShape, "visible", true);
1401 tryCompare(tooltipShape, "visible", true);
1402+ tryCompare(tooltipShape, "opacity", .95);
1398
1403
1399 // Right click to show the quicklist
1404 // Right click to show the quicklist
1400 mouseClick(item, item.width / 2, item.height / 2, Qt.RightButton);
1405 mouseClick(item, item.width / 2, item.height / 2, Qt.RightButton);
1401 tryCompare(quickListShape, "visible", true);
1406 tryCompare(quickListShape, "visible", true);
1402 tryCompare(tooltipShape, "visible", false);
1407 tryCompare(tooltipShape, "visible", false);
1408+ tryCompare(tooltipShape, "opacity", .0);
1403
1409
1404 // Left click hides the quicklist, tooltip is still dismissed
1410 // Left click hides the quicklist, tooltip is still dismissed
1405 mouseClick(item, item.width / 2, item.height / 2, Qt.LefftButton);
1411 mouseClick(item, item.width / 2, item.height / 2, Qt.LefftButton);
1406 tryCompare(quickListShape, "visible", false);
1412 tryCompare(quickListShape, "visible", false);
1407 tryCompare(tooltipShape, "visible", false);
1413 tryCompare(tooltipShape, "visible", false);
1414+ tryCompare(tooltipShape, "opacity", .0);
1408
1415
1409 // Mouse motion should should show tooltip again
1416 // Mouse motion should should show tooltip again
1410 mouseMove(item, item.width / 2, item.height / 2, 10);
1417 mouseMove(item, item.width / 2, item.height / 2, 10);
1411 mouseMove(item, item.width / 2 + 1, item.height / 2, 10);
1418 mouseMove(item, item.width / 2 + 1, item.height / 2, 10);
1412 tryCompare(tooltipShape, "visible", true);
1419 tryCompare(tooltipShape, "visible", true);
1420+ tryCompare(tooltipShape, "opacity", .95);
1413 }
1421 }
1414
1422
1415 function test_click_dismisses_tooltip() {
1423 function test_click_dismisses_tooltip() {
@@ -1423,21 +1431,25 @@ Rectangle {
1423 mouseMove(root, root.width, root.height / 2, 10);
1431 mouseMove(root, root.width, root.height / 2, 10);
1424
1432
1425 // Initial state
1433 // Initial state
1426− compare(tooltipShape.visible, false);
1434+ tryCompare(tooltipShape, "visible", false);
1435+ tryCompare(tooltipShape, "opacity", .0);
1427
1436
1428 // Move the mouse on the launcher icon
1437 // Move the mouse on the launcher icon
1429 mouseMove(item, item.width / 2, item.height / 2, 10);
1438 mouseMove(item, item.width / 2, item.height / 2, 10);
1430 mouseMove(item, item.width / 2 + 1, item.height / 2, 10);
1439 mouseMove(item, item.width / 2 + 1, item.height / 2, 10);
1431 tryCompare(tooltipShape, "visible", true);
1440 tryCompare(tooltipShape, "visible", true);
1441+ tryCompare(tooltipShape, "opacity", .95);
1432
1442
1433 // Left click should dismiss the tooltip
1443 // Left click should dismiss the tooltip
1434 mouseClick(item, item.width / 2 + 1, item.height / 2, Qt.LeftButton);
1444 mouseClick(item, item.width / 2 + 1, item.height / 2, Qt.LeftButton);
1435 tryCompare(tooltipShape, "visible", false);
1445 tryCompare(tooltipShape, "visible", false);
1446+ tryCompare(tooltipShape, "opacity", .0);
1436
1447
1437 // Mouse motion should should show tooltip again
1448 // Mouse motion should should show tooltip again
1438 mouseMove(item, item.width / 2, item.height / 2, 10);
1449 mouseMove(item, item.width / 2, item.height / 2, 10);
1439 mouseMove(item, item.width / 2 + 1, item.height / 2, 10);
1450 mouseMove(item, item.width / 2 + 1, item.height / 2, 10);
1440 tryCompare(tooltipShape, "visible", true);
1451 tryCompare(tooltipShape, "visible", true);
1452+ tryCompare(tooltipShape, "opacity", .95);
1441 }
1453 }
1442 }
1454 }
1443}
1455}