| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QMLGYROSCOPE_P_H |
| 5 | #define QMLGYROSCOPE_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include "qmlsensor_p.h" |
| 19 | |
| 20 | QT_BEGIN_NAMESPACE |
| 21 | |
| 22 | class QGyroscope; |
| 23 | |
| 24 | class Q_SENSORSQUICK_EXPORT QmlGyroscope : public QmlSensor |
| 25 | { |
| 26 | Q_OBJECT |
| 27 | QML_NAMED_ELEMENT(Gyroscope) |
| 28 | QML_ADDED_IN_VERSION(5,0) |
| 29 | public: |
| 30 | explicit QmlGyroscope(QObject *parent = 0); |
| 31 | ~QmlGyroscope(); |
| 32 | |
| 33 | QSensor *sensor() const override; |
| 34 | |
| 35 | private: |
| 36 | QGyroscope *m_sensor; |
| 37 | QmlSensorReading *createReading() const override; |
| 38 | }; |
| 39 | |
| 40 | class Q_SENSORSQUICK_EXPORT QmlGyroscopeReading : public QmlSensorReading |
| 41 | { |
| 42 | Q_OBJECT |
| 43 | Q_PROPERTY(qreal x READ x NOTIFY xChanged BINDABLE bindableX) |
| 44 | Q_PROPERTY(qreal y READ y NOTIFY yChanged BINDABLE bindableY) |
| 45 | Q_PROPERTY(qreal z READ z NOTIFY zChanged BINDABLE bindableZ) |
| 46 | QML_NAMED_ELEMENT(GyroscopeReading) |
| 47 | QML_UNCREATABLE("Cannot create GyroscopeReading" ) |
| 48 | QML_ADDED_IN_VERSION(5,0) |
| 49 | public: |
| 50 | explicit QmlGyroscopeReading(QGyroscope *sensor); |
| 51 | ~QmlGyroscopeReading(); |
| 52 | |
| 53 | qreal x() const; |
| 54 | QBindable<qreal> bindableX() const; |
| 55 | qreal y() const; |
| 56 | QBindable<qreal> bindableY() const; |
| 57 | qreal z() const; |
| 58 | QBindable<qreal> bindableZ() const; |
| 59 | |
| 60 | Q_SIGNALS: |
| 61 | void xChanged(); |
| 62 | void yChanged(); |
| 63 | void zChanged(); |
| 64 | |
| 65 | private: |
| 66 | QSensorReading *reading() const override; |
| 67 | void readingUpdate() override; |
| 68 | QGyroscope *m_sensor; |
| 69 | Q_OBJECT_BINDABLE_PROPERTY(QmlGyroscopeReading, qreal, |
| 70 | m_x, &QmlGyroscopeReading::xChanged) |
| 71 | Q_OBJECT_BINDABLE_PROPERTY(QmlGyroscopeReading, qreal, |
| 72 | m_y, &QmlGyroscopeReading::yChanged) |
| 73 | Q_OBJECT_BINDABLE_PROPERTY(QmlGyroscopeReading, qreal, |
| 74 | m_z, &QmlGyroscopeReading::zChanged) |
| 75 | }; |
| 76 | |
| 77 | QT_END_NAMESPACE |
| 78 | #endif |
| 79 | |