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 QMLAMBIENTLIGHTSENSOR_P_H |
5 | #define QMLAMBIENTLIGHTSENSOR_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 | #include <QtSensors/QAmbientLightSensor> |
20 | |
21 | QT_BEGIN_NAMESPACE |
22 | |
23 | class QAmbientLightSensor; |
24 | |
25 | class Q_SENSORSQUICK_PRIVATE_EXPORT QmlAmbientLightSensor : public QmlSensor |
26 | { |
27 | Q_OBJECT |
28 | QML_NAMED_ELEMENT(AmbientLightSensor) |
29 | QML_ADDED_IN_VERSION(5,0) |
30 | public: |
31 | explicit QmlAmbientLightSensor(QObject *parent = 0); |
32 | ~QmlAmbientLightSensor(); |
33 | |
34 | QSensor *sensor() const override; |
35 | |
36 | private: |
37 | QAmbientLightSensor *m_sensor; |
38 | QmlSensorReading *createReading() const override; |
39 | |
40 | }; |
41 | |
42 | class Q_SENSORSQUICK_PRIVATE_EXPORT QmlAmbientLightSensorReading : public QmlSensorReading |
43 | { |
44 | Q_OBJECT |
45 | Q_PROPERTY(QAmbientLightReading::LightLevel lightLevel READ lightLevel |
46 | NOTIFY lightLevelChanged BINDABLE bindableLightLevel) |
47 | QML_NAMED_ELEMENT(AmbientLightReading) |
48 | QML_UNCREATABLE("Cannot create AmbientLightReading") |
49 | QML_ADDED_IN_VERSION(5,0) |
50 | public: |
51 | |
52 | explicit QmlAmbientLightSensorReading(QAmbientLightSensor *sensor); |
53 | ~QmlAmbientLightSensorReading(); |
54 | |
55 | QAmbientLightReading::LightLevel lightLevel() const; |
56 | QBindable<QAmbientLightReading::LightLevel> bindableLightLevel() const; |
57 | |
58 | Q_SIGNALS: |
59 | void lightLevelChanged(); |
60 | |
61 | private: |
62 | QSensorReading *reading() const override; |
63 | void readingUpdate() override; |
64 | QAmbientLightSensor *m_sensor; |
65 | Q_OBJECT_BINDABLE_PROPERTY(QmlAmbientLightSensorReading, QAmbientLightReading::LightLevel, |
66 | m_lightLevel, &QmlAmbientLightSensorReading::lightLevelChanged) |
67 | }; |
68 | |
69 | QT_END_NAMESPACE |
70 | #endif |
71 |