| 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 QMLORIENTATIONSENSOR_P_H |
| 5 | #define QMLORIENTATIONSENSOR_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 | #include <QtSensors/QOrientationSensor> |
| 20 | |
| 21 | QT_BEGIN_NAMESPACE |
| 22 | |
| 23 | class QOrientationSensor; |
| 24 | |
| 25 | class Q_SENSORSQUICK_EXPORT QmlOrientationSensor : public QmlSensor |
| 26 | { |
| 27 | Q_OBJECT |
| 28 | QML_NAMED_ELEMENT(OrientationSensor) |
| 29 | QML_ADDED_IN_VERSION(5,0) |
| 30 | public: |
| 31 | explicit QmlOrientationSensor(QObject *parent = 0); |
| 32 | ~QmlOrientationSensor(); |
| 33 | |
| 34 | QSensor *sensor() const override; |
| 35 | |
| 36 | private: |
| 37 | QOrientationSensor *m_sensor; |
| 38 | QmlSensorReading *createReading() const override; |
| 39 | }; |
| 40 | |
| 41 | class Q_SENSORSQUICK_EXPORT QmlOrientationSensorReading : public QmlSensorReading |
| 42 | { |
| 43 | Q_OBJECT |
| 44 | Q_PROPERTY(QOrientationReading::Orientation orientation READ orientation |
| 45 | NOTIFY orientationChanged BINDABLE bindableOrientation) |
| 46 | QML_NAMED_ELEMENT(OrientationReading) |
| 47 | QML_UNCREATABLE("Cannot create OrientationReading") |
| 48 | QML_ADDED_IN_VERSION(5,0) |
| 49 | public: |
| 50 | |
| 51 | explicit QmlOrientationSensorReading(QOrientationSensor *sensor); |
| 52 | ~QmlOrientationSensorReading(); |
| 53 | |
| 54 | QOrientationReading::Orientation orientation() const; |
| 55 | QBindable<QOrientationReading::Orientation> bindableOrientation() const; |
| 56 | |
| 57 | Q_SIGNALS: |
| 58 | void orientationChanged(); |
| 59 | |
| 60 | private: |
| 61 | QSensorReading *reading() const override; |
| 62 | void readingUpdate() override; |
| 63 | QOrientationSensor *m_sensor; |
| 64 | Q_OBJECT_BINDABLE_PROPERTY(QmlOrientationSensorReading, QOrientationReading::Orientation, |
| 65 | m_orientation, &QmlOrientationSensorReading::orientationChanged) |
| 66 | }; |
| 67 | |
| 68 | QT_END_NAMESPACE |
| 69 | #endif |
| 70 |
