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 <qlidsensor.h>
4#include "qlidsensor_p.h"
5
6QT_BEGIN_NAMESPACE
7
8IMPLEMENT_READING(QLidReading)
9
10/*!
11 \class QLidReading
12 \ingroup sensors_reading
13 \inmodule QtSensors
14 \since 5.9
15 \internal
16
17 \brief The QLidReading class holds readings from the Lid sensor.
18
19 A normal laptop has what we call a front lid.
20
21 If the laptop can be converted to a tablet by rotating or closing the lid
22 where the display is out, this is known as a back lid.
23
24 \section2 QLidReading Units
25 The Lid sensor can detect if a device's lid is closed or not. A lid can be a laptop,
26 a laptop that converts to a tablet, or even a cover for a tablet or phone.
27*/
28
29/*!
30 \property QLidReading::backLidClosed
31 \brief A value indicating whether the back lid is closed.
32 A back lid can be when a convertable laptop is closed
33 into to tablet mode without keyboard.
34
35 \sa {QLidReading Units}
36*/
37
38bool QLidReading::backLidClosed() const
39{
40 return d->backLidClosed;
41}
42
43/*!
44 Sets the backLidClosed value to \a closed.
45*/
46void QLidReading::setBackLidClosed(bool closed)
47{
48 d->backLidClosed = closed;
49}
50
51/*!
52 \property QLidReading::frontLidClosed
53 \brief A value indicating whether the front lid is closed.
54 A front lid would be a normal laptop lid.
55 \sa {QLidReading Units}
56*/
57
58bool QLidReading::frontLidClosed() const
59{
60 return d->frontLidClosed;
61}
62
63/*!
64 Sets the frontLidClosed value to \a closed.
65*/
66void QLidReading::setFrontLidClosed(bool closed)
67{
68 d->frontLidClosed = closed;
69}
70
71// =====================================================================
72
73/*!
74 \class QLidFilter
75 \ingroup sensors_filter
76 \inmodule QtSensors
77 \since 5.9
78 \internal
79
80 \brief The QLidFilter class is a convenience wrapper around QSensorFilter.
81
82 The only difference is that the filter() method features a pointer to QLidReading
83 instead of QSensorReading.
84*/
85
86/*!
87 \fn QLidFilter::filter(QLidReading *reading)
88
89 Called when \a reading changes. Returns false to prevent the reading from propagating.
90
91 \sa QSensorFilter::filter()
92*/
93
94bool QLidFilter::filter(QSensorReading *reading)
95{
96 return filter(reading: static_cast<QLidReading*>(reading));
97}
98
99char const * const QLidSensor::sensorType("QLidSensor");
100
101/*!
102 \class QLidSensor
103 \ingroup sensors_type
104 \inmodule QtSensors
105 \since 5.9
106 \internal
107
108 \brief The QLidSensor class is a convenience wrapper around QSensor.
109
110 The only behavioural difference is that this class sets the type properly.
111
112 This class also features a reading() function that returns a QLidReading instead
113 of a QSensorReading.
114
115 For details about how the sensor works, see \l QLidReading.
116
117 \sa QLidReading
118*/
119
120/*!
121 Construct the sensor as a child of \a parent.
122*/
123QLidSensor::QLidSensor(QObject *parent)
124 : QSensor(QLidSensor::sensorType, parent)
125{
126}
127
128/*!
129 Destroy the sensor. Stops the sensor if it has not already been stopped.
130*/
131QLidSensor::~QLidSensor()
132{
133}
134
135/*!
136 \fn QLidSensor::reading() const
137
138 Returns the reading class for this sensor.
139
140 \sa QSensor::reading()
141*/
142
143QLidReading *QLidSensor::reading() const
144{
145 return static_cast<QLidReading*>(QSensor::reading());
146}
147
148QT_END_NAMESPACE
149
150#include "moc_qlidsensor.cpp"
151

source code of qtsensors/src/sensors/qlidsensor.cpp