File indexing completed on 2024-04-28 05:27:37

0001 /*
0002     SPDX-FileCopyrightText: 2019 Roman Gilg <subdiff@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 #pragma once
0007 
0008 #include <QObject>
0009 #include <QOrientationReading>
0010 
0011 class OrientationSensor final : public QObject
0012 {
0013     Q_OBJECT
0014 public:
0015     explicit OrientationSensor(QObject *parent = nullptr);
0016     ~OrientationSensor() override final;
0017 
0018     QOrientationReading::Orientation value() const;
0019     bool available() const;
0020     bool enabled() const;
0021 
0022     void setEnabled(bool enable);
0023 
0024 Q_SIGNALS:
0025     void valueChanged(QOrientationReading::Orientation orientation);
0026     void availableChanged(bool available);
0027     void enabledChanged(bool enabled);
0028 
0029 private:
0030     void refresh();
0031     void updateState();
0032 
0033     QOrientationSensor *m_sensor;
0034     QOrientationReading::Orientation m_value = QOrientationReading::Undefined;
0035     bool m_enabled = false;
0036 };