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 "qmlirproximitysensor_p.h"
5#include <QtSensors/QIRProximitySensor>
6
7/*!
8 \qmltype IRProximitySensor
9//! \instantiates QmlIRProximitySensor
10 \ingroup qml-sensors_type
11 \inqmlmodule QtSensors
12 \since QtSensors 5.0
13 \inherits Sensor
14 \brief The IRProximitySensor element reports on infra-red reflectance values.
15 \internal
16
17 This element wraps the QIRProximitySensor class. Please see the documentation for
18 QIRProximitySensor for details.
19
20 \sa IRProximityReading
21*/
22
23QmlIRProximitySensor::QmlIRProximitySensor(QObject *parent)
24 : QmlSensor(parent)
25 , m_sensor(new QIRProximitySensor(this))
26{
27}
28
29QmlIRProximitySensor::~QmlIRProximitySensor()
30{
31}
32
33QmlSensorReading *QmlIRProximitySensor::createReading() const
34{
35 return new QmlIRProximitySensorReading(m_sensor);
36}
37
38QSensor *QmlIRProximitySensor::sensor() const
39{
40 return m_sensor;
41}
42
43/*!
44 \qmltype IRProximityReading
45//! \instantiates QmlIRProximitySensorReading
46 \ingroup qml-sensors_reading
47 \inqmlmodule QtSensors
48 \since QtSensors 5.0
49 \inherits SensorReading
50 \brief The IRProximityReading element holds the most recent IR proximity reading.
51 \internal
52
53 The IRProximityReading element holds the most recent IR proximity reading.
54
55 This element wraps the QIRProximityReading class. Please see the documentation for
56 QIRProximityReading for details.
57
58 This element cannot be directly created.
59*/
60
61QmlIRProximitySensorReading::QmlIRProximitySensorReading(QIRProximitySensor *sensor)
62 : m_sensor(sensor)
63{
64}
65
66QmlIRProximitySensorReading::~QmlIRProximitySensorReading()
67{
68}
69
70/*!
71 \qmlproperty qreal IRProximityReading::reflectance
72 This property holds the reflectance value.
73
74 Please see QIRProximityReading::reflectance for information about this property.
75*/
76
77qreal QmlIRProximitySensorReading::reflectance() const
78{
79 return m_reflectance;
80}
81
82QBindable<qreal> QmlIRProximitySensorReading::bindableReflectance() const
83{
84 return &m_reflectance;
85}
86
87
88QSensorReading *QmlIRProximitySensorReading::reading() const
89{
90 return m_sensor->reading();
91}
92
93void QmlIRProximitySensorReading::readingUpdate()
94{
95 m_reflectance = m_sensor->reading()->reflectance();
96}
97

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