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 QMLPROXIMITYSENSOR_P_H
5#define QMLPROXIMITYSENSOR_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#ifdef near
20#undef near
21#endif
22QT_BEGIN_NAMESPACE
23
24class QProximitySensor;
25
26class Q_SENSORSQUICK_PRIVATE_EXPORT QmlProximitySensor : public QmlSensor
27{
28 Q_OBJECT
29 QML_NAMED_ELEMENT(ProximitySensor)
30 QML_ADDED_IN_VERSION(5,0)
31public:
32 explicit QmlProximitySensor(QObject *parent = 0);
33 ~QmlProximitySensor();
34
35 QSensor *sensor() const override;
36
37private:
38 QProximitySensor *m_sensor;
39 QmlSensorReading *createReading() const override;
40};
41
42class Q_SENSORSQUICK_PRIVATE_EXPORT QmlProximitySensorReading : public QmlSensorReading
43{
44 Q_OBJECT
45 Q_PROPERTY(bool near READ near NOTIFY nearChanged BINDABLE bindableNear)
46 QML_NAMED_ELEMENT(ProximityReading)
47 QML_UNCREATABLE("Cannot create ProximityReading")
48 QML_ADDED_IN_VERSION(5,0)
49public:
50 explicit QmlProximitySensorReading(QProximitySensor *sensor);
51 ~QmlProximitySensorReading();
52
53 bool near() const;
54 QBindable<bool> bindableNear() const;
55
56Q_SIGNALS:
57 void nearChanged();
58
59private:
60 QSensorReading *reading() const override;
61 void readingUpdate() override;
62 QProximitySensor *m_sensor;
63 Q_OBJECT_BINDABLE_PROPERTY(QmlProximitySensorReading, bool,
64 m_near, &QmlProximitySensorReading::nearChanged)
65};
66
67QT_END_NAMESPACE
68#endif
69

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