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 "qproximitysensor.h" |
5 | #include "qproximitysensor_p.h" |
6 | |
7 | QT_BEGIN_NAMESPACE |
8 | |
9 | IMPLEMENT_READING(QProximityReading) |
10 | |
11 | /*! |
12 | \class QProximityReading |
13 | \ingroup sensors_reading |
14 | \inmodule QtSensors |
15 | \since 5.1 |
16 | |
17 | \brief The QProximityReading class represents one reading from the |
18 | proximity sensor. |
19 | |
20 | \target QProximityReading_Units |
21 | The proximity sensor can only indicate if an object is close or not. |
22 | |
23 | The distance at which an object is considered close is device-specific. This |
24 | distance may be available in the QSensor::outputRanges property. |
25 | */ |
26 | |
27 | /*! |
28 | \property QProximityReading::close |
29 | \brief a value indicating if something is close. |
30 | |
31 | Set to true if something is close. |
32 | Set to false is nothing is close. |
33 | |
34 | \sa QProximityReading_Units |
35 | */ |
36 | |
37 | bool QProximityReading::close() const |
38 | { |
39 | return d->close; |
40 | } |
41 | |
42 | /*! |
43 | Sets the close value to \a close. |
44 | */ |
45 | void QProximityReading::setClose(bool close) |
46 | { |
47 | d->close = close; |
48 | } |
49 | |
50 | // ===================================================================== |
51 | |
52 | /*! |
53 | \class QProximityFilter |
54 | \ingroup sensors_filter |
55 | \inmodule QtSensors |
56 | \since 5.1 |
57 | |
58 | \brief The QProximityFilter class is a convenience wrapper around QSensorFilter. |
59 | |
60 | The only difference is that the filter() method features a pointer to QProximityReading |
61 | instead of QSensorReading. |
62 | */ |
63 | |
64 | /*! |
65 | \fn QProximityFilter::filter(QProximityReading *reading) |
66 | |
67 | Called when \a reading changes. Returns false to prevent the reading from propagating. |
68 | |
69 | \sa QSensorFilter::filter() |
70 | */ |
71 | |
72 | bool QProximityFilter::filter(QSensorReading *reading) |
73 | { |
74 | return filter(reading: static_cast<QProximityReading*>(reading)); |
75 | } |
76 | |
77 | char const * const QProximitySensor::sensorType("QProximitySensor" ); |
78 | |
79 | /*! |
80 | \class QProximitySensor |
81 | \ingroup sensors_type |
82 | \inmodule QtSensors |
83 | \since 5.1 |
84 | |
85 | \brief The QProximitySensor class is a convenience wrapper around QSensor. |
86 | |
87 | The only behavioural difference is that this class sets the type properly. |
88 | |
89 | This class also features a reading() function that returns a QProximityReading instead of a QSensorReading. |
90 | |
91 | For details about how the sensor works, see \l QProximityReading. |
92 | |
93 | \sa QProximityReading |
94 | */ |
95 | |
96 | /*! |
97 | Construct the sensor as a child of \a parent. |
98 | */ |
99 | QProximitySensor::QProximitySensor(QObject *parent) |
100 | : QSensor(QProximitySensor::sensorType, parent) |
101 | { |
102 | } |
103 | |
104 | /*! |
105 | Destroy the sensor. Stops the sensor if it has not already been stopped. |
106 | */ |
107 | QProximitySensor::~QProximitySensor() |
108 | { |
109 | } |
110 | |
111 | /*! |
112 | \fn QProximitySensor::reading() const |
113 | |
114 | Returns the reading class for this sensor. |
115 | |
116 | \sa QSensor::reading() |
117 | */ |
118 | |
119 | QProximityReading *QProximitySensor::reading() const |
120 | { |
121 | return static_cast<QProximityReading*>(QSensor::reading()); |
122 | } |
123 | |
124 | QT_END_NAMESPACE |
125 | |
126 | #include "moc_qproximitysensor.cpp" |
127 | |