diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-08-12 11:48:12 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-08-15 16:09:13 +0200 |
commit | 6ff04b182453f7a8cf6e73dd90b1a8282fc821d1 (patch) | |
tree | 03cb8a2f10acf6abbd838da19002d5926521edad | |
parent | 9e27158caaab6140b66c53587e30b525258329bb (diff) | |
download | qtconnectivity-6ff04b182453f7a8cf6e73dd90b1a8282fc821d1.tar.gz |
Bluetooth heartrate-game example: Basic polish
- Reorder includes by module
- Reorder Q_OBJECT macros
- Use member initialization
- Update copyright year
- Remove QML import versions
Change-Id: I00a817c07bf50efcb9fed60372c374d34d138640
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 4c3d8adc17cdbe80a3eb65727997a4b7db426b3f)
24 files changed, 67 insertions, 62 deletions
diff --git a/examples/bluetooth/heartrate-game/bluetoothbaseclass.cpp b/examples/bluetooth/heartrate-game/bluetoothbaseclass.cpp index 7f6a8f63..5b59a767 100644 --- a/examples/bluetooth/heartrate-game/bluetoothbaseclass.cpp +++ b/examples/bluetooth/heartrate-game/bluetoothbaseclass.cpp @@ -1,6 +1,6 @@ /*************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2022 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. diff --git a/examples/bluetooth/heartrate-game/bluetoothbaseclass.h b/examples/bluetooth/heartrate-game/bluetoothbaseclass.h index 5a043b3d..e681f263 100644 --- a/examples/bluetooth/heartrate-game/bluetoothbaseclass.h +++ b/examples/bluetooth/heartrate-game/bluetoothbaseclass.h @@ -1,6 +1,6 @@ /*************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2022 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. @@ -56,6 +56,7 @@ 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) diff --git a/examples/bluetooth/heartrate-game/connectionhandler.h b/examples/bluetooth/heartrate-game/connectionhandler.h index 9f5a42cc..055b6428 100644 --- a/examples/bluetooth/heartrate-game/connectionhandler.h +++ b/examples/bluetooth/heartrate-game/connectionhandler.h @@ -1,6 +1,6 @@ /*************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2022 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. @@ -51,17 +51,19 @@ #ifndef CONNECTIONHANDLER_H #define CONNECTIONHANDLER_H -#include <QObject> #include <QBluetoothLocalDevice> +#include <QObject> + class ConnectionHandler : public QObject { + Q_OBJECT + Q_PROPERTY(bool alive READ alive 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 public: explicit ConnectionHandler(QObject *parent = nullptr); diff --git a/examples/bluetooth/heartrate-game/devicefinder.cpp b/examples/bluetooth/heartrate-game/devicefinder.cpp index c63327f6..fdb536b7 100644 --- a/examples/bluetooth/heartrate-game/devicefinder.cpp +++ b/examples/bluetooth/heartrate-game/devicefinder.cpp @@ -1,6 +1,6 @@ /*************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2022 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. diff --git a/examples/bluetooth/heartrate-game/devicefinder.h b/examples/bluetooth/heartrate-game/devicefinder.h index 6dbb5692..2624b3b8 100644 --- a/examples/bluetooth/heartrate-game/devicefinder.h +++ b/examples/bluetooth/heartrate-game/devicefinder.h @@ -1,6 +1,6 @@ /*************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2022 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. @@ -54,11 +54,11 @@ #include "heartrate-global.h" #include "bluetoothbaseclass.h" -#include <QTimer> -#include <QVariant> #include <QBluetoothDeviceDiscoveryAgent> #include <QBluetoothDeviceInfo> +#include <QTimer> +#include <QVariant> class DeviceInfo; class DeviceHandler; diff --git a/examples/bluetooth/heartrate-game/devicehandler.cpp b/examples/bluetooth/heartrate-game/devicehandler.cpp index cf7020f6..4a51d159 100644 --- a/examples/bluetooth/heartrate-game/devicehandler.cpp +++ b/examples/bluetooth/heartrate-game/devicehandler.cpp @@ -1,6 +1,6 @@ /*************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2022 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. @@ -51,15 +51,12 @@ #include "heartrate-global.h" #include "devicehandler.h" #include "deviceinfo.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); diff --git a/examples/bluetooth/heartrate-game/devicehandler.h b/examples/bluetooth/heartrate-game/devicehandler.h index e8305f73..2dfc69e1 100644 --- a/examples/bluetooth/heartrate-game/devicehandler.h +++ b/examples/bluetooth/heartrate-game/devicehandler.h @@ -1,6 +1,6 @@ /*************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2022 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. @@ -53,13 +53,13 @@ #include "bluetoothbaseclass.h" +#include <QLowEnergyController> +#include <QLowEnergyService> + #include <QDateTime> #include <QList> #include <QTimer> -#include <QLowEnergyController> -#include <QLowEnergyService> - class DeviceInfo; class DeviceHandler : public BluetoothBaseClass @@ -133,10 +133,10 @@ 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; diff --git a/examples/bluetooth/heartrate-game/deviceinfo.cpp b/examples/bluetooth/heartrate-game/deviceinfo.cpp index 4ed7f1b1..0996336f 100644 --- a/examples/bluetooth/heartrate-game/deviceinfo.cpp +++ b/examples/bluetooth/heartrate-game/deviceinfo.cpp @@ -1,6 +1,6 @@ /*************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2022 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. @@ -50,6 +50,7 @@ #include "heartrate-global.h" #include "deviceinfo.h" + #include <QBluetoothAddress> #include <QBluetoothUuid> diff --git a/examples/bluetooth/heartrate-game/deviceinfo.h b/examples/bluetooth/heartrate-game/deviceinfo.h index f8fc3a19..82cc5731 100644 --- a/examples/bluetooth/heartrate-game/deviceinfo.h +++ b/examples/bluetooth/heartrate-game/deviceinfo.h @@ -1,6 +1,6 @@ /*************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2022 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. @@ -51,13 +51,15 @@ #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/heartrate-global.h b/examples/bluetooth/heartrate-game/heartrate-global.h index cc47bbb4..ad16ca74 100644 --- a/examples/bluetooth/heartrate-game/heartrate-global.h +++ b/examples/bluetooth/heartrate-game/heartrate-global.h @@ -1,6 +1,6 @@ /*************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2022 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. diff --git a/examples/bluetooth/heartrate-game/main.cpp b/examples/bluetooth/heartrate-game/main.cpp index 4a58ac90..bb122ed7 100644 --- a/examples/bluetooth/heartrate-game/main.cpp +++ b/examples/bluetooth/heartrate-game/main.cpp @@ -1,6 +1,6 @@ /*************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2022 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. @@ -48,15 +48,17 @@ ** ****************************************************************************/ -#include <QGuiApplication> -#include <QLoggingCategory> -#include <QQmlApplicationEngine> -#include <QQmlContext> - #include "connectionhandler.h" #include "devicefinder.h" #include "devicehandler.h" +#include <QQmlApplicationEngine> +#include <QQmlContext> + +#include <QGuiApplication> + +#include <QLoggingCategory> + int main(int argc, char *argv[]) { // QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true")); diff --git a/examples/bluetooth/heartrate-game/qml/App.qml b/examples/bluetooth/heartrate-game/qml/App.qml index b61a7374..add237a6 100644 --- a/examples/bluetooth/heartrate-game/qml/App.qml +++ b/examples/bluetooth/heartrate-game/qml/App.qml @@ -1,6 +1,6 @@ /*************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2022 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. @@ -48,7 +48,7 @@ ** ****************************************************************************/ -import QtQuick 2.5 +import QtQuick Item { id: app diff --git a/examples/bluetooth/heartrate-game/qml/BluetoothAlarmDialog.qml b/examples/bluetooth/heartrate-game/qml/BluetoothAlarmDialog.qml index df55c300..8ad2494f 100644 --- a/examples/bluetooth/heartrate-game/qml/BluetoothAlarmDialog.qml +++ b/examples/bluetooth/heartrate-game/qml/BluetoothAlarmDialog.qml @@ -1,6 +1,6 @@ /*************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2022 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. @@ -48,7 +48,7 @@ ** ****************************************************************************/ -import QtQuick 2.5 +import QtQuick Item { id: root diff --git a/examples/bluetooth/heartrate-game/qml/BottomLine.qml b/examples/bluetooth/heartrate-game/qml/BottomLine.qml index 6e99474a..7859da6b 100644 --- a/examples/bluetooth/heartrate-game/qml/BottomLine.qml +++ b/examples/bluetooth/heartrate-game/qml/BottomLine.qml @@ -1,6 +1,6 @@ /*************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2022 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. @@ -48,7 +48,7 @@ ** ****************************************************************************/ -import QtQuick 2.5 +import QtQuick Rectangle { anchors.horizontalCenter: parent.horizontalCenter diff --git a/examples/bluetooth/heartrate-game/qml/Connect.qml b/examples/bluetooth/heartrate-game/qml/Connect.qml index d19f49f9..fc0a7bf7 100644 --- a/examples/bluetooth/heartrate-game/qml/Connect.qml +++ b/examples/bluetooth/heartrate-game/qml/Connect.qml @@ -1,6 +1,6 @@ /*************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2022 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. @@ -48,8 +48,8 @@ ** ****************************************************************************/ -import QtQuick 2.5 -import Shared 1.0 +import QtQuick +import Shared GamePage { diff --git a/examples/bluetooth/heartrate-game/qml/GameButton.qml b/examples/bluetooth/heartrate-game/qml/GameButton.qml index eabd8dcd..a2336370 100644 --- a/examples/bluetooth/heartrate-game/qml/GameButton.qml +++ b/examples/bluetooth/heartrate-game/qml/GameButton.qml @@ -1,6 +1,6 @@ /*************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2022 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. @@ -48,7 +48,7 @@ ** ****************************************************************************/ -import QtQuick 2.5 +import QtQuick import "." Rectangle { diff --git a/examples/bluetooth/heartrate-game/qml/GamePage.qml b/examples/bluetooth/heartrate-game/qml/GamePage.qml index 5e432e58..cb8e9eb4 100644 --- a/examples/bluetooth/heartrate-game/qml/GamePage.qml +++ b/examples/bluetooth/heartrate-game/qml/GamePage.qml @@ -1,6 +1,6 @@ /*************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2022 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. @@ -48,7 +48,7 @@ ** ****************************************************************************/ -import QtQuick 2.5 +import QtQuick import "." Item { diff --git a/examples/bluetooth/heartrate-game/qml/GameSettings.qml b/examples/bluetooth/heartrate-game/qml/GameSettings.qml index e9edde90..28a1902a 100644 --- a/examples/bluetooth/heartrate-game/qml/GameSettings.qml +++ b/examples/bluetooth/heartrate-game/qml/GameSettings.qml @@ -1,6 +1,6 @@ /*************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2022 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. @@ -49,7 +49,7 @@ ****************************************************************************/ pragma Singleton -import QtQuick 2.5 +import QtQuick Item { property int wHeight diff --git a/examples/bluetooth/heartrate-game/qml/Measure.qml b/examples/bluetooth/heartrate-game/qml/Measure.qml index 07056e6e..c0ac6e75 100644 --- a/examples/bluetooth/heartrate-game/qml/Measure.qml +++ b/examples/bluetooth/heartrate-game/qml/Measure.qml @@ -1,6 +1,6 @@ /*************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2022 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. @@ -48,7 +48,7 @@ ** ****************************************************************************/ -import QtQuick 2.5 +import QtQuick GamePage { id: measurePage diff --git a/examples/bluetooth/heartrate-game/qml/SplashScreen.qml b/examples/bluetooth/heartrate-game/qml/SplashScreen.qml index 59870188..c7de8cdd 100644 --- a/examples/bluetooth/heartrate-game/qml/SplashScreen.qml +++ b/examples/bluetooth/heartrate-game/qml/SplashScreen.qml @@ -1,6 +1,6 @@ /*************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2022 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. @@ -48,7 +48,7 @@ ** ****************************************************************************/ -import QtQuick 2.5 +import QtQuick import "." Item { diff --git a/examples/bluetooth/heartrate-game/qml/Stats.qml b/examples/bluetooth/heartrate-game/qml/Stats.qml index 5d45fc8c..e2266c5c 100644 --- a/examples/bluetooth/heartrate-game/qml/Stats.qml +++ b/examples/bluetooth/heartrate-game/qml/Stats.qml @@ -1,6 +1,6 @@ /*************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2022 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. @@ -48,7 +48,7 @@ ** ****************************************************************************/ -import QtQuick 2.5 +import QtQuick GamePage { diff --git a/examples/bluetooth/heartrate-game/qml/StatsLabel.qml b/examples/bluetooth/heartrate-game/qml/StatsLabel.qml index ff5e0fbb..2e52fab2 100644 --- a/examples/bluetooth/heartrate-game/qml/StatsLabel.qml +++ b/examples/bluetooth/heartrate-game/qml/StatsLabel.qml @@ -1,6 +1,6 @@ /*************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2022 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. @@ -48,7 +48,7 @@ ** ****************************************************************************/ -import QtQuick 2.5 +import QtQuick import "." Item { diff --git a/examples/bluetooth/heartrate-game/qml/TitleBar.qml b/examples/bluetooth/heartrate-game/qml/TitleBar.qml index 3a3e2c42..edaa87a1 100644 --- a/examples/bluetooth/heartrate-game/qml/TitleBar.qml +++ b/examples/bluetooth/heartrate-game/qml/TitleBar.qml @@ -1,6 +1,6 @@ /*************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2022 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. @@ -48,7 +48,7 @@ ** ****************************************************************************/ -import QtQuick 2.5 +import QtQuick Rectangle { id: titleBar diff --git a/examples/bluetooth/heartrate-game/qml/main.qml b/examples/bluetooth/heartrate-game/qml/main.qml index 7476aab5..45d8073a 100644 --- a/examples/bluetooth/heartrate-game/qml/main.qml +++ b/examples/bluetooth/heartrate-game/qml/main.qml @@ -1,6 +1,6 @@ /*************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2022 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. @@ -48,8 +48,8 @@ ** ****************************************************************************/ -import QtQuick 2.7 -import QtQuick.Window 2.2 +import QtQuick +import QtQuick.Window import "." Window { |