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 QMLTILTSENSOR_P_H
5#define QMLTILTSENSOR_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/QTiltSensor>
20
21QT_BEGIN_NAMESPACE
22
23class QTiltSensor;
24
25class Q_SENSORSQUICK_PRIVATE_EXPORT QmlTiltSensor : public QmlSensor
26{
27 Q_OBJECT
28 QML_NAMED_ELEMENT(TiltSensor)
29 QML_ADDED_IN_VERSION(5,0)
30public:
31
32 explicit QmlTiltSensor(QObject *parent = 0);
33 ~QmlTiltSensor();
34 Q_INVOKABLE void calibrate();
35
36 QSensor *sensor() const override;
37
38private:
39 QTiltSensor *m_sensor;
40 QmlSensorReading *createReading() const override;
41};
42
43class Q_SENSORSQUICK_PRIVATE_EXPORT QmlTiltSensorReading : public QmlSensorReading
44{
45 Q_OBJECT
46 Q_PROPERTY(qreal yRotation READ yRotation NOTIFY yRotationChanged BINDABLE bindableYRotation)
47 Q_PROPERTY(qreal xRotation READ xRotation NOTIFY xRotationChanged BINDABLE bindableXRotation)
48 QML_NAMED_ELEMENT(TiltReading)
49 QML_UNCREATABLE("Cannot create TiltReading")
50 QML_ADDED_IN_VERSION(5,0)
51public:
52 explicit QmlTiltSensorReading(QTiltSensor *sensor);
53 ~QmlTiltSensorReading();
54
55 qreal yRotation() const;
56 QBindable<qreal> bindableYRotation() const;
57 qreal xRotation() const;
58 QBindable<qreal> bindableXRotation() const;
59
60Q_SIGNALS:
61 void yRotationChanged();
62 void xRotationChanged();
63
64private:
65 QSensorReading *reading() const override;
66 void readingUpdate() override;
67 QTiltSensor *m_sensor;
68 Q_OBJECT_BINDABLE_PROPERTY(QmlTiltSensorReading, qreal,
69 m_yRotation, &QmlTiltSensorReading::yRotationChanged)
70 Q_OBJECT_BINDABLE_PROPERTY(QmlTiltSensorReading, qreal,
71 m_xRotation, &QmlTiltSensorReading::xRotationChanged)
72};
73
74QT_END_NAMESPACE
75#endif
76

source code of qtsensors/src/sensorsquick/qmltiltsensor_p.h