summaryrefslogtreecommitdiff
path: root/examples/quick
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2023-01-03 17:00:33 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2023-01-05 06:04:16 +0100
commitcae32cb2ec0df3eb6f5e048259b90fe3d182f479 (patch)
treeaf81d7a6c86a1be86e069abd6c428df00d9af0e1 /examples/quick
parent051d7dd9555381274b399183dd425ca2ae8c9d5a (diff)
downloadqtdeclarative-cae32cb2ec0df3eb6f5e048259b90fe3d182f479.tar.gz
Use inline component in sidebar example rather than Loader
Originally in ca9e2a0d7488cbbb94d8343c43eb49c6ee5f6519 I used Loader as a way of reusing some content in two places in one QML file, not necessarily to test hover behavior with Loader. Inline components are a little cleaner. Pick-to: 6.2 6.4 6.5 Change-Id: Ib064bdb460704bec0c714550d8935dcef8af0637 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Diffstat (limited to 'examples/quick')
-rw-r--r--examples/quick/pointerhandlers/sidebar.qml121
1 files changed, 57 insertions, 64 deletions
diff --git a/examples/quick/pointerhandlers/sidebar.qml b/examples/quick/pointerhandlers/sidebar.qml
index 187e535d92..55857cf733 100644
--- a/examples/quick/pointerhandlers/sidebar.qml
+++ b/examples/quick/pointerhandlers/sidebar.qml
@@ -10,69 +10,66 @@ Rectangle {
height: 480
color: rootHover.hovered ? "#555" : "#444"
- Component {
- id: buttonsAndStuff
- Column {
- anchors.fill: parent
- anchors.margins: 8
- spacing: 8
+ component ButtonsAndStuff: Column {
+ anchors.fill: parent
+ anchors.margins: 8
+ spacing: 8
+
+ CheckBox {
+ id: hoverBlockingCB
+ text: "Button hover is blocking"
+ }
+
+ 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")
+ }
+
+ Text {
+ anchors.centerIn: parent
+ text: "MouseArea"
+ }
+ }
+
+ 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
+ blocking: hoverBlockingCB.checked
+ cursorShape: tapHandler.pressed ? Qt.BusyCursor : Qt.PointingHandCursor
+ }
- CheckBox {
- id: hoverBlockingCB
- text: "Button hover is blocking"
+ TapHandler {
+ id: tapHandler
+ onTapped: tapFlash.start()
}
- 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")
- }
-
- Text {
- anchors.centerIn: parent
- text: "MouseArea"
- }
+ Text {
+ anchors.centerIn: parent
+ text: "HoverHandler"
}
- 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
- blocking: hoverBlockingCB.checked
- cursorShape: tapHandler.pressed ? Qt.BusyCursor : Qt.PointingHandCursor
- }
-
- TapHandler {
- id: tapHandler
- onTapped: tapFlash.start()
- }
-
- Text {
- anchors.centerIn: parent
- text: "HoverHandler"
- }
-
- FlashAnimation on flash {
- id: tapFlash
- }
+ FlashAnimation on flash {
+ id: tapFlash
}
}
}
@@ -135,9 +132,7 @@ Rectangle {
cursorShape: Qt.OpenHandCursor
}
- Loader {
- objectName: "topSidebarLoader"
- sourceComponent: buttonsAndStuff
+ ButtonsAndStuff {
anchors.fill: parent
}
@@ -166,9 +161,7 @@ Rectangle {
cursorShape: Qt.ClosedHandCursor
anchors.fill: parent
- Loader {
- objectName: "bottomSidebarLoader"
- sourceComponent: buttonsAndStuff
+ ButtonsAndStuff {
anchors.fill: parent
}
}