| 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 QMLMAGNETOMETER_P_H |
| 5 | #define QMLMAGNETOMETER_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 QMagnetometer; |
| 23 | |
| 24 | class Q_SENSORSQUICK_EXPORT QmlMagnetometer : public QmlSensor |
| 25 | { |
| 26 | Q_OBJECT |
| 27 | Q_PROPERTY(bool returnGeoValues READ returnGeoValues WRITE setReturnGeoValues NOTIFY returnGeoValuesChanged) |
| 28 | QML_NAMED_ELEMENT(Magnetometer) |
| 29 | QML_ADDED_IN_VERSION(5,0) |
| 30 | public: |
| 31 | explicit QmlMagnetometer(QObject *parent = 0); |
| 32 | ~QmlMagnetometer(); |
| 33 | |
| 34 | bool returnGeoValues() const; |
| 35 | void setReturnGeoValues(bool geo); |
| 36 | |
| 37 | QSensor *sensor() const override; |
| 38 | |
| 39 | Q_SIGNALS: |
| 40 | void returnGeoValuesChanged(bool returnGeoValues); |
| 41 | |
| 42 | private: |
| 43 | QMagnetometer *m_sensor; |
| 44 | QmlSensorReading *createReading() const override; |
| 45 | }; |
| 46 | |
| 47 | class Q_SENSORSQUICK_EXPORT QmlMagnetometerReading : public QmlSensorReading |
| 48 | { |
| 49 | Q_OBJECT |
| 50 | Q_PROPERTY(qreal x READ x NOTIFY xChanged BINDABLE bindableX) |
| 51 | Q_PROPERTY(qreal y READ y NOTIFY yChanged BINDABLE bindableY) |
| 52 | Q_PROPERTY(qreal z READ z NOTIFY zChanged BINDABLE bindableZ) |
| 53 | Q_PROPERTY(qreal calibrationLevel READ calibrationLevel |
| 54 | NOTIFY calibrationLevelChanged BINDABLE bindableCalibrationLevel) |
| 55 | QML_NAMED_ELEMENT(MagnetometerReading) |
| 56 | QML_UNCREATABLE("Cannot create MagnetometerReading" ) |
| 57 | QML_ADDED_IN_VERSION(5,0) |
| 58 | public: |
| 59 | explicit QmlMagnetometerReading(QMagnetometer *sensor); |
| 60 | ~QmlMagnetometerReading(); |
| 61 | |
| 62 | qreal x() const; |
| 63 | QBindable<qreal> bindableX() const; |
| 64 | qreal y() const; |
| 65 | QBindable<qreal> bindableY() const; |
| 66 | qreal z() const; |
| 67 | QBindable<qreal> bindableZ() const; |
| 68 | qreal calibrationLevel() const; |
| 69 | QBindable<qreal> bindableCalibrationLevel() const; |
| 70 | |
| 71 | |
| 72 | Q_SIGNALS: |
| 73 | void xChanged(); |
| 74 | void yChanged(); |
| 75 | void zChanged(); |
| 76 | void calibrationLevelChanged(); |
| 77 | |
| 78 | private: |
| 79 | QSensorReading *reading() const override; |
| 80 | void readingUpdate() override; |
| 81 | QMagnetometer *m_sensor; |
| 82 | Q_OBJECT_BINDABLE_PROPERTY(QmlMagnetometerReading, qreal, |
| 83 | m_x, &QmlMagnetometerReading::xChanged) |
| 84 | Q_OBJECT_BINDABLE_PROPERTY(QmlMagnetometerReading, qreal, |
| 85 | m_y, &QmlMagnetometerReading::yChanged) |
| 86 | Q_OBJECT_BINDABLE_PROPERTY(QmlMagnetometerReading, qreal, |
| 87 | m_z, &QmlMagnetometerReading::zChanged) |
| 88 | Q_OBJECT_BINDABLE_PROPERTY(QmlMagnetometerReading, qreal, |
| 89 | m_calibrationLevel, &QmlMagnetometerReading::calibrationLevelChanged) |
| 90 | }; |
| 91 | |
| 92 | QT_END_NAMESPACE |
| 93 | #endif |
| 94 | |