diff options
Diffstat (limited to 'examples/bluetooth/lowenergyscanner/Devices.qml')
-rw-r--r-- | examples/bluetooth/lowenergyscanner/Devices.qml | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/examples/bluetooth/lowenergyscanner/Devices.qml b/examples/bluetooth/lowenergyscanner/Devices.qml index 594e6b7d..40afce7f 100644 --- a/examples/bluetooth/lowenergyscanner/Devices.qml +++ b/examples/bluetooth/lowenergyscanner/Devices.qml @@ -22,7 +22,15 @@ Rectangle { Header { id: header anchors.top: parent.top - headerText: "Start Discovery" + headerText: { + if (Device.state) + return "Discovering" + + if (Device.devicesList.length > 0) + return "Select a device" + + return "Start Discovery" + } } Dialog { @@ -50,11 +58,6 @@ Rectangle { border.color: "black" radius: 5 - Component.onCompleted: { - info.visible = false - header.headerText = "Select a device" - } - MouseArea { anchors.fill: parent onClicked: { @@ -103,11 +106,15 @@ Rectangle { menuHeight: (parent.height / 6) menuText: Device.update onButtonClick: { - Device.startDeviceDiscovery() - // if startDeviceDiscovery() failed Device.state is not set - if (Device.state) { - info.dialogText = "Searching..." - info.visible = true + if (!Device.state) { + Device.startDeviceDiscovery() + // if startDeviceDiscovery() failed Device.state is not set + if (Device.state) { + info.dialogText = "Searching..." + info.visible = true + } + } else { + Device.stopDeviceDiscovery() } } } |