1// Copyright (C) 2016 Canonical 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 QMLHUMIDITYSENSOR_P_H
5#define QMLHUMIDITYSENSOR_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
20QT_BEGIN_NAMESPACE
21
22class QHumiditySensor;
23
24class Q_SENSORSQUICK_PRIVATE_EXPORT QmlHumiditySensor : public QmlSensor
25{
26 Q_OBJECT
27
28 QML_NAMED_ELEMENT(HumiditySensor)
29 QML_ADDED_IN_VERSION(5,9)
30public:
31 explicit QmlHumiditySensor(QObject *parent = nullptr);
32 ~QmlHumiditySensor();
33
34 QSensor *sensor() const override;
35
36private:
37 QmlSensorReading *createReading() const override;
38
39 QHumiditySensor *m_sensor;
40};
41
42class Q_SENSORSQUICK_PRIVATE_EXPORT QmlHumidityReading : public QmlSensorReading
43{
44 Q_OBJECT
45 Q_PROPERTY(qreal relativeHumidity READ relativeHumidity
46 NOTIFY relativeHumidityChanged BINDABLE bindableRelativeHumidity)
47 Q_PROPERTY(qreal absoluteHumidity READ absoluteHumidity
48 NOTIFY absoluteHumidityChanged BINDABLE bindableAbsoluteHumidity)
49 QML_NAMED_ELEMENT(HumidityReading)
50 QML_UNCREATABLE("Cannot create HumidityReading")
51 QML_ADDED_IN_VERSION(5,9)
52public:
53 explicit QmlHumidityReading(QHumiditySensor *sensor);
54 ~QmlHumidityReading();
55
56 qreal relativeHumidity() const;
57 QBindable<qreal> bindableRelativeHumidity() const;
58 qreal absoluteHumidity() const;
59 QBindable<qreal> bindableAbsoluteHumidity() const;
60
61Q_SIGNALS:
62 void relativeHumidityChanged();
63 void absoluteHumidityChanged();
64
65private:
66 QSensorReading *reading() const override;
67 void readingUpdate() override;
68
69 QHumiditySensor *m_sensor;
70 Q_OBJECT_BINDABLE_PROPERTY(QmlHumidityReading, qreal,
71 m_relativeHumidity, &QmlHumidityReading::relativeHumidityChanged)
72 Q_OBJECT_BINDABLE_PROPERTY(QmlHumidityReading, qreal,
73 m_absoluteHumidity, &QmlHumidityReading::absoluteHumidityChanged)
74};
75
76QT_END_NAMESPACE
77#endif
78

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