File indexing completed on 2024-05-12 05:36:20

0001 // SPDX-FileCopyrightText: 2022-2023 Devin Lin <devin@kde.org>
0002 // SPDX-License-Identifier: GPL-2.0-or-later
0003 
0004 #pragma once
0005 
0006 #include <QObject>
0007 #include <QOrientationSensor>
0008 
0009 #include <kscreen/config.h>
0010 
0011 class ScreenRotationUtil : public QObject
0012 {
0013     Q_OBJECT
0014     Q_PROPERTY(bool autoScreenRotationEnabled READ autoScreenRotationEnabled WRITE setAutoScreenRotationEnabled NOTIFY autoScreenRotationEnabledChanged);
0015     Q_PROPERTY(bool available READ isAvailable NOTIFY availableChanged);
0016 
0017 public:
0018     ScreenRotationUtil(QObject *parent = nullptr);
0019 
0020     bool autoScreenRotationEnabled();
0021     void setAutoScreenRotationEnabled(bool value);
0022 
0023     bool isAvailable();
0024 
0025 Q_SIGNALS:
0026     void autoScreenRotationEnabledChanged();
0027     void availableChanged();
0028 
0029 private:
0030     KScreen::ConfigPtr m_config;
0031     QOrientationSensor *m_sensor;
0032 
0033     bool m_available;
0034 };