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 QMLLIGHTSENSOR_P_H |
5 | #define QMLLIGHTSENSOR_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 | |
20 | QT_BEGIN_NAMESPACE |
21 | |
22 | class QLightSensor; |
23 | |
24 | class Q_SENSORSQUICK_PRIVATE_EXPORT QmlLightSensor : public QmlSensor |
25 | { |
26 | Q_OBJECT |
27 | Q_PROPERTY(qreal fieldOfView READ fieldOfView NOTIFY fieldOfViewChanged) |
28 | QML_NAMED_ELEMENT(LightSensor) |
29 | QML_ADDED_IN_VERSION(5,0) |
30 | public: |
31 | explicit QmlLightSensor(QObject *parent = 0); |
32 | ~QmlLightSensor(); |
33 | |
34 | qreal fieldOfView() const; |
35 | QSensor *sensor() const override; |
36 | |
37 | Q_SIGNALS: |
38 | void fieldOfViewChanged(qreal fieldOfView); |
39 | |
40 | private: |
41 | QLightSensor *m_sensor; |
42 | QmlSensorReading *createReading() const override; |
43 | }; |
44 | |
45 | class Q_SENSORSQUICK_PRIVATE_EXPORT QmlLightSensorReading : public QmlSensorReading |
46 | { |
47 | Q_OBJECT |
48 | Q_PROPERTY(qreal illuminance READ illuminance |
49 | NOTIFY illuminanceChanged BINDABLE bindableIlluminance) |
50 | QML_NAMED_ELEMENT(LightReading) |
51 | QML_UNCREATABLE("Cannot create LightReading") |
52 | QML_ADDED_IN_VERSION(5,0) |
53 | public: |
54 | explicit QmlLightSensorReading(QLightSensor *sensor); |
55 | ~QmlLightSensorReading(); |
56 | |
57 | qreal illuminance() const; |
58 | QBindable<qreal> bindableIlluminance() const; |
59 | |
60 | Q_SIGNALS: |
61 | void illuminanceChanged(); |
62 | |
63 | private: |
64 | QSensorReading *reading() const override; |
65 | void readingUpdate() override; |
66 | QLightSensor *m_sensor; |
67 | Q_OBJECT_BINDABLE_PROPERTY(QmlLightSensorReading, qreal, |
68 | m_illuminance, &QmlLightSensorReading::illuminanceChanged) |
69 | }; |
70 | |
71 | QT_END_NAMESPACE |
72 | #endif |
73 |