| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2016 Canonical, Ltd |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the QtSensors module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU Lesser General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
| 24 | ** |
| 25 | ** GNU General Public License Usage |
| 26 | ** Alternatively, this file may be used under the terms of the GNU |
| 27 | ** General Public License version 2.0 or (at your option) the GNU General |
| 28 | ** Public license version 3 or any later version approved by the KDE Free |
| 29 | ** Qt Foundation. The licenses are as published by the Free Software |
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
| 31 | ** included in the packaging of this file. Please review the following |
| 32 | ** information to ensure the GNU General Public License requirements will |
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
| 35 | ** |
| 36 | ** $QT_END_LICENSE$ |
| 37 | ** |
| 38 | ****************************************************************************/ |
| 39 | #include <qlidsensor.h> |
| 40 | #include "qlidsensor_p.h" |
| 41 | |
| 42 | QT_BEGIN_NAMESPACE |
| 43 | |
| 44 | IMPLEMENT_READING(QLidReading) |
| 45 | |
| 46 | /*! |
| 47 | \class QLidReading |
| 48 | \ingroup sensors_reading |
| 49 | \inmodule QtSensors |
| 50 | \since 5.9 |
| 51 | |
| 52 | \brief The QLidReading class holds readings from the Lid sensor. |
| 53 | |
| 54 | A normal laptop has what we call a front lid. |
| 55 | |
| 56 | If the laptop can be converted to a tablet by rotating or closing the lid |
| 57 | where the display is out, this is known as a back lid. |
| 58 | |
| 59 | \section2 QLidReading Units |
| 60 | The Lid sensor can detect if a device's lid is closed or not. A lid can be a laptop, |
| 61 | a laptop that converts to a tablet, or even a cover for a tablet or phone. |
| 62 | */ |
| 63 | |
| 64 | /*! |
| 65 | \property QLidReading::backLidClosed |
| 66 | \brief A value indicating whether the back lid is closed. |
| 67 | A back lid can be when a convertable laptop is closed |
| 68 | into to tablet mode without keyboard. |
| 69 | |
| 70 | \sa {QLidReading Units} |
| 71 | */ |
| 72 | |
| 73 | bool QLidReading::backLidClosed() const |
| 74 | { |
| 75 | return d->backLidClosed; |
| 76 | } |
| 77 | |
| 78 | /*! |
| 79 | Sets the backLidClosed value to \a closed. |
| 80 | */ |
| 81 | void QLidReading::setBackLidClosed(bool closed) |
| 82 | { |
| 83 | d->backLidClosed = closed; |
| 84 | } |
| 85 | |
| 86 | /*! |
| 87 | \property QLidReading::frontLidClosed |
| 88 | \brief A value indicating whether the front lid is closed. |
| 89 | A front lid would be a normal laptop lid. |
| 90 | \sa {QLidReading Units} |
| 91 | */ |
| 92 | |
| 93 | bool QLidReading::frontLidClosed() const |
| 94 | { |
| 95 | return d->frontLidClosed; |
| 96 | } |
| 97 | |
| 98 | /*! |
| 99 | Sets the frontLidClosed value to \a closed. |
| 100 | */ |
| 101 | void QLidReading::setFrontLidClosed(bool closed) |
| 102 | { |
| 103 | d->frontLidClosed = closed; |
| 104 | } |
| 105 | |
| 106 | // ===================================================================== |
| 107 | |
| 108 | /*! |
| 109 | \class QLidFilter |
| 110 | \ingroup sensors_filter |
| 111 | \inmodule QtSensors |
| 112 | \since 5.9 |
| 113 | |
| 114 | \brief The QLidFilter class is a convenience wrapper around QSensorFilter. |
| 115 | |
| 116 | The only difference is that the filter() method features a pointer to QLidReading |
| 117 | instead of QSensorReading. |
| 118 | */ |
| 119 | |
| 120 | /*! |
| 121 | \fn QLidFilter::filter(QLidReading *reading) |
| 122 | |
| 123 | Called when \a reading changes. Returns false to prevent the reading from propagating. |
| 124 | |
| 125 | \sa QSensorFilter::filter() |
| 126 | */ |
| 127 | |
| 128 | bool QLidFilter::filter(QSensorReading *reading) |
| 129 | { |
| 130 | return filter(reading: static_cast<QLidReading*>(reading)); |
| 131 | } |
| 132 | |
| 133 | char const * const QLidSensor::type("QLidSensor" ); |
| 134 | |
| 135 | /*! |
| 136 | \class QLidSensor |
| 137 | \ingroup sensors_type |
| 138 | \inmodule QtSensors |
| 139 | \since 5.9 |
| 140 | |
| 141 | \brief The QLidSensor class is a convenience wrapper around QSensor. |
| 142 | |
| 143 | The only behavioural difference is that this class sets the type properly. |
| 144 | |
| 145 | This class also features a reading() function that returns a QLidReading instead |
| 146 | of a QSensorReading. |
| 147 | |
| 148 | For details about how the sensor works, see \l QLidReading. |
| 149 | |
| 150 | \sa QLidReading |
| 151 | */ |
| 152 | |
| 153 | /*! |
| 154 | Construct the sensor as a child of \a parent. |
| 155 | */ |
| 156 | QLidSensor::QLidSensor(QObject *parent) |
| 157 | : QSensor(QLidSensor::type, parent) |
| 158 | { |
| 159 | } |
| 160 | |
| 161 | /*! |
| 162 | Destroy the sensor. Stops the sensor if it has not already been stopped. |
| 163 | */ |
| 164 | QLidSensor::~QLidSensor() |
| 165 | { |
| 166 | } |
| 167 | |
| 168 | /*! |
| 169 | \fn QLidSensor::reading() const |
| 170 | |
| 171 | Returns the reading class for this sensor. |
| 172 | |
| 173 | \sa QSensor::reading() |
| 174 | */ |
| 175 | |
| 176 | QLidReading *QLidSensor::reading() const |
| 177 | { |
| 178 | return static_cast<QLidReading*>(QSensor::reading()); |
| 179 | } |
| 180 | |
| 181 | QT_END_NAMESPACE |
| 182 | |
| 183 | #include "moc_qlidsensor.cpp" |
| 184 | |