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#include "qmltiltsensor_p.h"
5#include <QtSensors/qtiltsensor.h>
6
7QT_BEGIN_NAMESPACE
8QT_END_NAMESPACE
9
10/*!
11 \qmltype TiltSensor
12//! \instantiates QmlTiltSensor
13 \ingroup qml-sensors_type
14 \inqmlmodule QtSensors
15 \since QtSensors 5.0
16 \inherits Sensor
17 \brief The TiltSensor element reports tilt events
18 along the X and Y axes.
19
20 The TiltSensor element reports tilt events along the X and Y axes.
21
22 This element wraps the QTiltSensor class. Please see the documentation for
23 QTiltSensor for details.
24
25 \sa TiltReading
26*/
27
28QmlTiltSensor::QmlTiltSensor(QObject *parent)
29 : QmlSensor(parent)
30 , m_sensor(new QTiltSensor(this))
31{
32}
33
34QmlTiltSensor::~QmlTiltSensor()
35{
36}
37
38QmlSensorReading *QmlTiltSensor::createReading() const
39{
40 return new QmlTiltSensorReading(m_sensor);
41}
42
43QSensor *QmlTiltSensor::sensor() const
44{
45 return m_sensor;
46}
47
48/*!
49 \qmlmethod TiltSensor::calibrate()
50 Calibrate the tilt sensor.
51
52 Please see QTiltSensor::calibrate() for information about this property.
53*/
54void QmlTiltSensor::calibrate()
55{
56 m_sensor->calibrate();
57}
58
59/*!
60 \qmltype TiltReading
61//! \instantiates QmlTiltSensorReading
62 \ingroup qml-sensors_reading
63 \inqmlmodule QtSensors
64 \since QtSensors 5.0
65 \inherits SensorReading
66 \brief The TiltReading element holds the most recent TiltSensor reading.
67
68 The TiltReading element holds the most recent TiltSensor reading.
69
70 This element wraps the QTiltReading class. Please see the documentation for
71 QTiltReading for details.
72
73 This element cannot be directly created.
74*/
75
76QmlTiltSensorReading::QmlTiltSensorReading(QTiltSensor *sensor)
77 : m_sensor(sensor)
78{
79}
80
81QmlTiltSensorReading::~QmlTiltSensorReading()
82{
83}
84
85/*!
86 \qmlproperty qreal TiltReading::yRotation
87 This property holds the amount of tilt on the Y axis.
88
89 Please see QTiltReading::yRotation for information about this property.
90*/
91
92qreal QmlTiltSensorReading::yRotation() const
93{
94 return m_yRotation;
95}
96
97QBindable<qreal> QmlTiltSensorReading::bindableYRotation() const
98{
99 return &m_yRotation;
100}
101
102/*!
103 \qmlproperty qreal TiltReading::xRotation
104 This property holds the amount of tilt on the X axis.
105
106 Please see QTiltReading::xRotation for information about this property.
107*/
108
109qreal QmlTiltSensorReading::xRotation() const
110{
111 return m_xRotation;
112}
113
114QBindable<qreal> QmlTiltSensorReading::bindableXRotation() const
115{
116 return &m_xRotation;
117}
118
119QSensorReading *QmlTiltSensorReading::reading() const
120{
121 return m_sensor->reading();
122}
123
124void QmlTiltSensorReading::readingUpdate()
125{
126 m_yRotation = m_sensor->reading()->yRotation();
127 m_xRotation = m_sensor->reading()->xRotation();
128}
129

source code of qtsensors/src/sensorsquick/qmltiltsensor.cpp