aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2022-09-13 15:31:56 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2022-09-16 20:01:32 +0200
commite43e17d9f8aa1d5fffbf87127cd6235497d6e3e6 (patch)
treed8775b78ad3447fb646f48f11b82dc936a54751f
parent5383feab9f12f2a2640470c705bd8523a9686a97 (diff)
Add hover enable/disable checkboxes to lesHoverables autotest qml
This isn't needed for the autotest, but we sometimes use this qml file for manual testing. Control-h toggles the upper HoverHandler enabled state, and Control-m toggles the MouseArea hoverEnabled state; that way it's possible to test that hover feedback disappears even if the mouse isn't moved. However, flushFrameSynchronousEvents() currently gets called only if some items are marked dirty; so if we don't change the checkbox appearance, _and_ we use only keyboard shortcuts to change the enabled state, this demonstrates that we still have bugs: we don't immediately update the containsMouse and hovered properties when the respective objects have their hover processing en-/disabled. While we're at it: stop using Loader, use named components instead. Task-number: QTBUG-46460 Change-Id: Ib7aecf4788621a7d5cf0b9461ca56553610120ec Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
-rw-r--r--tests/auto/quick/pointerhandlers/qquickhoverhandler/data/lesHoverables.qml141
1 files changed, 89 insertions, 52 deletions
diff --git a/tests/auto/quick/pointerhandlers/qquickhoverhandler/data/lesHoverables.qml b/tests/auto/quick/pointerhandlers/qquickhoverhandler/data/lesHoverables.qml
index 612940ecab..ac962d5677 100644
--- a/tests/auto/quick/pointerhandlers/qquickhoverhandler/data/lesHoverables.qml
+++ b/tests/auto/quick/pointerhandlers/qquickhoverhandler/data/lesHoverables.qml
@@ -9,59 +9,89 @@ Rectangle {
height: 480
color: "#444"
- Component {
- id: buttonsAndStuff
- Column {
- anchors.fill: parent
- anchors.margins: 8
- spacing: 8
-
- Rectangle {
- objectName: "buttonWithMA"
- width: parent.width
- height: 30
- color: buttonMA.pressed ? "lightsteelblue" : "#999"
- border.color: buttonMA.containsMouse ? "cyan" : "transparent"
-
- MouseArea {
- id: buttonMA
- objectName: "buttonMA"
- hoverEnabled: true
- cursorShape: Qt.UpArrowCursor
- anchors.fill: parent
- onClicked: console.log("clicked MA")
- }
+ component CheckBox: Row {
+ id: cbRoot
+ property bool checked : true
+ property string label : "CheckBox"
+ spacing: 4
+ Rectangle {
+ width: 16; height: 16
+ // comment out this color change to test whether we rely on "dirty" items to
+ // trigger QQuickDeliveryAgentPrivate::flushFrameSynchronousEvents() to update hover state
+ color: cbRoot.checked ? "cadetblue" : "transparent"
+ border.color: "black"
+ TapHandler { onTapped: cbRoot.checked = !cbRoot.checked }
+ }
+ Text { text: cbRoot.label }
+ }
- Text {
- anchors.centerIn: parent
- text: "MouseArea"
- }
+ component ButtonsAndStuff: Column {
+ anchors.fill: parent
+ anchors.margins: 8
+ spacing: 8
+ function toggleMAHover() { maButtonHoverCB.checked = !maButtonHoverCB.checked }
+ function toggleHHEnabled() { hhButtonHoverCB.checked = !hhButtonHoverCB.checked }
+
+ CheckBox {
+ id: maButtonHoverCB
+ label: "hover enabled"
+ }
+
+ Rectangle {
+ objectName: "buttonWithMA"
+ width: parent.width
+ height: 30
+ color: buttonMA.pressed ? "lightsteelblue" : "#999"
+ border.color: buttonMA.containsMouse ? "cyan" : "transparent"
+
+ MouseArea {
+ id: buttonMA
+ objectName: "buttonMA"
+ hoverEnabled: maButtonHoverCB.checked
+ cursorShape: Qt.UpArrowCursor
+ anchors.fill: parent
}
- Rectangle {
- objectName: "buttonWithHH"
- width: parent.width
- height: 30
- color: flash ? "#999" : "white"
- border.color: buttonHH.hovered ? "cyan" : "transparent"
- property bool flash: true
-
- HoverHandler {
- id: buttonHH
- objectName: "buttonHH"
- acceptedDevices: PointerDevice.AllDevices
- cursorShape: tapHandler.pressed ? Qt.BusyCursor : Qt.PointingHandCursor
- }
+ Text {
+ anchors.centerIn: parent
+ text: "MouseArea"
+ }
+ }
- TapHandler {
- id: tapHandler
- }
+ CheckBox {
+ id: hhButtonHoverCB
+ label: "hover enabled"
+ }
- Text {
- anchors.centerIn: parent
- text: "HoverHandler"
+ Rectangle {
+ id: buttonRoot
+ objectName: "buttonWithHH"
+ width: parent.width
+ height: 30
+ color: flash ? "#999" : "white"
+ border.color: buttonHH.hovered ? "cyan" : "transparent"
+ property bool flash: true
+
+ HoverHandler {
+ id: buttonHH
+ objectName: "buttonHH"
+ acceptedDevices: PointerDevice.AllDevices
+ enabled: hhButtonHoverCB.checked
+ cursorShape: tapHandler.pressed ? Qt.BusyCursor : Qt.PointingHandCursor
+ }
+
+ TapHandler {
+ id: tapHandler
+ onTapped: {
+ console.log("buttonRoot tapped")
+ buttonHH.enabled = !buttonHH.enabled
}
}
+
+ Text {
+ anchors.centerIn: parent
+ text: "HoverHandler"
+ }
}
}
@@ -109,10 +139,18 @@ Rectangle {
cursorShape: Qt.OpenHandCursor
}
- Loader {
- objectName: "topSidebarLoader"
- sourceComponent: buttonsAndStuff
+ ButtonsAndStuff {
+ id: tbs
+ objectName: "topSidebarContents"
anchors.fill: parent
+ Shortcut {
+ sequence: "Ctrl+M"
+ onActivated: tbs.toggleMAHover()
+ }
+ Shortcut {
+ sequence: "Ctrl+H"
+ onActivated: tbs.toggleHHEnabled()
+ }
}
}
@@ -136,9 +174,8 @@ Rectangle {
anchors.fill: parent
}
- Loader {
- objectName: "bottomSidebarLoader"
- sourceComponent: buttonsAndStuff
+ ButtonsAndStuff {
+ objectName: "bottomSidebarContents"
anchors.fill: parent
}
}