summaryrefslogtreecommitdiffstats
path: root/examples/bluetooth/heartrate-game
diff options
context:
space:
mode:
Diffstat (limited to 'examples/bluetooth/heartrate-game')
-rw-r--r--examples/bluetooth/heartrate-game/App.qml99
-rw-r--r--examples/bluetooth/heartrate-game/BluetoothAlarmDialog.qml80
-rw-r--r--examples/bluetooth/heartrate-game/BottomLine.qml11
-rw-r--r--examples/bluetooth/heartrate-game/CMakeLists.txt91
-rw-r--r--examples/bluetooth/heartrate-game/Connect.qml155
-rw-r--r--examples/bluetooth/heartrate-game/GameButton.qml39
-rw-r--r--examples/bluetooth/heartrate-game/GamePage.qml77
-rw-r--r--examples/bluetooth/heartrate-game/GameSettings.qml61
-rw-r--r--examples/bluetooth/heartrate-game/Main.qml71
-rw-r--r--examples/bluetooth/heartrate-game/Measure.qml325
-rw-r--r--examples/bluetooth/heartrate-game/SplashScreen.qml30
-rw-r--r--examples/bluetooth/heartrate-game/Stats.qml80
-rw-r--r--examples/bluetooth/heartrate-game/StatsLabel.qml34
-rw-r--r--examples/bluetooth/heartrate-game/TitleBar.qml63
-rw-r--r--examples/bluetooth/heartrate-game/bluetoothbaseclass.cpp65
-rw-r--r--examples/bluetooth/heartrate-game/bluetoothbaseclass.h72
-rw-r--r--examples/bluetooth/heartrate-game/connectionhandler.cpp107
-rw-r--r--examples/bluetooth/heartrate-game/connectionhandler.h66
-rw-r--r--examples/bluetooth/heartrate-game/devicefinder.cpp168
-rw-r--r--examples/bluetooth/heartrate-game/devicefinder.h72
-rw-r--r--examples/bluetooth/heartrate-game/devicehandler.cpp136
-rw-r--r--examples/bluetooth/heartrate-game/devicehandler.h78
-rw-r--r--examples/bluetooth/heartrate-game/deviceinfo.cpp68
-rw-r--r--examples/bluetooth/heartrate-game/deviceinfo.h57
-rw-r--r--examples/bluetooth/heartrate-game/doc/images/heartgame-result.pngbin9468 -> 0 bytes
-rw-r--r--examples/bluetooth/heartrate-game/doc/images/heartgame-result.webpbin0 -> 23682 bytes
-rw-r--r--examples/bluetooth/heartrate-game/doc/images/heartgame-running.pngbin10951 -> 0 bytes
-rw-r--r--examples/bluetooth/heartrate-game/doc/images/heartgame-running.webpbin0 -> 24072 bytes
-rw-r--r--examples/bluetooth/heartrate-game/doc/images/heartgame-search.pngbin14591 -> 0 bytes
-rw-r--r--examples/bluetooth/heartrate-game/doc/images/heartgame-search.webpbin0 -> 29732 bytes
-rw-r--r--examples/bluetooth/heartrate-game/doc/images/heartgame-start.pngbin13214 -> 0 bytes
-rw-r--r--examples/bluetooth/heartrate-game/doc/images/heartgame-start.webpbin0 -> 33590 bytes
-rw-r--r--examples/bluetooth/heartrate-game/doc/src/heartrate-game.qdoc61
-rw-r--r--examples/bluetooth/heartrate-game/heartrate-game.pro38
-rw-r--r--examples/bluetooth/heartrate-game/heartrate-global.h58
-rw-r--r--examples/bluetooth/heartrate-game/images.qrc7
-rw-r--r--examples/bluetooth/heartrate-game/images/alert.svg4
-rw-r--r--examples/bluetooth/heartrate-game/images/bluetooth.svg3
-rw-r--r--examples/bluetooth/heartrate-game/images/bt_off_to_on.png (renamed from examples/bluetooth/heartrate-game/qml/images/bt_off_to_on.png)bin6143 -> 6143 bytes
-rw-r--r--examples/bluetooth/heartrate-game/images/clock.svg4
-rw-r--r--examples/bluetooth/heartrate-game/images/heart.pngbin0 -> 2318 bytes
-rw-r--r--examples/bluetooth/heartrate-game/images/logo.png (renamed from examples/bluetooth/heartrate-game/qml/images/logo.png)bin31915 -> 31915 bytes
-rw-r--r--examples/bluetooth/heartrate-game/images/progress.svg4
-rw-r--r--examples/bluetooth/heartrate-game/images/search.svg4
-rw-r--r--examples/bluetooth/heartrate-game/main.cpp102
-rw-r--r--examples/bluetooth/heartrate-game/qml.qrc18
-rw-r--r--examples/bluetooth/heartrate-game/qml/App.qml130
-rw-r--r--examples/bluetooth/heartrate-game/qml/BluetoothAlarmDialog.qml122
-rw-r--r--examples/bluetooth/heartrate-game/qml/BottomLine.qml59
-rw-r--r--examples/bluetooth/heartrate-game/qml/Connect.qml188
-rw-r--r--examples/bluetooth/heartrate-game/qml/GameButton.qml88
-rw-r--r--examples/bluetooth/heartrate-game/qml/GamePage.qml93
-rw-r--r--examples/bluetooth/heartrate-game/qml/GameSettings.qml101
-rw-r--r--examples/bluetooth/heartrate-game/qml/Measure.qml244
-rw-r--r--examples/bluetooth/heartrate-game/qml/SplashScreen.qml90
-rw-r--r--examples/bluetooth/heartrate-game/qml/Stats.qml99
-rw-r--r--examples/bluetooth/heartrate-game/qml/StatsLabel.qml82
-rw-r--r--examples/bluetooth/heartrate-game/qml/TitleBar.qml97
-rw-r--r--examples/bluetooth/heartrate-game/qml/images/heart.pngbin2664 -> 0 bytes
-rw-r--r--examples/bluetooth/heartrate-game/qml/main.qml105
-rw-r--r--examples/bluetooth/heartrate-game/qml/qmldir1
-rw-r--r--examples/bluetooth/heartrate-game/qmldir15
62 files changed, 1636 insertions, 2286 deletions
diff --git a/examples/bluetooth/heartrate-game/App.qml b/examples/bluetooth/heartrate-game/App.qml
new file mode 100644
index 00000000..db6aa714
--- /dev/null
+++ b/examples/bluetooth/heartrate-game/App.qml
@@ -0,0 +1,99 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Layouts
+import HeartRateGame
+
+Item {
+ id: app
+
+ required property ConnectionHandler connectionHandler
+ required property DeviceFinder deviceFinder
+ required property DeviceHandler deviceHandler
+
+ anchors.fill: parent
+ opacity: 0.0
+
+ Behavior on opacity {
+ NumberAnimation {
+ duration: 500
+ }
+ }
+
+ property int __currentIndex: 0
+
+ TitleBar {
+ id: titleBar
+ anchors.top: parent.top
+ anchors.left: parent.left
+ anchors.right: parent.right
+ currentIndex: app.__currentIndex
+
+ onTitleClicked: (index) => {
+ if (index < app.__currentIndex)
+ app.__currentIndex = index
+ }
+ }
+
+ StackLayout {
+ id: pageStack
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.top: titleBar.bottom
+ anchors.bottom: parent.bottom
+ currentIndex: app.__currentIndex
+
+ Connect {
+ connectionHandler: app.connectionHandler
+ deviceFinder: app.deviceFinder
+ deviceHandler: app.deviceHandler
+
+ onShowMeasurePage: app.__currentIndex = 1
+ }
+ Measure {
+ id: measurePage
+ deviceHandler: app.deviceHandler
+
+ onShowStatsPage: app.__currentIndex = 2
+ }
+ Stats {
+ deviceHandler: app.deviceHandler
+ }
+
+ onCurrentIndexChanged: {
+ if (currentIndex === 0)
+ measurePage.close()
+ }
+ }
+
+ BluetoothAlarmDialog {
+ id: btAlarmDialog
+ anchors.fill: parent
+ visible: !app.connectionHandler.alive || permissionError
+ permissionError: !app.connectionHandler.hasPermission
+ }
+
+ Keys.onReleased: (event) => {
+ switch (event.key) {
+ case Qt.Key_Escape:
+ case Qt.Key_Back:
+ {
+ if (app.__currentIndex > 0) {
+ app.__currentIndex = app.__currentIndex - 1
+ event.accepted = true
+ } else {
+ Qt.quit()
+ }
+ break
+ }
+ default:
+ break
+ }
+ }
+
+ Component.onCompleted: {
+ forceActiveFocus()
+ app.opacity = 1.0
+ }
+}
diff --git a/examples/bluetooth/heartrate-game/BluetoothAlarmDialog.qml b/examples/bluetooth/heartrate-game/BluetoothAlarmDialog.qml
new file mode 100644
index 00000000..5cc8f393
--- /dev/null
+++ b/examples/bluetooth/heartrate-game/BluetoothAlarmDialog.qml
@@ -0,0 +1,80 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+
+Item {
+ id: root
+
+ property bool permissionError: false
+
+ anchors.fill: parent
+
+ Rectangle {
+ anchors.fill: parent
+ color: "black"
+ opacity: 0.9
+ }
+
+ MouseArea {
+ id: eventEater
+ }
+
+ Rectangle {
+ id: dialogFrame
+
+ anchors.centerIn: parent
+ width: parent.width * 0.8
+ height: parent.height * 0.6
+ border.color: "#454545"
+ color: GameSettings.backgroundColor
+ radius: width * 0.05
+
+ Item {
+ id: dialogContainer
+ anchors.fill: parent
+ anchors.margins: parent.width*0.05
+
+ Image {
+ id: offOnImage
+ anchors.left: quitButton.left
+ anchors.right: quitButton.right
+ anchors.top: parent.top
+ height: GameSettings.heightForWidth(width, sourceSize)
+ source: "images/bt_off_to_on.png"
+ }
+
+ Text {
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.top: offOnImage.bottom
+ anchors.bottom: quitButton.top
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ wrapMode: Text.WordWrap
+ font.pixelSize: GameSettings.smallFontSize
+ color: GameSettings.textColor
+ text: root.permissionError
+ ? qsTr("Bluetooth permissions are not granted. Please grant the permissions in the system settings.")
+ : qsTr("This application cannot be used without Bluetooth. Please switch Bluetooth ON to continue.")
+ }
+
+ GameButton {
+ id: quitButton
+ anchors.bottom: parent.bottom
+ anchors.horizontalCenter: parent.horizontalCenter
+ width: dialogContainer.width * 0.6
+ height: GameSettings.buttonHeight
+ onClicked: Qt.quit()
+
+ Text {
+ anchors.centerIn: parent
+ color: GameSettings.textColor
+ font.pixelSize: GameSettings.microFontSize
+ text: qsTr("QUIT")
+ }
+ }
+ }
+ }
+}
+
diff --git a/examples/bluetooth/heartrate-game/BottomLine.qml b/examples/bluetooth/heartrate-game/BottomLine.qml
new file mode 100644
index 00000000..80fdaa8c
--- /dev/null
+++ b/examples/bluetooth/heartrate-game/BottomLine.qml
@@ -0,0 +1,11 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+
+Rectangle {
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottom: parent.bottom
+ width: parent.width
+ height: parent.height * 0.05
+}
diff --git a/examples/bluetooth/heartrate-game/CMakeLists.txt b/examples/bluetooth/heartrate-game/CMakeLists.txt
new file mode 100644
index 00000000..7677bcb4
--- /dev/null
+++ b/examples/bluetooth/heartrate-game/CMakeLists.txt
@@ -0,0 +1,91 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(heartrate-game LANGUAGES CXX)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/bluetooth/heartrate-game")
+
+find_package(Qt6 REQUIRED COMPONENTS Bluetooth Core Gui Qml Quick)
+
+qt_standard_project_setup(REQUIRES 6.5)
+
+qt_add_executable(heartrate-game
+ heartrate-global.h
+ main.cpp
+)
+
+set_target_properties(heartrate-game PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(heartrate-game PRIVATE
+ Qt6::Bluetooth
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Qml
+ Qt6::Quick
+)
+
+set_source_files_properties(GameSettings.qml PROPERTIES
+ QT_QML_SINGLETON_TYPE TRUE
+)
+
+qt_add_qml_module(heartrate-game
+ URI HeartRateGame
+ VERSION 1.0
+ SOURCES
+ bluetoothbaseclass.cpp bluetoothbaseclass.h
+ connectionhandler.cpp connectionhandler.h
+ devicefinder.cpp devicefinder.h
+ devicehandler.cpp devicehandler.h
+ deviceinfo.cpp deviceinfo.h
+ QML_FILES
+ App.qml
+ BluetoothAlarmDialog.qml
+ BottomLine.qml
+ Connect.qml
+ GameButton.qml
+ GamePage.qml
+ GameSettings.qml
+ Measure.qml
+ SplashScreen.qml
+ Stats.qml
+ StatsLabel.qml
+ TitleBar.qml
+ Main.qml
+ RESOURCES
+ images/alert.svg
+ images/bluetooth.svg
+ images/bt_off_to_on.png
+ images/clock.svg
+ images/heart.png
+ images/logo.png
+ images/progress.svg
+ images/search.svg
+)
+
+if (APPLE)
+ # Using absolute path for shared plist files is a Ninja bug workaround
+ get_filename_component(SHARED_PLIST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../shared ABSOLUTE)
+ if (IOS)
+ set_target_properties(heartrate-game PROPERTIES
+ MACOSX_BUNDLE_INFO_PLIST "${SHARED_PLIST_DIR}/Info.cmake.ios.plist"
+ )
+ else()
+ set_target_properties(heartrate-game PROPERTIES
+ MACOSX_BUNDLE_INFO_PLIST "${SHARED_PLIST_DIR}/Info.cmake.macos.plist"
+ )
+ endif()
+endif()
+
+install(TARGETS heartrate-game
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/bluetooth/heartrate-game/Connect.qml b/examples/bluetooth/heartrate-game/Connect.qml
new file mode 100644
index 00000000..ed5fb63d
--- /dev/null
+++ b/examples/bluetooth/heartrate-game/Connect.qml
@@ -0,0 +1,155 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+pragma ComponentBehavior: Bound
+import QtQuick
+import HeartRateGame
+
+GamePage {
+ id: connectPage
+
+ required property ConnectionHandler connectionHandler
+ required property DeviceFinder deviceFinder
+ required property DeviceHandler deviceHandler
+
+ signal showMeasurePage
+
+ errorMessage: deviceFinder.error
+ infoMessage: deviceFinder.info
+ iconType: deviceFinder.icon
+
+ Text {
+ id: viewCaption
+ anchors {
+ top: parent.top
+ topMargin: GameSettings.fieldMargin + connectPage.messageHeight
+ horizontalCenter: parent.horizontalCenter
+ }
+ width: parent.width - GameSettings.fieldMargin * 2
+ height: GameSettings.fieldHeight
+ horizontalAlignment: Text.AlignLeft
+ verticalAlignment: Text.AlignVCenter
+ color: GameSettings.textColor
+ font.pixelSize: GameSettings.smallFontSize
+ text: qsTr("Found Devices")
+ }
+
+ Rectangle {
+ id: viewContainer
+ anchors.top: viewCaption.bottom
+ // only BlueZ platform has address type selection
+ anchors.bottom: connectPage.connectionHandler.requiresAddressType ? addressTypeButton.top
+ : searchButton.top
+ anchors.bottomMargin: GameSettings.fieldMargin
+ anchors.horizontalCenter: parent.horizontalCenter
+ width: parent.width - GameSettings.fieldMargin * 2
+ color: GameSettings.viewColor
+ radius: GameSettings.buttonRadius
+
+ ListView {
+ id: devices
+ anchors.fill: parent
+ model: connectPage.deviceFinder.devices
+ clip: true
+
+ delegate: Rectangle {
+ id: box
+
+ required property int index
+ required property var modelData
+
+ height: GameSettings.fieldHeight * 1.2
+ width: devices.width
+ color: index % 2 === 0 ? GameSettings.delegate1Color : GameSettings.delegate2Color
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ connectPage.deviceFinder.connectToService(box.modelData.deviceAddress)
+ connectPage.showMeasurePage()
+ }
+ }
+
+ Text {
+ id: device
+ font.pixelSize: GameSettings.microFontSize
+ text: box.modelData.deviceName
+ anchors.top: parent.top
+ anchors.topMargin: parent.height * 0.15
+ anchors.leftMargin: parent.height * 0.15
+ anchors.left: parent.left
+ color: GameSettings.textColor
+ }
+
+ Text {
+ id: deviceAddress
+ font.pixelSize: GameSettings.microFontSize
+ text: box.modelData.deviceAddress
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: parent.height * 0.15
+ anchors.rightMargin: parent.height * 0.15
+ anchors.right: parent.right
+ color: Qt.darker(GameSettings.textColor)
+ }
+ }
+ }
+ }
+
+ GameButton {
+ id: addressTypeButton
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottom: searchButton.top
+ anchors.bottomMargin: GameSettings.fieldMargin * 0.5
+ width: viewContainer.width
+ height: GameSettings.fieldHeight
+ visible: connectPage.connectionHandler.requiresAddressType // only required on BlueZ
+ state: "public"
+ onClicked: state === "public" ? state = "random" : state = "public"
+
+ states: [
+ State {
+ name: "public"
+ PropertyChanges {
+ addressTypeText.text: qsTr("PUBLIC ADDRESS")
+ }
+ PropertyChanges {
+ connectPage.deviceHandler.addressType: DeviceHandler.PublicAddress
+ }
+ },
+ State {
+ name: "random"
+ PropertyChanges {
+ addressTypeText.text: qsTr("RANDOM ADDRESS")
+ }
+ PropertyChanges {
+ connectPage.deviceHandler.addressType: DeviceHandler.RandomAddress
+ }
+ }
+ ]
+
+ Text {
+ id: addressTypeText
+ anchors.centerIn: parent
+ font.pixelSize: GameSettings.microFontSize
+ color: GameSettings.textDarkColor
+ }
+ }
+
+ GameButton {
+ id: searchButton
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: GameSettings.fieldMargin
+ width: viewContainer.width
+ height: GameSettings.fieldHeight
+ enabled: !connectPage.deviceFinder.scanning
+ onClicked: connectPage.deviceFinder.startSearch()
+
+ Text {
+ anchors.centerIn: parent
+ font.pixelSize: GameSettings.microFontSize
+ text: qsTr("START SEARCH")
+ color: GameSettings.textDarkColor
+ }
+ }
+}
diff --git a/examples/bluetooth/heartrate-game/GameButton.qml b/examples/bluetooth/heartrate-game/GameButton.qml
new file mode 100644
index 00000000..8e876010
--- /dev/null
+++ b/examples/bluetooth/heartrate-game/GameButton.qml
@@ -0,0 +1,39 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+
+Rectangle {
+ id: button
+ color: baseColor
+ onEnabledChanged: checkColor()
+ radius: GameSettings.buttonRadius
+
+ property color baseColor: GameSettings.buttonColor
+ property color pressedColor: GameSettings.buttonPressedColor
+ property color disabledColor: GameSettings.disabledButtonColor
+
+ signal clicked
+
+ function checkColor() {
+ if (!button.enabled) {
+ button.color = disabledColor
+ } else {
+ if (mouseArea.containsPress)
+ button.color = pressedColor
+ else
+ button.color = baseColor
+ }
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onPressed: button.checkColor()
+ onReleased: button.checkColor()
+ onClicked: {
+ button.checkColor()
+ button.clicked()
+ }
+ }
+}
diff --git a/examples/bluetooth/heartrate-game/GamePage.qml b/examples/bluetooth/heartrate-game/GamePage.qml
new file mode 100644
index 00000000..ff81e9cd
--- /dev/null
+++ b/examples/bluetooth/heartrate-game/GamePage.qml
@@ -0,0 +1,77 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import HeartRateGame
+
+Item {
+ id: page
+
+ property string errorMessage: ""
+ property string infoMessage: ""
+ property real messageHeight: msg.height
+ property bool hasError: errorMessage != ""
+ property bool hasInfo: infoMessage != ""
+ property int iconType: BluetoothBaseClass.IconNone
+
+ function iconTypeToName(icon: int) : string {
+ switch (icon) {
+ case BluetoothBaseClass.IconNone: return ""
+ case BluetoothBaseClass.IconBluetooth: return "images/bluetooth.svg"
+ case BluetoothBaseClass.IconError: return "images/alert.svg"
+ case BluetoothBaseClass.IconProgress: return "images/progress.svg"
+ case BluetoothBaseClass.IconSearch: return "images/search.svg"
+ }
+ }
+
+ Rectangle {
+ id: msg
+ anchors {
+ top: parent.top
+ left: parent.left
+ right: parent.right
+ topMargin: GameSettings.fieldMargin * 0.5
+ leftMargin: GameSettings.fieldMargin
+ rightMargin: GameSettings.fieldMargin
+ }
+ height: GameSettings.fieldHeight
+ radius: GameSettings.buttonRadius
+ color: page.hasError ? GameSettings.errorColor : "transparent"
+ visible: page.hasError || page.hasInfo
+ border {
+ width: 1
+ color: page.hasError ? GameSettings.errorColor : GameSettings.infoColor
+ }
+
+ Image {
+ id: icon
+ readonly property int imgSize: GameSettings.fieldHeight * 0.5
+ anchors {
+ left: parent.left
+ leftMargin: GameSettings.fieldMargin * 0.5
+ verticalCenter: parent.verticalCenter
+ }
+ visible: source.toString() !== ""
+ source: page.iconTypeToName(page.iconType)
+ sourceSize.width: imgSize
+ sourceSize.height: imgSize
+ fillMode: Image.PreserveAspectFit
+ }
+
+ Text {
+ id: error
+ anchors {
+ fill: parent
+ leftMargin: GameSettings.fieldMargin + icon.width
+ rightMargin: GameSettings.fieldMargin + icon.width
+ }
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ minimumPixelSize: 5
+ font.pixelSize: GameSettings.microFontSize
+ fontSizeMode: Text.Fit
+ color: page.hasError ? GameSettings.textColor : GameSettings.infoColor
+ text: page.hasError ? page.errorMessage : page.infoMessage
+ }
+ }
+}
diff --git a/examples/bluetooth/heartrate-game/GameSettings.qml b/examples/bluetooth/heartrate-game/GameSettings.qml
new file mode 100644
index 00000000..4032787c
--- /dev/null
+++ b/examples/bluetooth/heartrate-game/GameSettings.qml
@@ -0,0 +1,61 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+pragma Singleton
+import QtQuick
+
+QtObject {
+ property int wHeight
+ property int wWidth
+
+ // Colors
+ readonly property color lightGreenColor: "#80ebb6"
+ readonly property color backgroundColor: "#2c3038"
+ readonly property color buttonColor: "#2cde85"
+ readonly property color buttonPressedColor: lightGreenColor
+ readonly property color disabledButtonColor: "#808080"
+ readonly property color viewColor: "#262626"
+ readonly property color delegate1Color: "#262626"
+ readonly property color delegate2Color: "#404040"
+ readonly property color textColor: "#ffffff"
+ readonly property color textDarkColor: "#0d0d0d"
+ readonly property color textInfoColor: lightGreenColor
+ readonly property color sliderColor: "#00414a"
+ readonly property color sliderBorderColor: lightGreenColor
+ readonly property color sliderTextColor: lightGreenColor
+ readonly property color errorColor: "#ba3f62"
+ readonly property color infoColor: lightGreenColor
+ readonly property color titleColor: "#202227"
+ readonly property color selectedTitleColor: "#19545c"
+ readonly property color hoverTitleColor: Qt.rgba(selectedTitleColor.r,
+ selectedTitleColor.g,
+ selectedTitleColor.b,
+ 0.25)
+ readonly property color bottomLineColor: "#e6e6e6"
+ readonly property color heartRateColor: "#f80067"
+
+ // All the fonts are given for the window of certain size.
+ // Resizing the window changes all the fonts accordingly
+ readonly property int defaultSize: 500
+ readonly property real fontScaleFactor: Math.min(wWidth, wHeight) / defaultSize
+
+ // Font sizes
+ readonly property real microFontSize: 16 * fontScaleFactor
+ readonly property real tinyFontSize: 20 * fontScaleFactor
+ readonly property real smallFontSize: 24 * fontScaleFactor
+ readonly property real mediumFontSize: 32 * fontScaleFactor
+ readonly property real bigFontSize: 36 * fontScaleFactor
+ readonly property real largeFontSize: 54 * fontScaleFactor
+ readonly property real hugeFontSize: 128 * fontScaleFactor
+
+ // Some other values
+ property real fieldHeight: wHeight * 0.08
+ property real fieldMargin: fieldHeight * 0.5
+ property real buttonHeight: wHeight * 0.08
+ property real buttonRadius: buttonHeight * 0.1
+
+ // Some help functions
+ function heightForWidth(w, ss) {
+ return w / ss.width * ss.height
+ }
+}
diff --git a/examples/bluetooth/heartrate-game/Main.qml b/examples/bluetooth/heartrate-game/Main.qml
new file mode 100644
index 00000000..e26f9b00
--- /dev/null
+++ b/examples/bluetooth/heartrate-game/Main.qml
@@ -0,0 +1,71 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+pragma ComponentBehavior: Bound
+import QtQuick
+import QtQuick.Window
+import HeartRateGame
+
+Window {
+ id: wroot
+ visible: true
+ width: 720 * .7
+ height: 1240 * .7
+ title: qsTr("HeartRateGame")
+ color: GameSettings.backgroundColor
+
+ required property ConnectionHandler connectionHandler
+ required property DeviceFinder deviceFinder
+ required property DeviceHandler deviceHandler
+
+ Component.onCompleted: {
+ GameSettings.wWidth = Qt.binding(function () {
+ return width
+ })
+ GameSettings.wHeight = Qt.binding(function () {
+ return height
+ })
+ }
+
+ Loader {
+ id: splashLoader
+ anchors.fill: parent
+ asynchronous: false
+ visible: true
+
+ sourceComponent: SplashScreen {
+ appIsReady: appLoader.status === Loader.Ready
+ onReadyChanged: {
+ if (ready) {
+ appLoader.visible = true
+ splashLoader.visible = false
+ splashLoader.active = false
+ }
+ }
+ }
+
+ onStatusChanged: {
+ if (status === Loader.Ready)
+ appLoader.active = true
+ }
+ }
+
+ Loader {
+ id: appLoader
+ anchors.fill: parent
+ active: false
+ asynchronous: true
+ visible: false
+
+ sourceComponent: App {
+ connectionHandler: wroot.connectionHandler
+ deviceFinder: wroot.deviceFinder
+ deviceHandler: wroot.deviceHandler
+ }
+
+ onStatusChanged: {
+ if (status === Loader.Error)
+ Qt.quit()
+ }
+ }
+}
diff --git a/examples/bluetooth/heartrate-game/Measure.qml b/examples/bluetooth/heartrate-game/Measure.qml
new file mode 100644
index 00000000..04ebeb09
--- /dev/null
+++ b/examples/bluetooth/heartrate-game/Measure.qml
@@ -0,0 +1,325 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import HeartRateGame
+
+GamePage {
+ id: measurePage
+
+ required property DeviceHandler deviceHandler
+
+ errorMessage: deviceHandler.error
+ infoMessage: deviceHandler.info
+ iconType: deviceHandler.icon
+
+ property real __timeCounter: 0
+ property real __maxTimeCount: 60
+
+ readonly property string relaxText: qsTr("Relax!")
+ readonly property string startText: qsTr("When you are ready,\npress Start.")
+ readonly property string instructionText: qsTr("You have %1s time to increase heart\nrate as much as possible.").arg(__maxTimeCount)
+ readonly property string goodLuckText: qsTr("Good luck!")
+
+ signal showStatsPage
+
+ function close() {
+ deviceHandler.stopMeasurement()
+ deviceHandler.disconnectService()
+ }
+
+ function start() {
+ if (!deviceHandler.measuring) {
+ __timeCounter = 0
+ deviceHandler.startMeasurement()
+ }
+ }
+
+ function stop() {
+ if (deviceHandler.measuring)
+ deviceHandler.stopMeasurement()
+
+ measurePage.showStatsPage()
+ }
+
+ Timer {
+ id: measureTimer
+ interval: 1000
+ running: measurePage.deviceHandler.measuring
+ repeat: true
+ onTriggered: {
+ measurePage.__timeCounter++
+ if (measurePage.__timeCounter >= measurePage.__maxTimeCount)
+ measurePage.stop()
+ }
+ }
+
+ Column {
+ anchors.centerIn: parent
+ spacing: GameSettings.fieldHeight * 0.5
+
+ Rectangle {
+ id: circle
+
+ readonly property bool hintVisible: !measurePage.deviceHandler.measuring
+ readonly property real innerSpacing: Math.min(width * 0.05, 25)
+
+ anchors.horizontalCenter: parent.horizontalCenter
+ width: Math.min(measurePage.width, measurePage.height - GameSettings.fieldHeight * 4)
+ - 2 * GameSettings.fieldMargin
+ height: width
+ radius: width * 0.5
+ color: GameSettings.viewColor
+
+ Text {
+ id: relaxTextBox
+ anchors {
+ bottom: startTextBox.top
+ bottomMargin: parent.innerSpacing
+ horizontalCenter: parent.horizontalCenter
+ }
+ width: parent.width * 0.6
+ height: parent.height * 0.1
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ text: measurePage.relaxText
+ visible: circle.hintVisible
+ color: GameSettings.textColor
+ fontSizeMode: Text.Fit
+ font.pixelSize: GameSettings.smallFontSize
+ font.bold: true
+ }
+
+ Text {
+ id: startTextBox
+ anchors {
+ bottom: heart.top
+ bottomMargin: parent.innerSpacing
+ horizontalCenter: parent.horizontalCenter
+ }
+ width: parent.width * 0.8
+ height: parent.height * 0.15
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ text: measurePage.startText
+ visible: circle.hintVisible
+ color: GameSettings.textColor
+ fontSizeMode: Text.Fit
+ font.pixelSize: GameSettings.tinyFontSize
+ }
+
+ Text {
+ id: measureTextBox
+ anchors {
+ bottom: heart.top
+ horizontalCenter: parent.horizontalCenter
+ }
+ width: parent.width * 0.7
+ height: parent.height * 0.35
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ text: measurePage.deviceHandler.hr
+ visible: measurePage.deviceHandler.measuring
+ color: GameSettings.heartRateColor
+ fontSizeMode: Text.Fit
+ font.pixelSize: GameSettings.hugeFontSize
+ font.bold: true
+ }
+
+ Image {
+ id: heart
+ anchors.centerIn: circle
+ width: parent.width * 0.2
+ height: width
+ fillMode: Image.PreserveAspectFit
+ source: "images/heart.png"
+ smooth: true
+ antialiasing: true
+
+ SequentialAnimation {
+ id: heartAnim
+ running: measurePage.deviceHandler.measuring
+ loops: Animation.Infinite
+ alwaysRunToEnd: true
+ PropertyAnimation {
+ target: heart
+ property: "scale"
+ to: 1.4
+ duration: 500
+ easing.type: Easing.InQuad
+ }
+ PropertyAnimation {
+ target: heart
+ property: "scale"
+ to: 1.0
+ duration: 500
+ easing.type: Easing.OutQuad
+ }
+ }
+ }
+
+ Text {
+ id: instructionTextBox
+ anchors {
+ top: heart.bottom
+ topMargin: parent.innerSpacing
+ horizontalCenter: parent.horizontalCenter
+ }
+ width: parent.width * 0.8
+ height: parent.height * 0.15
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ text: measurePage.instructionText
+ visible: circle.hintVisible
+ color: GameSettings.textColor
+ fontSizeMode: Text.Fit
+ font.pixelSize: GameSettings.tinyFontSize
+ }
+
+ Text {
+ id: goodLuckBox
+ anchors {
+ top: instructionTextBox.bottom
+ topMargin: parent.innerSpacing
+ horizontalCenter: parent.horizontalCenter
+ }
+ width: parent.width * 0.6
+ height: parent.height * 0.1
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ text: measurePage.goodLuckText
+ visible: circle.hintVisible
+ color: GameSettings.textColor
+ fontSizeMode: Text.Fit
+ font.pixelSize: GameSettings.smallFontSize
+ font.bold: true
+ }
+
+ Item {
+ id: minMaxContainer
+ anchors.horizontalCenter: parent.horizontalCenter
+ width: parent.width * 0.7
+ height: parent.height * 0.15
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: parent.height * 0.16
+ visible: measurePage.deviceHandler.measuring
+
+ Text {
+ anchors.left: parent.left
+ anchors.verticalCenter: parent.verticalCenter
+ width: parent.width * 0.35
+ horizontalAlignment: Text.AlignLeft
+ verticalAlignment: Text.AlignVCenter
+ text: measurePage.deviceHandler.minHR
+ color: GameSettings.textColor
+ fontSizeMode: Text.Fit
+ font.pixelSize: GameSettings.largeFontSize
+
+ Text {
+ anchors.left: parent.left
+ anchors.bottom: parent.top
+ horizontalAlignment: Text.AlignLeft
+ verticalAlignment: Text.AlignVCenter
+ width: parent.width
+ fontSizeMode: Text.Fit
+ font.pixelSize: GameSettings.mediumFontSize
+ color: parent.color
+ text: "MIN"
+ }
+ }
+
+ Text {
+ anchors.right: parent.right
+ anchors.verticalCenter: parent.verticalCenter
+ horizontalAlignment: Text.AlignRight
+ verticalAlignment: Text.AlignVCenter
+ width: parent.width * 0.35
+ text: measurePage.deviceHandler.maxHR
+ color: GameSettings.textColor
+ fontSizeMode: Text.Fit
+ font.pixelSize: GameSettings.largeFontSize
+
+ Text {
+ anchors.right: parent.right
+ anchors.bottom: parent.top
+ horizontalAlignment: Text.AlignRight
+ verticalAlignment: Text.AlignVCenter
+ width: parent.width
+ fontSizeMode: Text.Fit
+ font.pixelSize: GameSettings.mediumFontSize
+ color: parent.color
+ text: "MAX"
+ }
+ }
+ }
+ }
+
+ Rectangle {
+ id: timeSlider
+ color: GameSettings.viewColor
+ anchors.horizontalCenter: parent.horizontalCenter
+ width: circle.width
+ height: GameSettings.fieldHeight
+ radius: GameSettings.buttonRadius
+ border {
+ width: 1
+ color: GameSettings.sliderBorderColor
+ }
+
+ Rectangle {
+ anchors {
+ top: parent.top
+ topMargin: parent.border.width
+ left: parent.left
+ leftMargin: parent.border.width
+ }
+ height: parent.height - 2 * parent.border.width
+ width: Math.min(1.0, measurePage.__timeCounter / measurePage.__maxTimeCount)
+ * (parent.width - 2 * parent.border.width)
+ radius: parent.radius
+ color: GameSettings.sliderColor
+ }
+
+ Image {
+ readonly property int imgSize: GameSettings.fieldHeight * 0.5
+ anchors {
+ verticalCenter: parent.verticalCenter
+ left: parent.left
+ leftMargin: GameSettings.fieldMargin * 0.5
+ }
+ source: "images/clock.svg"
+ sourceSize.width: imgSize
+ sourceSize.height: imgSize
+ fillMode: Image.PreserveAspectFit
+ }
+
+ Text {
+ anchors.centerIn: parent
+ color: GameSettings.sliderTextColor
+ text: (measurePage.__maxTimeCount - measurePage.__timeCounter).toFixed(0) + " s"
+ font.pixelSize: GameSettings.smallFontSize
+ }
+ }
+ }
+
+ GameButton {
+ id: startButton
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: GameSettings.fieldMargin
+ width: circle.width
+ height: GameSettings.fieldHeight
+ enabled: measurePage.deviceHandler.alive && !measurePage.deviceHandler.measuring
+ && measurePage.errorMessage === ""
+ radius: GameSettings.buttonRadius
+
+ onClicked: measurePage.start()
+
+ Text {
+ anchors.centerIn: parent
+ font.pixelSize: GameSettings.microFontSize
+ text: qsTr("START")
+ color: GameSettings.textDarkColor
+ }
+ }
+}
diff --git a/examples/bluetooth/heartrate-game/SplashScreen.qml b/examples/bluetooth/heartrate-game/SplashScreen.qml
new file mode 100644
index 00000000..918319d7
--- /dev/null
+++ b/examples/bluetooth/heartrate-game/SplashScreen.qml
@@ -0,0 +1,30 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import HeartRateGame
+
+Item {
+ id: root
+
+ property bool appIsReady: false
+ property bool splashIsReady: false
+ property bool ready: appIsReady && splashIsReady
+
+ anchors.fill: parent
+
+ Image {
+ anchors.centerIn: parent
+ width: Math.min(parent.height, parent.width) * 0.6
+ height: GameSettings.heightForWidth(width, sourceSize)
+ source: "images/logo.png"
+ }
+
+ Timer {
+ id: splashTimer
+ interval: 1000
+ onTriggered: root.splashIsReady = true
+ }
+
+ Component.onCompleted: splashTimer.start()
+}
diff --git a/examples/bluetooth/heartrate-game/Stats.qml b/examples/bluetooth/heartrate-game/Stats.qml
new file mode 100644
index 00000000..87487c94
--- /dev/null
+++ b/examples/bluetooth/heartrate-game/Stats.qml
@@ -0,0 +1,80 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import HeartRateGame
+
+GamePage {
+ id: statsPage
+
+ required property DeviceHandler deviceHandler
+
+ Column {
+ anchors.centerIn: parent
+ width: parent.width
+
+ Rectangle {
+ id: resultRect
+ anchors.horizontalCenter: parent.horizontalCenter
+ width: height
+ height: statsPage.height / 2 - GameSettings.fieldHeight
+ radius: height / 2
+ color: GameSettings.viewColor
+
+ Column {
+ anchors.centerIn: parent
+
+ Text {
+ id: resultCaption
+ anchors.horizontalCenter: parent.horizontalCenter
+ width: resultRect.width * 0.8
+ height: resultRect.height * 0.15
+ horizontalAlignment: Text.AlignHCenter
+ fontSizeMode: Text.Fit
+ font.pixelSize: GameSettings.bigFontSize
+ color: GameSettings.textColor
+ text: qsTr("RESULT")
+ }
+
+ Text {
+ id: resultValue
+ anchors.horizontalCenter: parent.horizontalCenter
+ width: resultRect.width * 0.8
+ height: resultRect.height * 0.4
+ horizontalAlignment: Text.AlignHCenter
+ fontSizeMode: Text.Fit
+ font.pixelSize: GameSettings.hugeFontSize
+ font.bold: true
+ color: GameSettings.heartRateColor
+ text: (statsPage.deviceHandler.maxHR - statsPage.deviceHandler.minHR).toFixed(0)
+ }
+ }
+ }
+
+
+ Item {
+ height: GameSettings.fieldHeight
+ width: 1
+ }
+
+ StatsLabel {
+ title: qsTr("MIN")
+ value: statsPage.deviceHandler.minHR.toFixed(0)
+ }
+
+ StatsLabel {
+ title: qsTr("MAX")
+ value: statsPage.deviceHandler.maxHR.toFixed(0)
+ }
+
+ StatsLabel {
+ title: qsTr("AVG")
+ value: statsPage.deviceHandler.average.toFixed(1)
+ }
+
+ StatsLabel {
+ title: qsTr("CALORIES")
+ value: statsPage.deviceHandler.calories.toFixed(3)
+ }
+ }
+}
diff --git a/examples/bluetooth/heartrate-game/StatsLabel.qml b/examples/bluetooth/heartrate-game/StatsLabel.qml
new file mode 100644
index 00000000..0ea4249a
--- /dev/null
+++ b/examples/bluetooth/heartrate-game/StatsLabel.qml
@@ -0,0 +1,34 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+
+Item {
+ height: GameSettings.fieldHeight
+ width: parent.width
+
+ property alias title: leftText.text
+ property alias value: rightText.text
+
+ Text {
+ id: leftText
+ anchors.left: parent.left
+ height: parent.height
+ width: parent.width * 0.45
+ horizontalAlignment: Text.AlignRight
+ verticalAlignment: Text.AlignVCenter
+ font.pixelSize: GameSettings.mediumFontSize
+ color: GameSettings.textColor
+ }
+
+ Text {
+ id: rightText
+ anchors.right: parent.right
+ height: parent.height
+ width: parent.width * 0.45
+ horizontalAlignment: Text.AlignLeft
+ verticalAlignment: Text.AlignVCenter
+ font.pixelSize: GameSettings.mediumFontSize
+ color: GameSettings.textColor
+ }
+}
diff --git a/examples/bluetooth/heartrate-game/TitleBar.qml b/examples/bluetooth/heartrate-game/TitleBar.qml
new file mode 100644
index 00000000..ccec7608
--- /dev/null
+++ b/examples/bluetooth/heartrate-game/TitleBar.qml
@@ -0,0 +1,63 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+pragma ComponentBehavior: Bound
+import QtQuick
+
+Rectangle {
+ id: titleBar
+
+ property var __titles: ["CONNECT", "MEASURE", "STATS"]
+ property int currentIndex: 0
+
+ signal titleClicked(int index)
+
+ height: GameSettings.fieldHeight
+ color: GameSettings.titleColor
+
+ Rectangle {
+ anchors.bottom: parent.bottom
+ width: parent.width / 3
+ height: parent.height
+ x: titleBar.currentIndex * width
+ color: GameSettings.selectedTitleColor
+
+ BottomLine {
+ color: GameSettings.bottomLineColor
+ }
+
+ Behavior on x {
+ NumberAnimation {
+ duration: 200
+ }
+ }
+ }
+
+ Repeater {
+ model: 3
+ Rectangle {
+ id: caption
+ required property int index
+ property bool hoveredOrPressed: mouseArea.pressed || mouseArea.containsMouse
+ width: titleBar.width / 3
+ height: titleBar.height
+ x: index * width
+ color: (titleBar.currentIndex !== index) && hoveredOrPressed
+ ? GameSettings.hoverTitleColor : "transparent"
+ Text {
+ anchors.fill: parent
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ text: titleBar.__titles[caption.index]
+ font.pixelSize: GameSettings.microFontSize
+ color: GameSettings.textColor
+ }
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ hoverEnabled: true
+ onClicked: titleBar.titleClicked(caption.index)
+ }
+ }
+ }
+}
diff --git a/examples/bluetooth/heartrate-game/bluetoothbaseclass.cpp b/examples/bluetooth/heartrate-game/bluetoothbaseclass.cpp
index 7f6a8f63..4c60b180 100644
--- a/examples/bluetooth/heartrate-game/bluetoothbaseclass.cpp
+++ b/examples/bluetooth/heartrate-game/bluetoothbaseclass.cpp
@@ -1,52 +1,5 @@
-/***************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "bluetoothbaseclass.h"
@@ -80,8 +33,22 @@ void BluetoothBaseClass::setInfo(const QString &info)
}
}
+BluetoothBaseClass::IconType BluetoothBaseClass::icon() const
+{
+ return m_icon;
+}
+
+void BluetoothBaseClass::setIcon(IconType icon)
+{
+ if (m_icon != icon) {
+ m_icon = icon;
+ emit iconChanged();
+ }
+}
+
void BluetoothBaseClass::clearMessages()
{
setInfo("");
setError("");
+ setIcon(IconNone);
}
diff --git a/examples/bluetooth/heartrate-game/bluetoothbaseclass.h b/examples/bluetooth/heartrate-game/bluetoothbaseclass.h
index 5a043b3d..fba014f5 100644
--- a/examples/bluetooth/heartrate-game/bluetoothbaseclass.h
+++ b/examples/bluetooth/heartrate-game/bluetoothbaseclass.h
@@ -1,65 +1,34 @@
-/***************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef BLUETOOTHBASECLASS_H
#define BLUETOOTHBASECLASS_H
#include <QObject>
+#include <QQmlEngine>
+
class BluetoothBaseClass : public QObject
{
Q_OBJECT
+
Q_PROPERTY(QString error READ error WRITE setError NOTIFY errorChanged)
Q_PROPERTY(QString info READ info WRITE setInfo NOTIFY infoChanged)
+ Q_PROPERTY(IconType icon READ icon WRITE setIcon NOTIFY iconChanged)
+
+ QML_ELEMENT
+ QML_UNCREATABLE("BluetoothBaseClass is not intended to be created directly")
public:
+ enum IconType : int {
+ IconNone,
+ IconBluetooth,
+ IconError,
+ IconProgress,
+ IconSearch
+ };
+ Q_ENUM(IconType)
+
explicit BluetoothBaseClass(QObject *parent = nullptr);
QString error() const;
@@ -68,15 +37,20 @@ public:
QString info() const;
void setInfo(const QString& info);
+ IconType icon() const;
+ void setIcon(IconType icon);
+
void clearMessages();
signals:
void errorChanged();
void infoChanged();
+ void iconChanged();
private:
QString m_error;
QString m_info;
+ IconType m_icon = IconNone;
};
#endif // BLUETOOTHBASECLASS_H
diff --git a/examples/bluetooth/heartrate-game/connectionhandler.cpp b/examples/bluetooth/heartrate-game/connectionhandler.cpp
index 3388c0a8..87e64624 100644
--- a/examples/bluetooth/heartrate-game/connectionhandler.cpp
+++ b/examples/bluetooth/heartrate-game/connectionhandler.cpp
@@ -1,73 +1,42 @@
-/***************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-#include "heartrate-global.h"
#include "connectionhandler.h"
-#include <QtBluetooth/qtbluetooth-config.h>
-#include <QtCore/qsystemdetection.h>
+#include "heartrate-global.h"
+
+#include <qtbluetooth-config.h>
+
+#include <QtSystemDetection>
+
+#if QT_CONFIG(permissions)
+#include <QCoreApplication>
+#include <QPermissions>
+#endif
ConnectionHandler::ConnectionHandler(QObject *parent) : QObject(parent)
{
- connect(&m_localDevice, &QBluetoothLocalDevice::hostModeStateChanged,
- this, &ConnectionHandler::hostModeChanged);
+ initLocalDevice();
}
bool ConnectionHandler::alive() const
{
-#if defined(SIMULATOR) || defined(QT_PLATFORM_UIKIT)
+
+#ifdef QT_PLATFORM_UIKIT
return true;
+
#else
- return m_localDevice.isValid() && m_localDevice.hostMode() != QBluetoothLocalDevice::HostPoweredOff;
+ if (simulator)
+ return true;
+ return m_localDevice && m_localDevice->isValid()
+ && m_localDevice->hostMode() != QBluetoothLocalDevice::HostPoweredOff;
#endif
}
+bool ConnectionHandler::hasPermission() const
+{
+ return m_hasPermission;
+}
+
bool ConnectionHandler::requiresAddressType() const
{
#if QT_CONFIG(bluez)
@@ -79,15 +48,37 @@ bool ConnectionHandler::requiresAddressType() const
QString ConnectionHandler::name() const
{
- return m_localDevice.name();
+ return m_localDevice ? m_localDevice->name() : QString();
}
QString ConnectionHandler::address() const
{
- return m_localDevice.address().toString();
+ return m_localDevice ? m_localDevice->address().toString() : QString();
}
void ConnectionHandler::hostModeChanged(QBluetoothLocalDevice::HostMode /*mode*/)
{
emit deviceChanged();
}
+
+void ConnectionHandler::initLocalDevice()
+{
+#if QT_CONFIG(permissions)
+ QBluetoothPermission permission{};
+ permission.setCommunicationModes(QBluetoothPermission::Access);
+ switch (qApp->checkPermission(permission)) {
+ case Qt::PermissionStatus::Undetermined:
+ qApp->requestPermission(permission, this, &ConnectionHandler::initLocalDevice);
+ return;
+ case Qt::PermissionStatus::Denied:
+ return;
+ case Qt::PermissionStatus::Granted:
+ break; // proceed to initialization
+ }
+#endif
+ m_localDevice = new QBluetoothLocalDevice(this);
+ connect(m_localDevice, &QBluetoothLocalDevice::hostModeStateChanged,
+ this, &ConnectionHandler::hostModeChanged);
+ m_hasPermission = true;
+ emit deviceChanged();
+}
diff --git a/examples/bluetooth/heartrate-game/connectionhandler.h b/examples/bluetooth/heartrate-game/connectionhandler.h
index 9f5a42cc..e51fcbef 100644
--- a/examples/bluetooth/heartrate-game/connectionhandler.h
+++ b/examples/bluetooth/heartrate-game/connectionhandler.h
@@ -1,71 +1,31 @@
-/***************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef CONNECTIONHANDLER_H
#define CONNECTIONHANDLER_H
-#include <QObject>
#include <QBluetoothLocalDevice>
+#include <QObject>
+
+#include <QQmlEngine>
+
class ConnectionHandler : public QObject
{
+ Q_OBJECT
+
Q_PROPERTY(bool alive READ alive NOTIFY deviceChanged)
+ Q_PROPERTY(bool hasPermission READ hasPermission NOTIFY deviceChanged)
Q_PROPERTY(QString name READ name NOTIFY deviceChanged)
Q_PROPERTY(QString address READ address NOTIFY deviceChanged)
Q_PROPERTY(bool requiresAddressType READ requiresAddressType CONSTANT)
- Q_OBJECT
+ QML_ELEMENT
public:
explicit ConnectionHandler(QObject *parent = nullptr);
bool alive() const;
+ bool hasPermission() const;
bool requiresAddressType() const;
QString name() const;
QString address() const;
@@ -75,9 +35,11 @@ signals:
private slots:
void hostModeChanged(QBluetoothLocalDevice::HostMode mode);
+ void initLocalDevice();
private:
- QBluetoothLocalDevice m_localDevice;
+ QBluetoothLocalDevice *m_localDevice = nullptr;
+ bool m_hasPermission = false;
};
#endif // CONNECTIONHANDLER_H
diff --git a/examples/bluetooth/heartrate-game/devicefinder.cpp b/examples/bluetooth/heartrate-game/devicefinder.cpp
index 19ebee90..eaa70ca8 100644
--- a/examples/bluetooth/heartrate-game/devicefinder.cpp
+++ b/examples/bluetooth/heartrate-game/devicefinder.cpp
@@ -1,56 +1,17 @@
-/***************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "devicefinder.h"
#include "devicehandler.h"
#include "deviceinfo.h"
+#include "heartrate-global.h"
+
+#include <QBluetoothDeviceInfo>
+
+#if QT_CONFIG(permissions)
+#include <QCoreApplication>
+#include <QPermissions>
+#endif
DeviceFinder::DeviceFinder(DeviceHandler *handler, QObject *parent):
BluetoothBaseClass(parent),
@@ -58,22 +19,27 @@ DeviceFinder::DeviceFinder(DeviceHandler *handler, QObject *parent):
{
//! [devicediscovery-1]
m_deviceDiscoveryAgent = new QBluetoothDeviceDiscoveryAgent(this);
- m_deviceDiscoveryAgent->setLowEnergyDiscoveryTimeout(5000);
+ m_deviceDiscoveryAgent->setLowEnergyDiscoveryTimeout(15000);
- connect(m_deviceDiscoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered, this, &DeviceFinder::addDevice);
- connect(m_deviceDiscoveryAgent, static_cast<void (QBluetoothDeviceDiscoveryAgent::*)(QBluetoothDeviceDiscoveryAgent::Error)>(&QBluetoothDeviceDiscoveryAgent::error),
+ connect(m_deviceDiscoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered,
+ this, &DeviceFinder::addDevice);
+ connect(m_deviceDiscoveryAgent, &QBluetoothDeviceDiscoveryAgent::errorOccurred,
this, &DeviceFinder::scanError);
- connect(m_deviceDiscoveryAgent, &QBluetoothDeviceDiscoveryAgent::finished, this, &DeviceFinder::scanFinished);
- connect(m_deviceDiscoveryAgent, &QBluetoothDeviceDiscoveryAgent::canceled, this, &DeviceFinder::scanFinished);
+ connect(m_deviceDiscoveryAgent, &QBluetoothDeviceDiscoveryAgent::finished,
+ this, &DeviceFinder::scanFinished);
+ connect(m_deviceDiscoveryAgent, &QBluetoothDeviceDiscoveryAgent::canceled,
+ this, &DeviceFinder::scanFinished);
//! [devicediscovery-1]
-#ifdef SIMULATOR
- m_demoTimer.setSingleShot(true);
- m_demoTimer.setInterval(2000);
- connect(&m_demoTimer, &QTimer::timeout, this, &DeviceFinder::scanFinished);
-#endif
+ if (simulator) {
+ m_demoTimer.setSingleShot(true);
+ m_demoTimer.setInterval(2000);
+ connect(&m_demoTimer, &QTimer::timeout, this, &DeviceFinder::scanFinished);
+ }
+
+ resetMessages();
}
DeviceFinder::~DeviceFinder()
@@ -84,6 +50,23 @@ DeviceFinder::~DeviceFinder()
void DeviceFinder::startSearch()
{
+#if QT_CONFIG(permissions)
+ //! [permissions]
+ QBluetoothPermission permission{};
+ permission.setCommunicationModes(QBluetoothPermission::Access);
+ switch (qApp->checkPermission(permission)) {
+ case Qt::PermissionStatus::Undetermined:
+ qApp->requestPermission(permission, this, &DeviceFinder::startSearch);
+ return;
+ case Qt::PermissionStatus::Denied:
+ setError(tr("Bluetooth permissions not granted!"));
+ setIcon(IconError);
+ return;
+ case Qt::PermissionStatus::Granted:
+ break; // proceed to search
+ }
+ //! [permissions]
+#endif // QT_CONFIG(permissions)
clearMessages();
m_deviceHandler->setDevice(nullptr);
qDeleteAll(m_devices);
@@ -91,15 +74,17 @@ void DeviceFinder::startSearch()
emit devicesChanged();
-#ifdef SIMULATOR
- m_demoTimer.start();
-#else
- //! [devicediscovery-2]
- m_deviceDiscoveryAgent->start(QBluetoothDeviceDiscoveryAgent::LowEnergyMethod);
- //! [devicediscovery-2]
-#endif
+ if (simulator) {
+ m_demoTimer.start();
+ } else {
+ //! [devicediscovery-2]
+ m_deviceDiscoveryAgent->start(QBluetoothDeviceDiscoveryAgent::LowEnergyMethod);
+ //! [devicediscovery-2]
+ }
+
emit scanningChanged();
setInfo(tr("Scanning for devices..."));
+ setIcon(IconProgress);
}
//! [devicediscovery-3]
@@ -107,8 +92,20 @@ void DeviceFinder::addDevice(const QBluetoothDeviceInfo &device)
{
// If device is LowEnergy-device, add it to the list
if (device.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration) {
- m_devices.append(new DeviceInfo(device));
+ auto devInfo = new DeviceInfo(device);
+ auto it = std::find_if(m_devices.begin(), m_devices.end(),
+ [devInfo](DeviceInfo *dev) {
+ return devInfo->getAddress() == dev->getAddress();
+ });
+ if (it == m_devices.end()) {
+ m_devices.append(devInfo);
+ } else {
+ auto oldDev = *it;
+ *it = devInfo;
+ delete oldDev;
+ }
setInfo(tr("Low Energy device found. Scanning more..."));
+ setIcon(IconProgress);
//! [devicediscovery-3]
emit devicesChanged();
//! [devicediscovery-4]
@@ -125,33 +122,44 @@ void DeviceFinder::scanError(QBluetoothDeviceDiscoveryAgent::Error error)
setError(tr("Writing or reading from the device resulted in an error."));
else
setError(tr("An unknown error has occurred."));
+ setIcon(IconError);
}
void DeviceFinder::scanFinished()
{
-#ifdef SIMULATOR
- // Only for testing
- for (int i = 0; i < 4; i++)
- m_devices.append(new DeviceInfo(QBluetoothDeviceInfo()));
-#endif
+ if (simulator) {
+ // Only for testing
+ for (int i = 0; i < 4; i++)
+ m_devices.append(new DeviceInfo(QBluetoothDeviceInfo()));
+ }
- if (m_devices.isEmpty())
+ if (m_devices.isEmpty()) {
setError(tr("No Low Energy devices found."));
- else
+ setIcon(IconError);
+ } else {
setInfo(tr("Scanning done."));
+ setIcon(IconBluetooth);
+ }
emit scanningChanged();
emit devicesChanged();
}
+void DeviceFinder::resetMessages()
+{
+ setError("");
+ setInfo(tr("Start search to find devices"));
+ setIcon(IconSearch);
+}
+
void DeviceFinder::connectToService(const QString &address)
{
m_deviceDiscoveryAgent->stop();
DeviceInfo *currentDevice = nullptr;
- for (QObject *entry : qAsConst(m_devices)) {
+ for (QObject *entry : std::as_const(m_devices)) {
auto device = qobject_cast<DeviceInfo *>(entry);
- if (device && device->getAddress() == address ) {
+ if (device && device->getAddress() == address) {
currentDevice = device;
break;
}
@@ -160,16 +168,14 @@ void DeviceFinder::connectToService(const QString &address)
if (currentDevice)
m_deviceHandler->setDevice(currentDevice);
- clearMessages();
+ resetMessages();
}
bool DeviceFinder::scanning() const
{
-#ifdef SIMULATOR
- return m_demoTimer.isActive();
-#else
+ if (simulator)
+ return m_demoTimer.isActive();
return m_deviceDiscoveryAgent->isActive();
-#endif
}
QVariant DeviceFinder::devices()
diff --git a/examples/bluetooth/heartrate-game/devicefinder.h b/examples/bluetooth/heartrate-game/devicefinder.h
index 6dbb5692..703ef2c2 100644
--- a/examples/bluetooth/heartrate-game/devicefinder.h
+++ b/examples/bluetooth/heartrate-game/devicefinder.h
@@ -1,64 +1,21 @@
-/***************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef DEVICEFINDER_H
#define DEVICEFINDER_H
-#include "heartrate-global.h"
#include "bluetoothbaseclass.h"
+#include <QBluetoothDeviceDiscoveryAgent>
+
#include <QTimer>
#include <QVariant>
-#include <QBluetoothDeviceDiscoveryAgent>
-#include <QBluetoothDeviceInfo>
+#include <QQmlEngine>
+
+QT_BEGIN_NAMESPACE
+class QBluetoothDeviceInfo;
+QT_END_NAMESPACE
class DeviceInfo;
class DeviceHandler;
@@ -70,6 +27,9 @@ class DeviceFinder: public BluetoothBaseClass
Q_PROPERTY(bool scanning READ scanning NOTIFY scanningChanged)
Q_PROPERTY(QVariant devices READ devices NOTIFY devicesChanged)
+ QML_ELEMENT
+ QML_UNCREATABLE("This class is not intended to be created directly")
+
public:
DeviceFinder(DeviceHandler *handler, QObject *parent = nullptr);
~DeviceFinder();
@@ -82,7 +42,7 @@ public slots:
void connectToService(const QString &address);
private slots:
- void addDevice(const QBluetoothDeviceInfo&);
+ void addDevice(const QBluetoothDeviceInfo &device);
void scanError(QBluetoothDeviceDiscoveryAgent::Error error);
void scanFinished();
@@ -91,13 +51,13 @@ signals:
void devicesChanged();
private:
+ void resetMessages();
+
DeviceHandler *m_deviceHandler;
QBluetoothDeviceDiscoveryAgent *m_deviceDiscoveryAgent;
- QList<QObject*> m_devices;
+ QList<DeviceInfo *> m_devices;
-#ifdef SIMULATOR
QTimer m_demoTimer;
-#endif
};
#endif // DEVICEFINDER_H
diff --git a/examples/bluetooth/heartrate-game/devicehandler.cpp b/examples/bluetooth/heartrate-game/devicehandler.cpp
index 83a4fbbe..c264d771 100644
--- a/examples/bluetooth/heartrate-game/devicehandler.cpp
+++ b/examples/bluetooth/heartrate-game/devicehandler.cpp
@@ -1,73 +1,23 @@
-/***************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-#include "heartrate-global.h"
#include "devicehandler.h"
#include "deviceinfo.h"
+#include "heartrate-global.h"
+
#include <QtEndian>
#include <QRandomGenerator>
DeviceHandler::DeviceHandler(QObject *parent) :
- BluetoothBaseClass(parent),
- m_foundHeartRateService(false),
- m_measuring(false),
- m_currentValue(0),
- m_min(0), m_max(0), m_sum(0), m_avg(0), m_calories(0)
+ BluetoothBaseClass(parent)
{
-#ifdef SIMULATOR
- m_demoTimer.setSingleShot(false);
- m_demoTimer.setInterval(2000);
- connect(&m_demoTimer, &QTimer::timeout, this, &DeviceHandler::updateDemoHR);
- m_demoTimer.start();
- updateDemoHR();
-#endif
+ if (simulator) {
+ m_demoTimer.setSingleShot(false);
+ m_demoTimer.setInterval(2000);
+ connect(&m_demoTimer, &QTimer::timeout, this, &DeviceHandler::updateDemoHR);
+ m_demoTimer.start();
+ updateDemoHR();
+ }
}
void DeviceHandler::setAddressType(AddressType type)
@@ -95,10 +45,11 @@ void DeviceHandler::setDevice(DeviceInfo *device)
clearMessages();
m_currentDevice = device;
-#ifdef SIMULATOR
- setInfo(tr("Demo device connected."));
- return;
-#endif
+ if (simulator) {
+ setInfo(tr("Demo device connected."));
+ setIcon(IconBluetooth);
+ return;
+ }
// Disconnect and delete old connection
if (m_control) {
@@ -121,17 +72,20 @@ void DeviceHandler::setDevice(DeviceInfo *device)
connect(m_control, &QLowEnergyController::discoveryFinished,
this, &DeviceHandler::serviceScanDone);
- connect(m_control, static_cast<void (QLowEnergyController::*)(QLowEnergyController::Error)>(&QLowEnergyController::error),
- this, [this](QLowEnergyController::Error error) {
- Q_UNUSED(error);
- setError("Cannot connect to remote device.");
- });
+ connect(m_control, &QLowEnergyController::errorOccurred, this,
+ [this](QLowEnergyController::Error error) {
+ Q_UNUSED(error);
+ setError("Cannot connect to remote device.");
+ setIcon(IconError);
+ });
connect(m_control, &QLowEnergyController::connected, this, [this]() {
setInfo("Controller connected. Search services...");
+ setIcon(IconProgress);
m_control->discoverServices();
});
connect(m_control, &QLowEnergyController::disconnected, this, [this]() {
setError("LowEnergy controller disconnected");
+ setIcon(IconError);
});
// Connect
@@ -164,8 +118,9 @@ void DeviceHandler::stopMeasurement()
//! [Filter HeartRate service 1]
void DeviceHandler::serviceDiscovered(const QBluetoothUuid &gatt)
{
- if (gatt == QBluetoothUuid(QBluetoothUuid::HeartRate)) {
+ if (gatt == QBluetoothUuid(QBluetoothUuid::ServiceClassUuid::HeartRate)) {
setInfo("Heart Rate service discovered. Waiting for service scan to be done...");
+ setIcon(IconProgress);
m_foundHeartRateService = true;
}
}
@@ -174,6 +129,7 @@ void DeviceHandler::serviceDiscovered(const QBluetoothUuid &gatt)
void DeviceHandler::serviceScanDone()
{
setInfo("Service scan done.");
+ setIcon(IconBluetooth);
// Delete old service if available
if (m_service) {
@@ -184,7 +140,7 @@ void DeviceHandler::serviceScanDone()
//! [Filter HeartRate service 2]
// If heartRateService found, create new service
if (m_foundHeartRateService)
- m_service = m_control->createServiceObject(QBluetoothUuid(QBluetoothUuid::HeartRate), this);
+ m_service = m_control->createServiceObject(QBluetoothUuid(QBluetoothUuid::ServiceClassUuid::HeartRate), this);
if (m_service) {
connect(m_service, &QLowEnergyService::stateChanged, this, &DeviceHandler::serviceStateChanged);
@@ -193,6 +149,7 @@ void DeviceHandler::serviceScanDone()
m_service->discoverDetails();
} else {
setError("Heart Rate Service not found.");
+ setIcon(IconError);
}
//! [Filter HeartRate service 2]
}
@@ -202,20 +159,24 @@ void DeviceHandler::serviceScanDone()
void DeviceHandler::serviceStateChanged(QLowEnergyService::ServiceState s)
{
switch (s) {
- case QLowEnergyService::DiscoveringServices:
+ case QLowEnergyService::RemoteServiceDiscovering:
setInfo(tr("Discovering services..."));
+ setIcon(IconProgress);
break;
- case QLowEnergyService::ServiceDiscovered:
+ case QLowEnergyService::RemoteServiceDiscovered:
{
setInfo(tr("Service discovered."));
+ setIcon(IconBluetooth);
- const QLowEnergyCharacteristic hrChar = m_service->characteristic(QBluetoothUuid(QBluetoothUuid::HeartRateMeasurement));
+ const QLowEnergyCharacteristic hrChar =
+ m_service->characteristic(QBluetoothUuid(QBluetoothUuid::CharacteristicType::HeartRateMeasurement));
if (!hrChar.isValid()) {
setError("HR Data not found.");
+ setIcon(IconError);
break;
}
- m_notificationDesc = hrChar.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration);
+ m_notificationDesc = hrChar.descriptor(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration);
if (m_notificationDesc.isValid())
m_service->writeDescriptor(m_notificationDesc, QByteArray::fromHex("0100"));
@@ -234,7 +195,7 @@ void DeviceHandler::serviceStateChanged(QLowEnergyService::ServiceState s)
void DeviceHandler::updateHeartRateValue(const QLowEnergyCharacteristic &c, const QByteArray &value)
{
// ignore any other characteristic change -> shouldn't really happen though
- if (c.uuid() != QBluetoothUuid(QBluetoothUuid::HeartRateMeasurement))
+ if (c.uuid() != QBluetoothUuid(QBluetoothUuid::CharacteristicType::HeartRateMeasurement))
return;
auto data = reinterpret_cast<const quint8 *>(value.constData());
@@ -251,21 +212,18 @@ void DeviceHandler::updateHeartRateValue(const QLowEnergyCharacteristic &c, cons
}
//! [Reading value]
-#ifdef SIMULATOR
void DeviceHandler::updateDemoHR()
{
int randomValue = 0;
- if (m_currentValue < 30) { // Initial value
+ if (m_currentValue < 30) // Initial value
randomValue = 55 + QRandomGenerator::global()->bounded(30);
- } else if (!m_measuring) { // Value when relax
+ else if (!m_measuring) // Value when relax
randomValue = qBound(55, m_currentValue - 2 + QRandomGenerator::global()->bounded(5), 75);
- } else { // Measuring
+ else // Measuring
randomValue = m_currentValue + QRandomGenerator::global()->bounded(10) - 2;
- }
addMeasurement(randomValue);
}
-#endif
void DeviceHandler::confirmedDescriptorWrite(const QLowEnergyDescriptor &d, const QByteArray &value)
{
@@ -301,12 +259,11 @@ bool DeviceHandler::measuring() const
bool DeviceHandler::alive() const
{
-#ifdef SIMULATOR
- return true;
-#endif
+ if (simulator)
+ return true;
if (m_service)
- return m_service->state() == QLowEnergyService::ServiceDiscovered;
+ return m_service->state() == QLowEnergyService::RemoteServiceDiscovered;
return false;
}
@@ -355,7 +312,8 @@ void DeviceHandler::addMeasurement(int value)
m_max = qMax(value, m_max);
m_sum += value;
m_avg = (double)m_sum / m_measurements.size();
- m_calories = ((-55.0969 + (0.6309 * m_avg) + (0.1988 * 94) + (0.2017 * 24)) / 4.184) * 60 * time()/3600;
+ m_calories = ((-55.0969 + (0.6309 * m_avg) + (0.1988 * 94) + (0.2017 * 24)) / 4.184)
+ * 60 * time() / 3600;
}
emit statsChanged();
diff --git a/examples/bluetooth/heartrate-game/devicehandler.h b/examples/bluetooth/heartrate-game/devicehandler.h
index 4fa2782b..a010d396 100644
--- a/examples/bluetooth/heartrate-game/devicehandler.h
+++ b/examples/bluetooth/heartrate-game/devicehandler.h
@@ -1,64 +1,19 @@
-/***************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef DEVICEHANDLER_H
#define DEVICEHANDLER_H
#include "bluetoothbaseclass.h"
+#include <QLowEnergyController>
+#include <QLowEnergyService>
+
#include <QDateTime>
+#include <QList>
#include <QTimer>
-#include <QVector>
-#include <QLowEnergyController>
-#include <QLowEnergyService>
+#include <QQmlEngine>
class DeviceInfo;
@@ -76,6 +31,8 @@ class DeviceHandler : public BluetoothBaseClass
Q_PROPERTY(float calories READ calories NOTIFY statsChanged)
Q_PROPERTY(AddressType addressType READ addressType WRITE setAddressType)
+ QML_ELEMENT
+
public:
enum class AddressType {
PublicAddress,
@@ -120,11 +77,10 @@ private:
void updateHeartRateValue(const QLowEnergyCharacteristic &c,
const QByteArray &value);
void confirmedDescriptorWrite(const QLowEnergyDescriptor &d,
- const QByteArray &value);
+ const QByteArray &value);
-#ifdef SIMULATOR
void updateDemoHR();
-#endif
+
private:
void addMeasurement(int value);
@@ -133,21 +89,19 @@ private:
QLowEnergyDescriptor m_notificationDesc;
DeviceInfo *m_currentDevice = nullptr;
- bool m_foundHeartRateService;
- bool m_measuring;
- int m_currentValue, m_min, m_max, m_sum;
- float m_avg, m_calories;
+ bool m_foundHeartRateService = false;
+ bool m_measuring = false;
+ int m_currentValue = 0, m_min = 0, m_max = 0, m_sum = 0;
+ float m_avg = 0, m_calories = 0;
// Statistics
QDateTime m_start;
QDateTime m_stop;
- QVector<int> m_measurements;
+ QList<int> m_measurements;
QLowEnergyController::RemoteAddressType m_addressType = QLowEnergyController::PublicAddress;
-#ifdef SIMULATOR
QTimer m_demoTimer;
-#endif
};
#endif // DEVICEHANDLER_H
diff --git a/examples/bluetooth/heartrate-game/deviceinfo.cpp b/examples/bluetooth/heartrate-game/deviceinfo.cpp
index 4ed7f1b1..9bfff540 100644
--- a/examples/bluetooth/heartrate-game/deviceinfo.cpp
+++ b/examples/bluetooth/heartrate-game/deviceinfo.cpp
@@ -1,58 +1,14 @@
-/***************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-#include "heartrate-global.h"
#include "deviceinfo.h"
+#include "heartrate-global.h"
+
#include <QBluetoothAddress>
#include <QBluetoothUuid>
+using namespace Qt::StringLiterals;
+
DeviceInfo::DeviceInfo(const QBluetoothDeviceInfo &info):
m_device(info)
{
@@ -65,18 +21,16 @@ QBluetoothDeviceInfo DeviceInfo::getDevice() const
QString DeviceInfo::getName() const
{
-#ifdef SIMULATOR
- return "Demo device";
-#else
+ if (simulator)
+ return u"Demo BT Device"_s;
return m_device.name();
-#endif
}
QString DeviceInfo::getAddress() const
{
-#ifdef SIMULATOR
- return "00:11:22:33:44:55";
-#elif defined Q_OS_DARWIN
+ if (simulator)
+ return u"00:11:22:33:44:55"_s;
+#ifdef Q_OS_DARWIN
// workaround for Core Bluetooth:
return m_device.deviceUuid().toString();
#else
diff --git a/examples/bluetooth/heartrate-game/deviceinfo.h b/examples/bluetooth/heartrate-game/deviceinfo.h
index f8fc3a19..19dd7afb 100644
--- a/examples/bluetooth/heartrate-game/deviceinfo.h
+++ b/examples/bluetooth/heartrate-game/deviceinfo.h
@@ -1,63 +1,18 @@
-/***************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef DEVICEINFO_H
#define DEVICEINFO_H
-#include <QString>
-#include <QObject>
#include <QBluetoothDeviceInfo>
+#include <QObject>
+#include <QString>
+
class DeviceInfo: public QObject
{
Q_OBJECT
+
Q_PROPERTY(QString deviceName READ getName NOTIFY deviceChanged)
Q_PROPERTY(QString deviceAddress READ getAddress NOTIFY deviceChanged)
diff --git a/examples/bluetooth/heartrate-game/doc/images/heartgame-result.png b/examples/bluetooth/heartrate-game/doc/images/heartgame-result.png
deleted file mode 100644
index 2dad1b30..00000000
--- a/examples/bluetooth/heartrate-game/doc/images/heartgame-result.png
+++ /dev/null
Binary files differ
diff --git a/examples/bluetooth/heartrate-game/doc/images/heartgame-result.webp b/examples/bluetooth/heartrate-game/doc/images/heartgame-result.webp
new file mode 100644
index 00000000..58815ac0
--- /dev/null
+++ b/examples/bluetooth/heartrate-game/doc/images/heartgame-result.webp
Binary files differ
diff --git a/examples/bluetooth/heartrate-game/doc/images/heartgame-running.png b/examples/bluetooth/heartrate-game/doc/images/heartgame-running.png
deleted file mode 100644
index 05485f0e..00000000
--- a/examples/bluetooth/heartrate-game/doc/images/heartgame-running.png
+++ /dev/null
Binary files differ
diff --git a/examples/bluetooth/heartrate-game/doc/images/heartgame-running.webp b/examples/bluetooth/heartrate-game/doc/images/heartgame-running.webp
new file mode 100644
index 00000000..1de7af6d
--- /dev/null
+++ b/examples/bluetooth/heartrate-game/doc/images/heartgame-running.webp
Binary files differ
diff --git a/examples/bluetooth/heartrate-game/doc/images/heartgame-search.png b/examples/bluetooth/heartrate-game/doc/images/heartgame-search.png
deleted file mode 100644
index 4b0b0497..00000000
--- a/examples/bluetooth/heartrate-game/doc/images/heartgame-search.png
+++ /dev/null
Binary files differ
diff --git a/examples/bluetooth/heartrate-game/doc/images/heartgame-search.webp b/examples/bluetooth/heartrate-game/doc/images/heartgame-search.webp
new file mode 100644
index 00000000..727486d0
--- /dev/null
+++ b/examples/bluetooth/heartrate-game/doc/images/heartgame-search.webp
Binary files differ
diff --git a/examples/bluetooth/heartrate-game/doc/images/heartgame-start.png b/examples/bluetooth/heartrate-game/doc/images/heartgame-start.png
deleted file mode 100644
index 21cc641f..00000000
--- a/examples/bluetooth/heartrate-game/doc/images/heartgame-start.png
+++ /dev/null
Binary files differ
diff --git a/examples/bluetooth/heartrate-game/doc/images/heartgame-start.webp b/examples/bluetooth/heartrate-game/doc/images/heartgame-start.webp
new file mode 100644
index 00000000..9a49e4a1
--- /dev/null
+++ b/examples/bluetooth/heartrate-game/doc/images/heartgame-start.webp
Binary files differ
diff --git a/examples/bluetooth/heartrate-game/doc/src/heartrate-game.qdoc b/examples/bluetooth/heartrate-game/doc/src/heartrate-game.qdoc
index f0d4c365..891ffc69 100644
--- a/examples/bluetooth/heartrate-game/doc/src/heartrate-game.qdoc
+++ b/examples/bluetooth/heartrate-game/doc/src/heartrate-game.qdoc
@@ -1,43 +1,21 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example heartrate-game
\title Bluetooth Low Energy Heart Rate Game
+ \examplecategory {Connectivity}
+ \meta tags {bluetooth, ble, quick}
\brief A game demonstrating the interaction with a Bluetooth Low Energy Heart Rate
device/service.
The Bluetooth Low Energy Heart Rate Game shows how to develop a Bluetooth Low Energy
- application using the Qt Bluetooth API. The application covers the scanning for
+ application using the \l{QtBluetooth}{Qt Bluetooth API}. The application covers the scanning for
Bluetooth Low Energy devices, connecting to a Heart Rate service on the device, writing
characteristics and descriptors, and receiving updates from the device once the heart rate
has changed.
- \image heartgame-start.png
+ \image heartgame-start.webp
The example introduces the following Qt classes:
@@ -52,17 +30,30 @@
service is required for this application to work. An alternative might be a programmable
Bluetooth Low Energy device which might simulate the service. You can also use the
\l {heartrate-server} {Heart Rate server} example for that purpose.
- If no such device can be found, the example uses a demo mode which creates and displays
- random values.
+ If no such device is available, a demo mode is available which creates and displays
+ random values. This demo mode is enabled by passing \c{--simulator} on the
+ command line.
The goal of the game is to increase the measured heart rate as much as possible.
+ A detailed explanation of the APIs used in this example is given in the
+ \l {Using Qt Bluetooth Low Energy API} section of the \l{Qt Bluetooth} module
+ documentation.
+
The \l {lowenergyscanner}{Bluetooth Low Energy Scanner} example might be more suitable
if a heart rate device is not available. The scanner example works with any type of Bluetooth
Low Energy peripheral device.
\include examples-run.qdocinc
+ \section1 Checking Bluetooth Permissions
+
+ Before the application can start using Bluetooth, we have to check that
+ appropriate permissions were granted:
+
+ \snippet heartrate-game/devicefinder.cpp permissions
+
+
\section1 Visual Tour
The application searches for all Bluetooth Low Energy peripheral devices in the vicinity.
@@ -70,17 +61,17 @@
presented in a list. Note that all found Bluetooth Low Energy devices are listed even
if they do not offer a Heart Rate service.
- \image heartgame-search.png
+ \image heartgame-search.webp
After the user has selected a target device, the example connects to its Heart Rate service
if one is available. It automatically enables notification updates for the Heart Rate value
and presents the current value on the screen.
- \image heartgame-running.png
+ \image heartgame-running.webp
- Once the monitoring process is canceled, a small graph presents a summary of the received
- values.
+ Once the monitoring process is finished, a small summary of the received
+ values is presented.
- \image heartgame-result.png
+ \image heartgame-result.webp
*/
diff --git a/examples/bluetooth/heartrate-game/heartrate-game.pro b/examples/bluetooth/heartrate-game/heartrate-game.pro
index fcec0bd2..7cd5dcc5 100644
--- a/examples/bluetooth/heartrate-game/heartrate-game.pro
+++ b/examples/bluetooth/heartrate-game/heartrate-game.pro
@@ -2,7 +2,10 @@ TEMPLATE = app
TARGET = heartrate-game
QT += qml quick bluetooth
-CONFIG += c++11
+
+CONFIG += qmltypes
+QML_IMPORT_NAME = HeartRateGame
+QML_IMPORT_MAJOR_VERSION = 1
HEADERS += \
connectionhandler.h \
@@ -19,11 +22,36 @@ SOURCES += main.cpp \
devicehandler.cpp \
bluetoothbaseclass.cpp
-RESOURCES += qml.qrc \
- images.qrc
+qml_resources.files = \
+ qmldir \
+ App.qml \
+ BluetoothAlarmDialog.qml \
+ BottomLine.qml \
+ Connect.qml \
+ GameButton.qml \
+ GamePage.qml \
+ GameSettings.qml \
+ Measure.qml \
+ SplashScreen.qml \
+ Stats.qml \
+ StatsLabel.qml \
+ TitleBar.qml \
+ Main.qml \
+ images/alert.svg \
+ images/bluetooth.svg \
+ images/bt_off_to_on.png \
+ images/clock.svg \
+ images/heart.png \
+ images/logo.png \
+ images/progress.svg \
+ images/search.svg
+
+qml_resources.prefix = /qt/qml/HeartRateGame
+
+RESOURCES = qml_resources
-# Additional import path used to resolve QML modules in Qt Creator's code model
-QML_IMPORT_PATH =
+ios: QMAKE_INFO_PLIST = ../shared/Info.qmake.ios.plist
+macos: QMAKE_INFO_PLIST = ../shared/Info.qmake.macos.plist
target.path = $$[QT_INSTALL_EXAMPLES]/bluetooth/heartrate-game
INSTALLS += target
diff --git a/examples/bluetooth/heartrate-game/heartrate-global.h b/examples/bluetooth/heartrate-game/heartrate-global.h
index cc47bbb4..a967e64e 100644
--- a/examples/bluetooth/heartrate-game/heartrate-global.h
+++ b/examples/bluetooth/heartrate-game/heartrate-global.h
@@ -1,61 +1,9 @@
-/***************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef HEARTRATEGLOBAL_H
#define HEARTRATEGLOBAL_H
-//#define USE_SIMULATOR
-
-#if defined(Q_OS_WIN32) || defined(USE_SIMULATOR)
-#define SIMULATOR
-#endif
-
+extern bool simulator;
#endif // HEARTRATEGLOBAL_H
diff --git a/examples/bluetooth/heartrate-game/images.qrc b/examples/bluetooth/heartrate-game/images.qrc
deleted file mode 100644
index 38058de0..00000000
--- a/examples/bluetooth/heartrate-game/images.qrc
+++ /dev/null
@@ -1,7 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>qml/images/logo.png</file>
- <file>qml/images/bt_off_to_on.png</file>
- <file>qml/images/heart.png</file>
- </qresource>
-</RCC>
diff --git a/examples/bluetooth/heartrate-game/images/alert.svg b/examples/bluetooth/heartrate-game/images/alert.svg
new file mode 100644
index 00000000..c48c10e6
--- /dev/null
+++ b/examples/bluetooth/heartrate-game/images/alert.svg
@@ -0,0 +1,4 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M12 4C16.4183 4 20 7.58172 20 12C20 16.4183 16.4183 20 12 20C7.58172 20 4 16.4183 4 12C4 7.58172 7.58172 4 12 4ZM12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2Z" fill="white"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M12 13C11.4477 13 11 12.5523 11 12V8C11 7.44772 11.4477 7 12 7C12.5523 7 13 7.44772 13 8V12C13 12.5523 12.5523 13 12 13ZM12 15C12.5523 15 13 15.4477 13 16C13 16.5523 12.5523 17 12 17C11.4477 17 11 16.5523 11 16C11 15.4477 11.4477 15 12 15Z" fill="white"/>
+</svg>
diff --git a/examples/bluetooth/heartrate-game/images/bluetooth.svg b/examples/bluetooth/heartrate-game/images/bluetooth.svg
new file mode 100644
index 00000000..6d01b28f
--- /dev/null
+++ b/examples/bluetooth/heartrate-game/images/bluetooth.svg
@@ -0,0 +1,3 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M11.1869 2.24413C11.4926 2.11749 11.8445 2.18749 12.0785 2.42149L16.5785 6.92149C16.8981 7.24101 16.8981 7.75905 16.5785 8.07857L12.6571 12L16.5785 15.9215C16.8981 16.241 16.8981 16.7591 16.5785 17.0786L12.0785 21.5786C11.8445 21.8126 11.4926 21.8826 11.1869 21.7559C10.8812 21.6293 10.6818 21.331 10.6818 21V13.9753L7.57855 17.0786C7.25903 17.3981 6.74098 17.3981 6.42146 17.0786C6.10194 16.7591 6.10194 16.241 6.42146 15.9215L10.3429 12L6.42146 8.07857C6.10194 7.75905 6.10194 7.24101 6.42146 6.92149C6.74098 6.60197 7.25903 6.60197 7.57855 6.92149L10.6818 10.0248V3.00003C10.6818 2.66911 10.8812 2.37077 11.1869 2.24413ZM12.3182 13.9753L14.8429 16.5L12.3182 19.0248V13.9753ZM12.3182 10.0248V4.9753L14.8429 7.50003L12.3182 10.0248Z" fill="#80EBB6"/>
+</svg>
diff --git a/examples/bluetooth/heartrate-game/qml/images/bt_off_to_on.png b/examples/bluetooth/heartrate-game/images/bt_off_to_on.png
index 5ea1f3f0..5ea1f3f0 100644
--- a/examples/bluetooth/heartrate-game/qml/images/bt_off_to_on.png
+++ b/examples/bluetooth/heartrate-game/images/bt_off_to_on.png
Binary files differ
diff --git a/examples/bluetooth/heartrate-game/images/clock.svg b/examples/bluetooth/heartrate-game/images/clock.svg
new file mode 100644
index 00000000..655996ba
--- /dev/null
+++ b/examples/bluetooth/heartrate-game/images/clock.svg
@@ -0,0 +1,4 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M8 20H16V17C16 15.9 15.6083 14.9583 14.825 14.175C14.0417 13.3917 13.1 13 12 13C10.9 13 9.95833 13.3917 9.175 14.175C8.39167 14.9583 8 15.9 8 17V20ZM12 11C13.1 11 14.0417 10.6083 14.825 9.825C15.6083 9.04167 16 8.1 16 7V4H8V7C8 8.1 8.39167 9.04167 9.175 9.825C9.95833 10.6083 10.9 11 12 11ZM5 22C4.44772 22 4 21.5523 4 21C4 20.4477 4.44772 20 5 20H6V17C6 15.9833 6.2375 15.0292 6.7125 14.1375C7.1875 13.2458 7.85 12.5333 8.7 12C7.85 11.4667 7.1875 10.7542 6.7125 9.8625C6.2375 8.97083 6 8.01667 6 7V4H5C4.44772 4 4 3.55228 4 3C4 2.44772 4.44772 2 5 2H19C19.5523 2 20 2.44772 20 3C20 3.55228 19.5523 4 19 4H18V7C18 8.01667 17.7625 8.97083 17.2875 9.8625C16.8125 10.7542 16.15 11.4667 15.3 12C16.15 12.5333 16.8125 13.2458 17.2875 14.1375C17.7625 15.0292 18 15.9833 18 17V20H19C19.5523 20 20 20.4477 20 21C20 21.5523 19.5523 22 19 22H5Z" fill="#80EBB6"/>
+<path d="M17 22H7L7 18C7 15.2386 9.23858 13 12 13C14.7614 13 17 15.2386 17 18V22Z" fill="#80EBB6"/>
+</svg>
diff --git a/examples/bluetooth/heartrate-game/images/heart.png b/examples/bluetooth/heartrate-game/images/heart.png
new file mode 100644
index 00000000..4ba0f822
--- /dev/null
+++ b/examples/bluetooth/heartrate-game/images/heart.png
Binary files differ
diff --git a/examples/bluetooth/heartrate-game/qml/images/logo.png b/examples/bluetooth/heartrate-game/images/logo.png
index ea0af7e0..ea0af7e0 100644
--- a/examples/bluetooth/heartrate-game/qml/images/logo.png
+++ b/examples/bluetooth/heartrate-game/images/logo.png
Binary files differ
diff --git a/examples/bluetooth/heartrate-game/images/progress.svg b/examples/bluetooth/heartrate-game/images/progress.svg
new file mode 100644
index 00000000..449fe5e7
--- /dev/null
+++ b/examples/bluetooth/heartrate-game/images/progress.svg
@@ -0,0 +1,4 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M19 11C19 11.5523 19.4477 12 20 12C20.5523 12 21 11.5523 21 11V10.8478C21 8.11075 19.7088 5.53404 17.5163 3.89561C17.0739 3.56501 16.4472 3.65565 16.1166 4.09805C15.786 4.54046 15.8767 5.1671 16.3191 5.4977C18.0064 6.75857 19 8.74149 19 10.8478V11ZM4 12C4.55228 12 5 11.5523 5 11V10.8478C5 8.74149 5.99363 6.75857 7.68091 5.4977C8.12331 5.1671 8.21395 4.54046 7.88335 4.09805C7.55275 3.65565 6.92611 3.56501 6.4837 3.89561C4.29117 5.53404 3 8.11075 3 10.8478V11C3 11.5523 3.44772 12 4 12ZM7.10555 19.5528C7.35253 19.0588 7.95321 18.8586 8.44719 19.1055C10.6837 20.2238 13.3162 20.2238 15.5528 19.1056C16.0467 18.8586 16.6474 19.0588 16.8944 19.5528C17.1414 20.0468 16.9412 20.6474 16.4472 20.8944C13.6476 22.2942 10.3523 22.2942 7.55276 20.8944C7.05878 20.6474 6.85856 20.0467 7.10555 19.5528Z" fill="#80EBB6"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M13 5C13 5.55228 12.5523 6 12 6C11.4477 6 11 5.55228 11 5C11 4.44772 11.4477 4 12 4C12.5523 4 13 4.44772 13 5ZM15 5C15 6.65685 13.6569 8 12 8C10.3431 8 9 6.65685 9 5C9 3.34315 10.3431 2 12 2C13.6569 2 15 3.34315 15 5ZM5 17C5.55228 17 6 16.5523 6 16C6 15.4477 5.55228 15 5 15C4.44772 15 4 15.4477 4 16C4 16.5523 4.44772 17 5 17ZM5 19C6.65685 19 8 17.6569 8 16C8 14.3431 6.65685 13 5 13C3.34315 13 2 14.3431 2 16C2 17.6569 3.34315 19 5 19ZM19 17C19.5523 17 20 16.5523 20 16C20 15.4477 19.5523 15 19 15C18.4477 15 18 15.4477 18 16C18 16.5523 18.4477 17 19 17ZM19 19C20.6569 19 22 17.6569 22 16C22 14.3431 20.6569 13 19 13C17.3431 13 16 14.3431 16 16C16 17.6569 17.3431 19 19 19Z" fill="#80EBB6"/>
+</svg>
diff --git a/examples/bluetooth/heartrate-game/images/search.svg b/examples/bluetooth/heartrate-game/images/search.svg
new file mode 100644
index 00000000..9af5fe4d
--- /dev/null
+++ b/examples/bluetooth/heartrate-game/images/search.svg
@@ -0,0 +1,4 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M14.2929 14.2929C14.6834 13.9024 15.3166 13.9024 15.7071 14.2929L21.7071 20.2929C22.0976 20.6834 22.0976 21.3166 21.7071 21.7071C21.3166 22.0976 20.6834 22.0976 20.2929 21.7071L14.2929 15.7071C13.9024 15.3166 13.9024 14.6834 14.2929 14.2929Z" fill="#80EBB6"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M10 4C6.68629 4 4 6.68629 4 10C4 13.3137 6.68629 16 10 16C13.3137 16 16 13.3137 16 10C16 6.68629 13.3137 4 10 4ZM2 10C2 5.58172 5.58172 2 10 2C14.4183 2 18 5.58172 18 10C18 14.4183 14.4183 18 10 18C5.58172 18 2 14.4183 2 10Z" fill="#80EBB6"/>
+</svg>
diff --git a/examples/bluetooth/heartrate-game/main.cpp b/examples/bluetooth/heartrate-game/main.cpp
index 05557c05..47192114 100644
--- a/examples/bluetooth/heartrate-game/main.cpp
+++ b/examples/bluetooth/heartrate-game/main.cpp
@@ -1,80 +1,56 @@
-/***************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QGuiApplication>
-#include <QLoggingCategory>
-#include <QQmlApplicationEngine>
-#include <QQmlContext>
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "connectionhandler.h"
#include "devicefinder.h"
#include "devicehandler.h"
+#include "heartrate-global.h"
+
+#include <QCommandLineOption>
+#include <QCommandLineParser>
+#include <QLoggingCategory>
+
+#include <QGuiApplication>
+
+#include <QQmlApplicationEngine>
+
+using namespace Qt::StringLiterals;
+
+bool simulator = false;
int main(int argc, char *argv[])
{
- QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
- QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
+ QCommandLineParser parser;
+ parser.setApplicationDescription(u"Bluetooth Low Energy Heart Rate Game"_s);
+ parser.addHelpOption();
+ parser.addVersionOption();
+ QCommandLineOption simulatorOption(u"simulator"_s, u"Simulator"_s);
+ parser.addOption(simulatorOption);
+
+ QCommandLineOption verboseOption(u"verbose"_s, u"Verbose mode"_s);
+ parser.addOption(verboseOption);
+ parser.process(app);
+
+ if (parser.isSet(verboseOption))
+ QLoggingCategory::setFilterRules(u"qt.bluetooth* = true"_s);
+ simulator = parser.isSet(simulatorOption);
+
ConnectionHandler connectionHandler;
DeviceHandler deviceHandler;
DeviceFinder deviceFinder(&deviceHandler);
- qmlRegisterUncreatableType<DeviceHandler>("Shared", 1, 0, "AddressType", "Enum is not a type");
-
QQmlApplicationEngine engine;
- engine.rootContext()->setContextProperty("connectionHandler", &connectionHandler);
- engine.rootContext()->setContextProperty("deviceFinder", &deviceFinder);
- engine.rootContext()->setContextProperty("deviceHandler", &deviceHandler);
-
- engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
+ engine.setInitialProperties({
+ {u"connectionHandler"_s, QVariant::fromValue(&connectionHandler)},
+ {u"deviceFinder"_s, QVariant::fromValue(&deviceFinder)},
+ {u"deviceHandler"_s, QVariant::fromValue(&deviceHandler)}
+ });
+
+ QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed, &app,
+ []() { QCoreApplication::exit(1); }, Qt::QueuedConnection);
+ engine.loadFromModule("HeartRateGame", "Main");
return app.exec();
}
diff --git a/examples/bluetooth/heartrate-game/qml.qrc b/examples/bluetooth/heartrate-game/qml.qrc
deleted file mode 100644
index bab96355..00000000
--- a/examples/bluetooth/heartrate-game/qml.qrc
+++ /dev/null
@@ -1,18 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>qml/BluetoothAlarmDialog.qml</file>
- <file>qml/main.qml</file>
- <file>qml/SplashScreen.qml</file>
- <file>qml/GameSettings.qml</file>
- <file>qml/App.qml</file>
- <file>qml/TitleBar.qml</file>
- <file>qml/Connect.qml</file>
- <file>qml/Measure.qml</file>
- <file>qml/Stats.qml</file>
- <file>qml/GameButton.qml</file>
- <file>qml/GamePage.qml</file>
- <file>qml/BottomLine.qml</file>
- <file>qml/StatsLabel.qml</file>
- <file>qml/qmldir</file>
- </qresource>
-</RCC>
diff --git a/examples/bluetooth/heartrate-game/qml/App.qml b/examples/bluetooth/heartrate-game/qml/App.qml
deleted file mode 100644
index b61a7374..00000000
--- a/examples/bluetooth/heartrate-game/qml/App.qml
+++ /dev/null
@@ -1,130 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.5
-
-Item {
- id: app
- anchors.fill: parent
- opacity: 0.0
-
- Behavior on opacity { NumberAnimation { duration: 500 } }
-
- property var lastPages: []
- property int __currentIndex: 0
-
- function init()
- {
- opacity = 1.0
- showPage("Connect.qml")
- }
-
- function prevPage()
- {
- lastPages.pop()
- pageLoader.setSource(lastPages[lastPages.length-1])
- __currentIndex = lastPages.length-1;
- }
-
- function showPage(name)
- {
- lastPages.push(name)
- pageLoader.setSource(name)
- __currentIndex = lastPages.length-1;
- }
-
- TitleBar {
- id: titleBar
- currentIndex: __currentIndex
-
- onTitleClicked: {
- if (index < __currentIndex)
- pageLoader.item.close()
- }
- }
-
- Loader {
- id: pageLoader
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.top: titleBar.bottom
- anchors.bottom: parent.bottom
-
- onStatusChanged: {
- if (status === Loader.Ready)
- {
- pageLoader.item.init();
- pageLoader.item.forceActiveFocus()
- }
- }
- }
-
- Keys.onReleased: {
- switch (event.key) {
- case Qt.Key_Escape:
- case Qt.Key_Back: {
- if (__currentIndex > 0) {
- pageLoader.item.close()
- event.accepted = true
- } else {
- Qt.quit()
- }
- break;
- }
- default: break;
- }
- }
-
- BluetoothAlarmDialog {
- id: btAlarmDialog
- anchors.fill: parent
- visible: !connectionHandler.alive
- }
-}
diff --git a/examples/bluetooth/heartrate-game/qml/BluetoothAlarmDialog.qml b/examples/bluetooth/heartrate-game/qml/BluetoothAlarmDialog.qml
deleted file mode 100644
index df55c300..00000000
--- a/examples/bluetooth/heartrate-game/qml/BluetoothAlarmDialog.qml
+++ /dev/null
@@ -1,122 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.5
-
-Item {
- id: root
- anchors.fill: parent
-
- Rectangle {
- anchors.fill: parent
- color: "black"
- opacity: 0.9
- }
-
- MouseArea {
- id: eventEater
- }
-
- Rectangle {
- id: dialogFrame
-
- anchors.centerIn: parent
- width: parent.width * 0.8
- height: parent.height * 0.6
- border.color: "#454545"
- color: GameSettings.backgroundColor
- radius: width * 0.05
-
- Item {
- id: dialogContainer
- anchors.fill: parent
- anchors.margins: parent.width*0.05
-
- Image {
- id: offOnImage
- anchors.left: quitButton.left
- anchors.right: quitButton.right
- anchors.top: parent.top
- height: GameSettings.heightForWidth(width, sourceSize)
- source: "images/bt_off_to_on.png"
- }
-
- Text {
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.top: offOnImage.bottom
- anchors.bottom: quitButton.top
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- wrapMode: Text.WordWrap
- font.pixelSize: GameSettings.mediumFontSize
- color: GameSettings.textColor
- text: qsTr("This application cannot be used without Bluetooth. Please switch Bluetooth ON to continue.")
- }
-
- GameButton {
- id: quitButton
- anchors.bottom: parent.bottom
- anchors.horizontalCenter: parent.horizontalCenter
- width: dialogContainer.width * 0.6
- height: GameSettings.buttonHeight
- onClicked: Qt.quit()
-
- Text {
- anchors.centerIn: parent
- color: GameSettings.textColor
- font.pixelSize: GameSettings.bigFontSize
- text: qsTr("Quit")
- }
- }
- }
- }
-}
-
diff --git a/examples/bluetooth/heartrate-game/qml/BottomLine.qml b/examples/bluetooth/heartrate-game/qml/BottomLine.qml
deleted file mode 100644
index 6e99474a..00000000
--- a/examples/bluetooth/heartrate-game/qml/BottomLine.qml
+++ /dev/null
@@ -1,59 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.5
-
-Rectangle {
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.bottom: parent.bottom
- width: parent.width * 0.85
- height: parent.height * 0.05
- radius: height*0.5
-}
diff --git a/examples/bluetooth/heartrate-game/qml/Connect.qml b/examples/bluetooth/heartrate-game/qml/Connect.qml
deleted file mode 100644
index 519fe302..00000000
--- a/examples/bluetooth/heartrate-game/qml/Connect.qml
+++ /dev/null
@@ -1,188 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.5
-import Shared 1.0
-
-GamePage {
-
- errorMessage: deviceFinder.error
- infoMessage: deviceFinder.info
-
- Rectangle {
- id: viewContainer
- anchors.top: parent.top
- anchors.bottom:
- // only BlueZ platform has address type selection
- connectionHandler.requiresAddressType ? addressTypeButton.top : searchButton.top
- anchors.topMargin: GameSettings.fieldMargin + messageHeight
- anchors.bottomMargin: GameSettings.fieldMargin
- anchors.horizontalCenter: parent.horizontalCenter
- width: parent.width - GameSettings.fieldMargin*2
- color: GameSettings.viewColor
- radius: GameSettings.buttonRadius
-
-
- Text {
- id: title
- width: parent.width
- height: GameSettings.fieldHeight
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- color: GameSettings.textColor
- font.pixelSize: GameSettings.mediumFontSize
- text: qsTr("FOUND DEVICES")
-
- BottomLine {
- height: 1;
- width: parent.width
- color: "#898989"
- }
- }
-
-
- ListView {
- id: devices
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.bottom: parent.bottom
- anchors.top: title.bottom
- model: deviceFinder.devices
- clip: true
-
- delegate: Rectangle {
- id: box
- height:GameSettings.fieldHeight * 1.2
- width: parent.width
- color: index % 2 === 0 ? GameSettings.delegate1Color : GameSettings.delegate2Color
-
- MouseArea {
- anchors.fill: parent
- onClicked: {
- deviceFinder.connectToService(modelData.deviceAddress);
- app.showPage("Measure.qml")
- }
- }
-
- Text {
- id: device
- font.pixelSize: GameSettings.smallFontSize
- text: modelData.deviceName
- anchors.top: parent.top
- anchors.topMargin: parent.height * 0.1
- anchors.leftMargin: parent.height * 0.1
- anchors.left: parent.left
- color: GameSettings.textColor
- }
-
- Text {
- id: deviceAddress
- font.pixelSize: GameSettings.smallFontSize
- text: modelData.deviceAddress
- anchors.bottom: parent.bottom
- anchors.bottomMargin: parent.height * 0.1
- anchors.rightMargin: parent.height * 0.1
- anchors.right: parent.right
- color: Qt.darker(GameSettings.textColor)
- }
- }
- }
- }
-
- GameButton {
- id: addressTypeButton
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.bottom: searchButton.top
- anchors.bottomMargin: GameSettings.fieldMargin*0.5
- width: viewContainer.width
- height: GameSettings.fieldHeight
- visible: connectionHandler.requiresAddressType // only required on BlueZ
- state: "public"
- onClicked: state == "public" ? state = "random" : state = "public"
-
- states: [
- State {
- name: "public"
- PropertyChanges { target: addressTypeText; text: qsTr("Public Address") }
- PropertyChanges { target: deviceHandler; addressType: AddressType.PublicAddress }
- },
- State {
- name: "random"
- PropertyChanges { target: addressTypeText; text: qsTr("Random Address") }
- PropertyChanges { target: deviceHandler; addressType: AddressType.RandomAddress }
- }
- ]
-
- Text {
- id: addressTypeText
- anchors.centerIn: parent
- font.pixelSize: GameSettings.tinyFontSize
- color: GameSettings.textColor
- }
- }
-
- GameButton {
- id: searchButton
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.bottom: parent.bottom
- anchors.bottomMargin: GameSettings.fieldMargin
- width: viewContainer.width
- height: GameSettings.fieldHeight
- enabled: !deviceFinder.scanning
- onClicked: deviceFinder.startSearch()
-
- Text {
- anchors.centerIn: parent
- font.pixelSize: GameSettings.tinyFontSize
- text: qsTr("START SEARCH")
- color: searchButton.enabled ? GameSettings.textColor : GameSettings.disabledTextColor
- }
- }
-}
diff --git a/examples/bluetooth/heartrate-game/qml/GameButton.qml b/examples/bluetooth/heartrate-game/qml/GameButton.qml
deleted file mode 100644
index eabd8dcd..00000000
--- a/examples/bluetooth/heartrate-game/qml/GameButton.qml
+++ /dev/null
@@ -1,88 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.5
-import "."
-
-Rectangle {
- id: button
- color: baseColor
- onEnabledChanged: checkColor()
- radius: GameSettings.buttonRadius
-
- property color baseColor: GameSettings.buttonColor
- property color pressedColor: GameSettings.buttonPressedColor
- property color disabledColor: GameSettings.disabledButtonColor
-
- signal clicked()
-
- function checkColor()
- {
- if (!button.enabled) {
- button.color = disabledColor
- } else {
- if (mouseArea.containsPress)
- button.color = pressedColor
- else
- button.color = baseColor
- }
- }
-
- MouseArea {
- id: mouseArea
- anchors.fill: parent
- onPressed: checkColor()
- onReleased: checkColor()
- onClicked: {
- checkColor()
- button.clicked()
- }
- }
-}
diff --git a/examples/bluetooth/heartrate-game/qml/GamePage.qml b/examples/bluetooth/heartrate-game/qml/GamePage.qml
deleted file mode 100644
index 5e432e58..00000000
--- a/examples/bluetooth/heartrate-game/qml/GamePage.qml
+++ /dev/null
@@ -1,93 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.5
-import "."
-
-Item {
- anchors.fill: parent
-
- property string errorMessage: ""
- property string infoMessage: ""
- property real messageHeight: msg.height
- property bool hasError: errorMessage != ""
- property bool hasInfo: infoMessage != ""
-
- function init()
- {
- }
-
- function close()
- {
- app.prevPage()
- }
-
- Rectangle {
- id: msg
- anchors.top: parent.top
- anchors.left: parent.left
- anchors.right: parent.right
- height: GameSettings.fieldHeight
- color: hasError ? GameSettings.errorColor : GameSettings.infoColor
- visible: hasError || hasInfo
-
- Text {
- id: error
- anchors.fill: parent
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- minimumPixelSize: 5
- font.pixelSize: GameSettings.smallFontSize
- fontSizeMode: Text.Fit
- color: GameSettings.textColor
- text: hasError ? errorMessage : infoMessage
- }
- }
-}
diff --git a/examples/bluetooth/heartrate-game/qml/GameSettings.qml b/examples/bluetooth/heartrate-game/qml/GameSettings.qml
deleted file mode 100644
index e9edde90..00000000
--- a/examples/bluetooth/heartrate-game/qml/GameSettings.qml
+++ /dev/null
@@ -1,101 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-pragma Singleton
-import QtQuick 2.5
-
-Item {
- property int wHeight
- property int wWidth
-
- // Colors
- readonly property color backgroundColor: "#2d3037"
- readonly property color buttonColor: "#202227"
- readonly property color buttonPressedColor: "#6ccaf2"
- readonly property color disabledButtonColor: "#555555"
- readonly property color viewColor: "#202227"
- readonly property color delegate1Color: Qt.darker(viewColor, 1.2)
- readonly property color delegate2Color: Qt.lighter(viewColor, 1.2)
- readonly property color textColor: "#ffffff"
- readonly property color textDarkColor: "#232323"
- readonly property color disabledTextColor: "#777777"
- readonly property color sliderColor: "#6ccaf2"
- readonly property color errorColor: "#ba3f62"
- readonly property color infoColor: "#3fba62"
-
- // Font sizes
- property real microFontSize: hugeFontSize * 0.2
- property real tinyFontSize: hugeFontSize * 0.4
- property real smallTinyFontSize: hugeFontSize * 0.5
- property real smallFontSize: hugeFontSize * 0.6
- property real mediumFontSize: hugeFontSize * 0.7
- property real bigFontSize: hugeFontSize * 0.8
- property real largeFontSize: hugeFontSize * 0.9
- property real hugeFontSize: (wWidth + wHeight) * 0.03
- property real giganticFontSize: (wWidth + wHeight) * 0.04
-
- // Some other values
- property real fieldHeight: wHeight * 0.08
- property real fieldMargin: fieldHeight * 0.5
- property real buttonHeight: wHeight * 0.08
- property real buttonRadius: buttonHeight * 0.1
-
- // Some help functions
- function widthForHeight(h, ss)
- {
- return h/ss.height * ss.width;
- }
-
- function heightForWidth(w, ss)
- {
- return w/ss.width * ss.height;
- }
-
-}
diff --git a/examples/bluetooth/heartrate-game/qml/Measure.qml b/examples/bluetooth/heartrate-game/qml/Measure.qml
deleted file mode 100644
index 07056e6e..00000000
--- a/examples/bluetooth/heartrate-game/qml/Measure.qml
+++ /dev/null
@@ -1,244 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.5
-
-GamePage {
- id: measurePage
-
- errorMessage: deviceHandler.error
- infoMessage: deviceHandler.info
-
- property real __timeCounter: 0;
- property real __maxTimeCount: 60
- property string relaxText: qsTr("Relax!\nWhen you are ready, press Start. You have %1s time to increase heartrate so much as possible.\nGood luck!").arg(__maxTimeCount)
-
- function close()
- {
- deviceHandler.stopMeasurement();
- deviceHandler.disconnectService();
- app.prevPage();
- }
-
- function start()
- {
- if (!deviceHandler.measuring) {
- __timeCounter = 0;
- deviceHandler.startMeasurement()
- }
- }
-
- function stop()
- {
- if (deviceHandler.measuring) {
- deviceHandler.stopMeasurement()
- }
-
- app.showPage("Stats.qml")
- }
-
- Timer {
- id: measureTimer
- interval: 1000
- running: deviceHandler.measuring
- repeat: true
- onTriggered: {
- __timeCounter++;
- if (__timeCounter >= __maxTimeCount)
- measurePage.stop()
- }
- }
-
- Column {
- anchors.centerIn: parent
- spacing: GameSettings.fieldHeight * 0.5
-
- Rectangle {
- id: circle
- anchors.horizontalCenter: parent.horizontalCenter
- width: Math.min(measurePage.width, measurePage.height-GameSettings.fieldHeight*4) - 2*GameSettings.fieldMargin
- height: width
- radius: width*0.5
- color: GameSettings.viewColor
-
- Text {
- id: hintText
- anchors.centerIn: parent
- anchors.verticalCenterOffset: -parent.height*0.1
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- width: parent.width * 0.8
- height: parent.height * 0.6
- wrapMode: Text.WordWrap
- text: measurePage.relaxText
- visible: !deviceHandler.measuring
- color: GameSettings.textColor
- fontSizeMode: Text.Fit
- minimumPixelSize: 10
- font.pixelSize: GameSettings.mediumFontSize
- }
-
- Text {
- id: text
- anchors.centerIn: parent
- anchors.verticalCenterOffset: -parent.height*0.15
- font.pixelSize: parent.width * 0.45
- text: deviceHandler.hr
- visible: deviceHandler.measuring
- color: GameSettings.textColor
- }
-
- Item {
- id: minMaxContainer
- anchors.horizontalCenter: parent.horizontalCenter
- width: parent.width*0.7
- height: parent.height * 0.15
- anchors.bottom: parent.bottom
- anchors.bottomMargin: parent.height*0.16
- visible: deviceHandler.measuring
-
- Text {
- anchors.left: parent.left
- anchors.verticalCenter: parent.verticalCenter
- text: deviceHandler.minHR
- color: GameSettings.textColor
- font.pixelSize: GameSettings.hugeFontSize
-
- Text {
- anchors.left: parent.left
- anchors.bottom: parent.top
- font.pixelSize: parent.font.pixelSize*0.8
- color: parent.color
- text: "MIN"
- }
- }
-
- Text {
- anchors.right: parent.right
- anchors.verticalCenter: parent.verticalCenter
- text: deviceHandler.maxHR
- color: GameSettings.textColor
- font.pixelSize: GameSettings.hugeFontSize
-
- Text {
- anchors.right: parent.right
- anchors.bottom: parent.top
- font.pixelSize: parent.font.pixelSize*0.8
- color: parent.color
- text: "MAX"
- }
- }
- }
-
- Image {
- id: heart
- anchors.horizontalCenter: minMaxContainer.horizontalCenter
- anchors.verticalCenter: minMaxContainer.bottom
- width: parent.width * 0.2
- height: width
- source: "images/heart.png"
- smooth: true
- antialiasing: true
-
- SequentialAnimation{
- id: heartAnim
- running: deviceHandler.alive
- loops: Animation.Infinite
- alwaysRunToEnd: true
- PropertyAnimation { target: heart; property: "scale"; to: 1.2; duration: 500; easing.type: Easing.InQuad }
- PropertyAnimation { target: heart; property: "scale"; to: 1.0; duration: 500; easing.type: Easing.OutQuad }
- }
- }
- }
-
- Rectangle {
- id: timeSlider
- color: GameSettings.viewColor
- anchors.horizontalCenter: parent.horizontalCenter
- width: circle.width
- height: GameSettings.fieldHeight
- radius: GameSettings.buttonRadius
-
- Rectangle {
- height: parent.height
- radius: parent.radius
- color: GameSettings.sliderColor
- width: Math.min(1.0,__timeCounter / __maxTimeCount) * parent.width
- }
-
- Text {
- anchors.centerIn: parent
- color: "gray"
- text: (__maxTimeCount - __timeCounter).toFixed(0) + " s"
- font.pixelSize: GameSettings.bigFontSize
- }
- }
- }
-
- GameButton {
- id: startButton
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.bottom: parent.bottom
- anchors.bottomMargin: GameSettings.fieldMargin
- width: circle.width
- height: GameSettings.fieldHeight
- enabled: !deviceHandler.measuring
- radius: GameSettings.buttonRadius
-
- onClicked: start()
-
- Text {
- anchors.centerIn: parent
- font.pixelSize: GameSettings.tinyFontSize
- text: qsTr("START")
- color: startButton.enabled ? GameSettings.textColor : GameSettings.disabledTextColor
- }
- }
-}
diff --git a/examples/bluetooth/heartrate-game/qml/SplashScreen.qml b/examples/bluetooth/heartrate-game/qml/SplashScreen.qml
deleted file mode 100644
index 59870188..00000000
--- a/examples/bluetooth/heartrate-game/qml/SplashScreen.qml
+++ /dev/null
@@ -1,90 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.5
-import "."
-
-Item {
- id: root
- anchors.fill: parent
-
- property bool appIsReady: false
- property bool splashIsReady: false
-
- property bool ready: appIsReady && splashIsReady
- onReadyChanged: if (ready) readyToGo();
-
- signal readyToGo()
-
- function appReady()
- {
- appIsReady = true
- }
-
- function errorInLoadingApp()
- {
- Qt.quit()
- }
-
- Image {
- anchors.centerIn: parent
- width: Math.min(parent.height, parent.width)*0.6
- height: GameSettings.heightForWidth(width, sourceSize)
- source: "images/logo.png"
- }
-
- Timer {
- id: splashTimer
- interval: 1000
- onTriggered: splashIsReady = true
- }
-
- Component.onCompleted: splashTimer.start()
-}
diff --git a/examples/bluetooth/heartrate-game/qml/Stats.qml b/examples/bluetooth/heartrate-game/qml/Stats.qml
deleted file mode 100644
index 5d45fc8c..00000000
--- a/examples/bluetooth/heartrate-game/qml/Stats.qml
+++ /dev/null
@@ -1,99 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.5
-
-GamePage {
-
- Column {
- anchors.centerIn: parent
- width: parent.width
-
- Text {
- anchors.horizontalCenter: parent.horizontalCenter
- font.pixelSize: GameSettings.hugeFontSize
- color: GameSettings.textColor
- text: qsTr("RESULT")
- }
-
- Text {
- anchors.horizontalCenter: parent.horizontalCenter
- font.pixelSize: GameSettings.giganticFontSize*3
- color: GameSettings.textColor
- text: (deviceHandler.maxHR - deviceHandler.minHR).toFixed(0)
- }
-
- Item {
- height: GameSettings.fieldHeight
- width: 1
- }
-
- StatsLabel {
- title: qsTr("MIN")
- value: deviceHandler.minHR.toFixed(0)
- }
-
- StatsLabel {
- title: qsTr("MAX")
- value: deviceHandler.maxHR.toFixed(0)
- }
-
- StatsLabel {
- title: qsTr("AVG")
- value: deviceHandler.average.toFixed(1)
- }
-
-
- StatsLabel {
- title: qsTr("CALORIES")
- value: deviceHandler.calories.toFixed(3)
- }
- }
-}
diff --git a/examples/bluetooth/heartrate-game/qml/StatsLabel.qml b/examples/bluetooth/heartrate-game/qml/StatsLabel.qml
deleted file mode 100644
index ff5e0fbb..00000000
--- a/examples/bluetooth/heartrate-game/qml/StatsLabel.qml
+++ /dev/null
@@ -1,82 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.5
-import "."
-
-Item {
- height: GameSettings.fieldHeight
- width: parent.width
-
- property alias title: leftText.text
- property alias value: rightText.text
-
- Text {
- id: leftText
- anchors.left: parent.left
- height: parent.height
- width: parent.width * 0.45
- horizontalAlignment: Text.AlignRight
- verticalAlignment: Text.AlignVCenter
- font.pixelSize: GameSettings.mediumFontSize
- color: GameSettings.textColor
- }
-
- Text {
- id: rightText
- anchors.right: parent.right
- height: parent.height
- width: parent.width * 0.45
- horizontalAlignment: Text.AlignLeft
- verticalAlignment: Text.AlignVCenter
- font.pixelSize: GameSettings.mediumFontSize
- color: GameSettings.textColor
- }
-}
diff --git a/examples/bluetooth/heartrate-game/qml/TitleBar.qml b/examples/bluetooth/heartrate-game/qml/TitleBar.qml
deleted file mode 100644
index 3a3e2c42..00000000
--- a/examples/bluetooth/heartrate-game/qml/TitleBar.qml
+++ /dev/null
@@ -1,97 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.5
-
-Rectangle {
- id: titleBar
- anchors.top: parent.top
- anchors.left: parent.left
- anchors.right: parent.right
- height: GameSettings.fieldHeight
- color: GameSettings.viewColor
-
- property var __titles: ["CONNECT", "MEASURE", "STATS"]
- property int currentIndex: 0
-
- signal titleClicked(int index)
-
- Repeater {
- model: 3
- Text {
- width: titleBar.width / 3
- height: titleBar.height
- x: index * width
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- text: __titles[index]
- font.pixelSize: GameSettings.tinyFontSize
- color: titleBar.currentIndex === index ? GameSettings.textColor : GameSettings.disabledTextColor
-
- MouseArea {
- anchors.fill: parent
- onClicked: titleClicked(index)
- }
- }
- }
-
-
- Item {
- anchors.bottom: parent.bottom
- width: parent.width / 3
- height: parent.height
- x: currentIndex * width
-
- BottomLine{}
-
- Behavior on x { NumberAnimation { duration: 200 } }
- }
-
-}
diff --git a/examples/bluetooth/heartrate-game/qml/images/heart.png b/examples/bluetooth/heartrate-game/qml/images/heart.png
deleted file mode 100644
index f2b3c0a3..00000000
--- a/examples/bluetooth/heartrate-game/qml/images/heart.png
+++ /dev/null
Binary files differ
diff --git a/examples/bluetooth/heartrate-game/qml/main.qml b/examples/bluetooth/heartrate-game/qml/main.qml
deleted file mode 100644
index 0dfeef44..00000000
--- a/examples/bluetooth/heartrate-game/qml/main.qml
+++ /dev/null
@@ -1,105 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.7
-import QtQuick.Window 2.2
-import "."
-
-Window {
- id: wroot
- visible: true
- width: 720 * .7
- height: 1240 * .7
- title: qsTr("HeartRateGame")
- color: GameSettings.backgroundColor
-
- Component.onCompleted: {
- GameSettings.wWidth = Qt.binding(function() {return width})
- GameSettings.wHeight = Qt.binding(function() {return height})
- }
-
- Loader {
- id: splashLoader
- anchors.fill: parent
- source: "SplashScreen.qml"
- asynchronous: false
- visible: true
-
- onStatusChanged: {
- if (status === Loader.Ready) {
- appLoader.setSource("App.qml");
- }
- }
- }
-
- Connections {
- target: splashLoader.item
- onReadyToGo: {
- appLoader.visible = true
- appLoader.item.init()
- splashLoader.visible = false
- splashLoader.setSource("")
- appLoader.item.forceActiveFocus();
- }
- }
-
- Loader {
- id: appLoader
- anchors.fill: parent
- visible: false
- asynchronous: true
- onStatusChanged: {
- if (status === Loader.Ready)
- splashLoader.item.appReady()
- if (status === Loader.Error)
- splashLoader.item.errorInLoadingApp();
- }
- }
-}
diff --git a/examples/bluetooth/heartrate-game/qml/qmldir b/examples/bluetooth/heartrate-game/qml/qmldir
deleted file mode 100644
index 5e0d2b54..00000000
--- a/examples/bluetooth/heartrate-game/qml/qmldir
+++ /dev/null
@@ -1 +0,0 @@
-singleton GameSettings 1.0 GameSettings.qml
diff --git a/examples/bluetooth/heartrate-game/qmldir b/examples/bluetooth/heartrate-game/qmldir
new file mode 100644
index 00000000..161e6bab
--- /dev/null
+++ b/examples/bluetooth/heartrate-game/qmldir
@@ -0,0 +1,15 @@
+module HeartRateGame
+prefer :/qt/qml/HeartRateGame/
+App 1.0 App.qml
+BluetoothAlarmDialog 1.0 BluetoothAlarmDialog.qml
+BottomLine 1.0 BottomLine.qml
+Connect 1.0 Connect.qml
+GameButton 1.0 GameButton.qml
+GamePage 1.0 GamePage.qml
+singleton GameSettings 1.0 GameSettings.qml
+Measure 1.0 Measure.qml
+SplashScreen 1.0 SplashScreen.qml
+Stats 1.0 Stats.qml
+StatsLabel 1.0 StatsLabel.qml
+TitleBar 1.0 TitleBar.qml
+Main 1.0 Main.qml