| 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 | #ifndef QMLLIDSENSOR_P_H |
| 4 | #define QMLLIDSENSOR_P_H |
| 5 | |
| 6 | // |
| 7 | // W A R N I N G |
| 8 | // ------------- |
| 9 | // |
| 10 | // This file is not part of the Qt API. It exists purely as an |
| 11 | // implementation detail. This header file may change from version to |
| 12 | // version without notice, or even be removed. |
| 13 | // |
| 14 | // We mean it. |
| 15 | // |
| 16 | |
| 17 | #include "qmlsensor_p.h" |
| 18 | |
| 19 | QT_BEGIN_NAMESPACE |
| 20 | |
| 21 | class QLidSensor; |
| 22 | |
| 23 | class Q_SENSORSQUICK_EXPORT QmlLidSensor : public QmlSensor |
| 24 | { |
| 25 | Q_OBJECT |
| 26 | QML_NAMED_ELEMENT(LidSensor) |
| 27 | QML_ADDED_IN_VERSION(5,9) |
| 28 | public: |
| 29 | explicit QmlLidSensor(QObject *parent = 0); |
| 30 | ~QmlLidSensor(); |
| 31 | |
| 32 | QSensor *sensor() const override; |
| 33 | |
| 34 | private: |
| 35 | QmlSensorReading *createReading() const override; |
| 36 | |
| 37 | QLidSensor *m_sensor; |
| 38 | }; |
| 39 | |
| 40 | class Q_SENSORSQUICK_EXPORT QmlLidReading : public QmlSensorReading |
| 41 | { |
| 42 | Q_OBJECT |
| 43 | Q_PROPERTY(bool backLidClosed READ backLidClosed |
| 44 | NOTIFY backLidChanged BINDABLE bindableBackLidClosed) |
| 45 | Q_PROPERTY(bool frontLidClosed READ frontLidClosed |
| 46 | NOTIFY frontLidChanged BINDABLE bindableFrontLidClosed) |
| 47 | QML_NAMED_ELEMENT(LidReading) |
| 48 | QML_UNCREATABLE("Cannot create LidReading" ) |
| 49 | QML_ADDED_IN_VERSION(5,9) |
| 50 | public: |
| 51 | explicit QmlLidReading(QLidSensor *sensor); |
| 52 | ~QmlLidReading(); |
| 53 | |
| 54 | bool backLidClosed() const; |
| 55 | QBindable<bool> bindableBackLidClosed() const; |
| 56 | bool frontLidClosed() const; |
| 57 | QBindable<bool> bindableFrontLidClosed() const; |
| 58 | |
| 59 | Q_SIGNALS: |
| 60 | void backLidChanged(bool closed); |
| 61 | bool frontLidChanged(bool closed); |
| 62 | |
| 63 | private: |
| 64 | QSensorReading *reading() const override; |
| 65 | void readingUpdate() override; |
| 66 | |
| 67 | QLidSensor *m_sensor; |
| 68 | Q_OBJECT_BINDABLE_PROPERTY(QmlLidReading, bool, |
| 69 | m_backClosed, &QmlLidReading::backLidChanged) |
| 70 | Q_OBJECT_BINDABLE_PROPERTY(QmlLidReading, bool, |
| 71 | m_frontClosed, &QmlLidReading::frontLidChanged) |
| 72 | }; |
| 73 | |
| 74 | QT_END_NAMESPACE |
| 75 | #endif |
| 76 | |