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.
This commit is contained in:
parent
160e97cbba
commit
23b9dd14f1
@ -96,7 +96,7 @@ PlasmaComponents.Page {
|
|||||||
objectName: "akonadiIcon"
|
objectName: "akonadiIcon"
|
||||||
source: "akonadi"
|
source: "akonadi"
|
||||||
width: height
|
width: height
|
||||||
height: _h*2
|
height: _h
|
||||||
//anchors.horizontalCenter: parent.horizontalCenter
|
//anchors.horizontalCenter: parent.horizontalCenter
|
||||||
Rectangle { color: "orange"; opacity: 0.3; anchors.fill: parent; }
|
Rectangle { color: "orange"; opacity: 0.3; anchors.fill: parent; }
|
||||||
PlasmaCore.ToolTip {
|
PlasmaCore.ToolTip {
|
||||||
@ -109,7 +109,7 @@ PlasmaComponents.Page {
|
|||||||
}
|
}
|
||||||
Image {
|
Image {
|
||||||
objectName: "bridgeimage"
|
objectName: "bridgeimage"
|
||||||
height: _h*2
|
height: _h
|
||||||
width: height
|
width: height
|
||||||
fillMode: Image.PreserveAspectFit
|
fillMode: Image.PreserveAspectFit
|
||||||
source: "../images/bridge.jpg"
|
source: "../images/bridge.jpg"
|
||||||
@ -122,7 +122,7 @@ PlasmaComponents.Page {
|
|||||||
}
|
}
|
||||||
Image {
|
Image {
|
||||||
objectName: "surfboardimage"
|
objectName: "surfboardimage"
|
||||||
height: _h*2
|
height: _h
|
||||||
width: height
|
width: height
|
||||||
fillMode: Image.PreserveAspectFit
|
fillMode: Image.PreserveAspectFit
|
||||||
source: "../images/surfboard.jpg"
|
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."
|
//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
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user