1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the QtSensors module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or (at your option) the GNU General |
28 | ** Public license version 3 or any later version approved by the KDE Free |
29 | ** Qt Foundation. The licenses are as published by the Free Software |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
31 | ** included in the packaging of this file. Please review the following |
32 | ** information to ensure the GNU General Public License requirements will |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
35 | ** |
36 | ** $QT_END_LICENSE$ |
37 | ** |
38 | ****************************************************************************/ |
39 | |
40 | #include "qproximitysensor.h" |
41 | #include "qproximitysensor_p.h" |
42 | |
43 | QT_BEGIN_NAMESPACE |
44 | |
45 | IMPLEMENT_READING(QProximityReading) |
46 | |
47 | /*! |
48 | \class QProximityReading |
49 | \ingroup sensors_reading |
50 | \inmodule QtSensors |
51 | \since 5.1 |
52 | |
53 | \brief The QProximityReading class represents one reading from the |
54 | proximity sensor. |
55 | |
56 | \target QProximityReading_Units |
57 | The proximity sensor can only indicate if an object is close or not. |
58 | |
59 | The distance at which an object is considered close is device-specific. This |
60 | distance may be available in the QSensor::outputRanges property. |
61 | */ |
62 | |
63 | /*! |
64 | \property QProximityReading::close |
65 | \brief a value indicating if something is close. |
66 | |
67 | Set to true if something is close. |
68 | Set to false is nothing is close. |
69 | |
70 | \sa QProximityReading_Units |
71 | */ |
72 | |
73 | bool QProximityReading::close() const |
74 | { |
75 | return d->close; |
76 | } |
77 | |
78 | /*! |
79 | Sets the close value to \a close. |
80 | */ |
81 | void QProximityReading::setClose(bool close) |
82 | { |
83 | d->close = close; |
84 | } |
85 | |
86 | // ===================================================================== |
87 | |
88 | /*! |
89 | \class QProximityFilter |
90 | \ingroup sensors_filter |
91 | \inmodule QtSensors |
92 | \since 5.1 |
93 | |
94 | \brief The QProximityFilter class is a convenience wrapper around QSensorFilter. |
95 | |
96 | The only difference is that the filter() method features a pointer to QProximityReading |
97 | instead of QSensorReading. |
98 | */ |
99 | |
100 | /*! |
101 | \fn QProximityFilter::filter(QProximityReading *reading) |
102 | |
103 | Called when \a reading changes. Returns false to prevent the reading from propagating. |
104 | |
105 | \sa QSensorFilter::filter() |
106 | */ |
107 | |
108 | bool QProximityFilter::filter(QSensorReading *reading) |
109 | { |
110 | return filter(reading: static_cast<QProximityReading*>(reading)); |
111 | } |
112 | |
113 | char const * const QProximitySensor::type("QProximitySensor" ); |
114 | |
115 | /*! |
116 | \class QProximitySensor |
117 | \ingroup sensors_type |
118 | \inmodule QtSensors |
119 | \since 5.1 |
120 | |
121 | \brief The QProximitySensor class is a convenience wrapper around QSensor. |
122 | |
123 | The only behavioural difference is that this class sets the type properly. |
124 | |
125 | This class also features a reading() function that returns a QProximityReading instead of a QSensorReading. |
126 | |
127 | For details about how the sensor works, see \l QProximityReading. |
128 | |
129 | \sa QProximityReading |
130 | */ |
131 | |
132 | /*! |
133 | Construct the sensor as a child of \a parent. |
134 | */ |
135 | QProximitySensor::QProximitySensor(QObject *parent) |
136 | : QSensor(QProximitySensor::type, parent) |
137 | { |
138 | } |
139 | |
140 | /*! |
141 | Destroy the sensor. Stops the sensor if it has not already been stopped. |
142 | */ |
143 | QProximitySensor::~QProximitySensor() |
144 | { |
145 | } |
146 | |
147 | /*! |
148 | \fn QProximitySensor::reading() const |
149 | |
150 | Returns the reading class for this sensor. |
151 | |
152 | \sa QSensor::reading() |
153 | */ |
154 | |
155 | QProximityReading *QProximitySensor::reading() const |
156 | { |
157 | return static_cast<QProximityReading*>(QSensor::reading()); |
158 | } |
159 | |
160 | QT_END_NAMESPACE |
161 | |
162 | #include "moc_qproximitysensor.cpp" |
163 | |