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 QMLROTATIONSENSOR_P_H |
5 | #define QMLROTATIONSENSOR_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 QRotationSensor; |
23 | |
24 | class Q_SENSORSQUICK_PRIVATE_EXPORT QmlRotationSensor : public QmlSensor |
25 | { |
26 | Q_OBJECT |
27 | Q_PROPERTY(bool hasZ READ hasZ NOTIFY hasZChanged) |
28 | QML_NAMED_ELEMENT(RotationSensor) |
29 | QML_ADDED_IN_VERSION(5,0) |
30 | public: |
31 | explicit QmlRotationSensor(QObject *parent = 0); |
32 | ~QmlRotationSensor(); |
33 | |
34 | bool hasZ() const; |
35 | QSensor *sensor() const override; |
36 | |
37 | Q_SIGNALS: |
38 | void hasZChanged(bool hasZ); |
39 | |
40 | private: |
41 | QRotationSensor *m_sensor; |
42 | QmlSensorReading *createReading() const override; |
43 | }; |
44 | |
45 | class Q_SENSORSQUICK_PRIVATE_EXPORT QmlRotationSensorReading : public QmlSensorReading |
46 | { |
47 | Q_OBJECT |
48 | Q_PROPERTY(qreal x READ x NOTIFY xChanged BINDABLE bindableX) |
49 | Q_PROPERTY(qreal y READ y NOTIFY yChanged BINDABLE bindableY) |
50 | Q_PROPERTY(qreal z READ z NOTIFY zChanged BINDABLE bindableZ) |
51 | QML_NAMED_ELEMENT(RotationReading) |
52 | QML_UNCREATABLE("Cannot create RotationReading" ) |
53 | QML_ADDED_IN_VERSION(5,0) |
54 | public: |
55 | explicit QmlRotationSensorReading(QRotationSensor *sensor); |
56 | ~QmlRotationSensorReading(); |
57 | |
58 | qreal x() const; |
59 | QBindable<qreal> bindableX() const; |
60 | qreal y() const; |
61 | QBindable<qreal> bindableY() const; |
62 | qreal z() const; |
63 | QBindable<qreal> bindableZ() const; |
64 | |
65 | Q_SIGNALS: |
66 | void xChanged(); |
67 | void yChanged(); |
68 | void zChanged(); |
69 | |
70 | private: |
71 | QSensorReading *reading() const override; |
72 | void readingUpdate() override; |
73 | QRotationSensor *m_sensor; |
74 | Q_OBJECT_BINDABLE_PROPERTY(QmlRotationSensorReading, qreal, |
75 | m_x, &QmlRotationSensorReading::xChanged) |
76 | Q_OBJECT_BINDABLE_PROPERTY(QmlRotationSensorReading, qreal, |
77 | m_y, &QmlRotationSensorReading::yChanged) |
78 | Q_OBJECT_BINDABLE_PROPERTY(QmlRotationSensorReading, qreal, |
79 | m_z, &QmlRotationSensorReading::zChanged) |
80 | }; |
81 | |
82 | QT_END_NAMESPACE |
83 | #endif |
84 | |