summaryrefslogtreecommitdiffstats
path: root/examples/bluetooth/pingpong/assets/Board.qml
diff options
context:
space:
mode:
authorAndreas Buhr <andreas@andreasbuhr.de>2021-03-02 15:07:29 +0100
committerAndreas Buhr <andreas@andreasbuhr.de>2021-03-03 11:15:10 +0100
commitfe8ee784031c3a42ac2515878b7aa8a129fc140e (patch)
tree01bfbc7d3e42fd8568e1798ab01c96cc3ff19c75 /examples/bluetooth/pingpong/assets/Board.qml
parentd031ee460d4945ebc2c13961591bf56f221950f4 (diff)
Pingpong example: move properties and event handlers
Reorganize code to have graphical elements and event handlers separated Change-Id: I64480649e7bf077b0e63193250a4cb0fe6be699d Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'examples/bluetooth/pingpong/assets/Board.qml')
-rw-r--r--examples/bluetooth/pingpong/assets/Board.qml74
1 files changed, 37 insertions, 37 deletions
diff --git a/examples/bluetooth/pingpong/assets/Board.qml b/examples/bluetooth/pingpong/assets/Board.qml
index 61e6bc45..c29f4da2 100644
--- a/examples/bluetooth/pingpong/assets/Board.qml
+++ b/examples/bluetooth/pingpong/assets/Board.qml
@@ -56,31 +56,6 @@ Rectangle {
width: 600
height: 300
- // 1 - server role; left pedal
- // 2 - client role; right pedal
- property int roleSide: pingPong.role
- onRoleSideChanged: {
- if (pingPong.role == 1) {
- rightMouse.opacity = 0.7
- rightMouse.enabled = false
- }
- else if (pingPong.role == 2) {
- leftMouse.opacity = 0.7
- leftMouse.enabled = false
- }
- }
-
- property bool deviceMessage: pingPong.showDialog
- onDeviceMessageChanged: {
- if (pingPong.showDialog) {
- info.visible = true;
- board.opacity = 0.5;
- } else {
- info.visible = false;
- board.opacity = 1;
- }
- }
-
// Left pedal - server role
Rectangle {
id: leftblock
@@ -123,18 +98,6 @@ Rectangle {
}
}
- property double leftBlockY: leftblock.y
- onLeftBlockYChanged: pingPong.updateLeftBlock(leftblock.y)
-
- property double leftBlockUpdate: pingPong.leftBlockY
- onLeftBlockUpdateChanged: leftblock.y = pingPong.leftBlockY
-
- property double rightBlockY: rightblock.y
- onRightBlockYChanged: pingPong.updateRightBlock(rightblock.y)
-
- property double rightBlockUpdate: pingPong.rightBlockY
- onRightBlockUpdateChanged: rightblock.y = pingPong.rightBlockY
-
Rectangle {
id: splitter
color: "#363636"
@@ -179,6 +142,43 @@ Rectangle {
}
}
+ // 1 - server role; left pedal
+ // 2 - client role; right pedal
+ property int roleSide: pingPong.role
+ onRoleSideChanged: {
+ if (pingPong.role == 1) {
+ rightMouse.opacity = 0.7
+ rightMouse.enabled = false
+ }
+ else if (pingPong.role == 2) {
+ leftMouse.opacity = 0.7
+ leftMouse.enabled = false
+ }
+ }
+
+ property bool deviceMessage: pingPong.showDialog
+ onDeviceMessageChanged: {
+ if (pingPong.showDialog) {
+ info.visible = true;
+ board.opacity = 0.5;
+ } else {
+ info.visible = false;
+ board.opacity = 1;
+ }
+ }
+
+ property double leftBlockY: leftblock.y
+ onLeftBlockYChanged: pingPong.updateLeftBlock(leftblock.y)
+
+ property double leftBlockUpdate: pingPong.leftBlockY
+ onLeftBlockUpdateChanged: leftblock.y = pingPong.leftBlockY
+
+ property double rightBlockY: rightblock.y
+ onRightBlockYChanged: pingPong.updateRightBlock(rightblock.y)
+
+ property double rightBlockUpdate: pingPong.rightBlockY
+ onRightBlockUpdateChanged: rightblock.y = pingPong.rightBlockY
+
Component.onCompleted: {
if (menulist.height == Screen.height && menulist.width == Screen.width)
pingPong.setSize(Screen.width, Screen.height)