From 23b9dd14f1059fb7472db51bea5c1cdea8fe6a5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= Date: Sun, 5 Jan 2014 04:23:18 +0100 Subject: [PATCH] Add test for PlasmaCore.ToolTip.target property This uses a MouseEventListener and a MouseArea to test whether the tooltip redirects events, and tests a common implementation scenario with one shared tooltip. This test (willingly) exposes a problem that with the MouseArea, we filter out all mouse events, and the target loses input. I.e. the last image in the row doesn't receive the click. --- .../testcomponents/contents/ui/IconsPage.qml | 48 +++++++++++++++++-- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/examples/applets/testcomponents/contents/ui/IconsPage.qml b/examples/applets/testcomponents/contents/ui/IconsPage.qml index 794c43080..7140b7ce8 100644 --- a/examples/applets/testcomponents/contents/ui/IconsPage.qml +++ b/examples/applets/testcomponents/contents/ui/IconsPage.qml @@ -96,7 +96,7 @@ PlasmaComponents.Page { objectName: "akonadiIcon" source: "akonadi" width: height - height: _h*2 + height: _h //anchors.horizontalCenter: parent.horizontalCenter Rectangle { color: "orange"; opacity: 0.3; anchors.fill: parent; } PlasmaCore.ToolTip { @@ -109,7 +109,7 @@ PlasmaComponents.Page { } Image { objectName: "bridgeimage" - height: _h*2 + height: _h width: height fillMode: Image.PreserveAspectFit source: "../images/bridge.jpg" @@ -122,7 +122,7 @@ PlasmaComponents.Page { } Image { objectName: "surfboardimage" - height: _h*2 + height: _h width: height fillMode: Image.PreserveAspectFit source: "../images/surfboard.jpg" @@ -139,6 +139,48 @@ PlasmaComponents.Page { //across the water from Nijmegen, Netherlands. It was taken during the summer festivals a few years back." } } + + + QtExtras.MouseEventListener { + id: task1 + + width: height + height: _h*2 + + hoverEnabled: true + + onContainsMouseChanged: { + if (containsMouse) { + print("Setting target to task1"); + tooltip.target = task1; + tooltip.mainText = "Bridge" + tooltip.subText = "in Nijmegen" + } else { + print("Setting target to null"); + tooltip.target = null; + } + } + Image { + objectName: "bridgeimage1" + anchors.fill: parent + fillMode: Image.PreserveAspectFit + source: "../images/bridge.jpg" + MouseArea { + anchors.fill: parent + onClicked: { + print("bridgeimage1 clicked"); + } + } + } + } + + } } + + PlasmaCore.ToolTip { + id: tooltip + target: null + } + }