| 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 QMLTAPSENSOR_P_H |
| 5 | #define QMLTAPSENSOR_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/QTapSensor> |
| 20 | |
| 21 | QT_BEGIN_NAMESPACE |
| 22 | |
| 23 | class QTapSensor; |
| 24 | |
| 25 | class Q_SENSORSQUICK_EXPORT QmlTapSensor : public QmlSensor |
| 26 | { |
| 27 | Q_OBJECT |
| 28 | Q_PROPERTY(bool returnDoubleTapEvents READ returnDoubleTapEvents WRITE setReturnDoubleTapEvents NOTIFY returnDoubleTapEventsChanged) |
| 29 | QML_NAMED_ELEMENT(TapSensor) |
| 30 | QML_ADDED_IN_VERSION(5,0) |
| 31 | public: |
| 32 | explicit QmlTapSensor(QObject *parent = 0); |
| 33 | ~QmlTapSensor(); |
| 34 | |
| 35 | bool returnDoubleTapEvents() const; |
| 36 | void setReturnDoubleTapEvents(bool ret); |
| 37 | |
| 38 | QSensor *sensor() const override; |
| 39 | |
| 40 | Q_SIGNALS: |
| 41 | void returnDoubleTapEventsChanged(bool returnDoubleTapEvents); |
| 42 | |
| 43 | private: |
| 44 | QTapSensor *m_sensor; |
| 45 | QmlSensorReading *createReading() const override; |
| 46 | }; |
| 47 | |
| 48 | class Q_SENSORSQUICK_EXPORT QmlTapSensorReading : public QmlSensorReading |
| 49 | { |
| 50 | Q_OBJECT |
| 51 | Q_PROPERTY(QTapReading::TapDirection tapDirection READ tapDirection |
| 52 | NOTIFY tapDirectionChanged BINDABLE bindableTapDirection) |
| 53 | Q_PROPERTY(bool doubleTap READ isDoubleTap |
| 54 | NOTIFY isDoubleTapChanged BINDABLE bindableDoubleTap) |
| 55 | QML_NAMED_ELEMENT(TapReading) |
| 56 | QML_UNCREATABLE("Cannot create TapReading") |
| 57 | QML_ADDED_IN_VERSION(5,0) |
| 58 | public: |
| 59 | |
| 60 | explicit QmlTapSensorReading(QTapSensor *sensor); |
| 61 | ~QmlTapSensorReading(); |
| 62 | |
| 63 | QTapReading::TapDirection tapDirection() const; |
| 64 | QBindable<QTapReading::TapDirection> bindableTapDirection() const; |
| 65 | bool isDoubleTap() const; |
| 66 | QBindable<bool> bindableDoubleTap() const; |
| 67 | |
| 68 | Q_SIGNALS: |
| 69 | void tapDirectionChanged(); |
| 70 | void isDoubleTapChanged(); |
| 71 | |
| 72 | private: |
| 73 | QSensorReading *reading() const override; |
| 74 | void readingUpdate() override; |
| 75 | QTapSensor *m_sensor; |
| 76 | Q_OBJECT_BINDABLE_PROPERTY(QmlTapSensorReading, QTapReading::TapDirection, |
| 77 | m_tapDirection, &QmlTapSensorReading::tapDirectionChanged) |
| 78 | Q_OBJECT_BINDABLE_PROPERTY(QmlTapSensorReading, bool, |
| 79 | m_isDoubleTap, &QmlTapSensorReading::isDoubleTapChanged) |
| 80 | }; |
| 81 | |
| 82 | QT_END_NAMESPACE |
| 83 | #endif |
| 84 |
