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#include "qmllidsensor_p.h"
4#include <QtSensors/QLidSensor>
5
6/*!
7 \qmltype LidSensor
8//! \instantiates QmlLidSensor
9 \ingroup qml-sensors_type
10 \inqmlmodule QtSensors
11 \since QtSensors 5.9
12 \inherits Sensor
13 \brief The LidSensor element reports on whether a device is closed.
14 \internal
15
16 The LidSensor element reports on whether a device is closed.
17
18 This element wraps the QLidSensor class. Please see the documentation for
19 QLidSensor for details.
20
21 \sa LidReading
22*/
23
24QmlLidSensor::QmlLidSensor(QObject *parent)
25 : QmlSensor(parent)
26 , m_sensor(new QLidSensor(this))
27{
28}
29
30QmlLidSensor::~QmlLidSensor()
31{
32}
33
34QmlSensorReading *QmlLidSensor::createReading() const
35{
36 return new QmlLidReading(m_sensor);
37}
38
39QSensor *QmlLidSensor::sensor() const
40{
41 return m_sensor;
42}
43
44/*!
45 \qmltype LidReading
46//! \instantiates QmlLidReading
47 \ingroup qml-sensors_reading
48 \inqmlmodule QtSensors
49 \since QtSensors 5.9
50 \inherits SensorReading
51 \brief The LidReading element holds the most recent LidSensor reading.
52 \internal
53
54 The LidReading element holds the most recent LidSensor reading.
55
56 This element wraps the QLidReading class. Please see the documentation for
57 QLidReading for details.
58
59 This element cannot be directly created.
60*/
61
62QmlLidReading::QmlLidReading(QLidSensor *sensor)
63 : m_sensor(sensor)
64 , m_backClosed(false)
65 , m_frontClosed(true)
66{
67}
68
69QmlLidReading::~QmlLidReading()
70{
71}
72
73/*!
74 \qmlproperty qreal LidReading::backLidClosed
75 This property holds whether the back lid is closed.
76
77 Please see QLidReading::backLidClosed for information about this property.
78*/
79
80bool QmlLidReading::backLidClosed() const
81{
82 return m_backClosed;
83}
84
85QBindable<bool> QmlLidReading::bindableBackLidClosed() const
86{
87 return &m_backClosed;
88}
89
90/*!
91 \qmlproperty qreal LidReading::frontLidClosed
92 This property holds whether the front lid is closed.
93
94 Please see QLidReading::frontLidClosed for information about this property.
95*/
96
97bool QmlLidReading::frontLidClosed() const
98{
99 return m_frontClosed;
100}
101
102QBindable<bool> QmlLidReading::bindableFrontLidClosed() const
103{
104 return &m_frontClosed;
105}
106
107QSensorReading *QmlLidReading::reading() const
108{
109 return m_sensor->reading();
110}
111
112void QmlLidReading::readingUpdate()
113{
114 m_backClosed = m_sensor->reading()->backLidClosed();
115 m_frontClosed = m_sensor->reading()->frontLidClosed();
116}
117

source code of qtsensors/src/sensorsquick/qmllidsensor.cpp