shift-shell/quicksettings/screenrotation/screenrotationutil.h
Devin Lin 1ac2745bfb quicksettings/screenrotation: Don't call rotate in signal handler
This is a workaround for https://invent.kde.org/plasma/plasma-mobile/-/issues/405, where if the caller gets deleted by the screen rotation, the entire shell crashes.

Eventually, we need to implement
https://invent.kde.org/plasma/plasma-mobile/-/issues/406 to reduce the
amount of oddities we have from recreating the quick settings panel
during screen rotation.
2024-10-03 22:41:29 -07:00

36 lines
910 B
C++

// SPDX-FileCopyrightText: 2022-2023 Devin Lin <devin@kde.org>
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <QObject>
#include <QOrientationSensor>
#include <kscreen/config.h>
class ScreenRotationUtil : public QObject
{
Q_OBJECT
Q_PROPERTY(bool autoScreenRotationEnabled READ autoScreenRotationEnabled WRITE setAutoScreenRotationEnabled NOTIFY autoScreenRotationEnabledChanged);
Q_PROPERTY(bool available READ isAvailable NOTIFY availableChanged);
public:
ScreenRotationUtil(QObject *parent = nullptr);
bool autoScreenRotationEnabled();
void setAutoScreenRotationEnabled(bool value);
bool isAvailable();
Q_SIGNALS:
void autoScreenRotationEnabledChanged();
void availableChanged();
private:
void actuallySetAutoScreenRotationEnabled(bool value);
KScreen::ConfigPtr m_config;
QOrientationSensor *m_sensor;
bool m_available;
};