quicksettings/autorotate: Properly listen to external changes

This ensures that external changes to screen rotation are listened to
and updated in the quicksetting.

TODO: haven't actually tested on device yet
This commit is contained in:
Devin Lin 2024-11-07 23:56:35 -08:00
parent 57a35ddd0c
commit 5decdbe2b5
2 changed files with 8 additions and 3 deletions

View file

@ -22,8 +22,13 @@ ScreenRotationUtil::ScreenRotationUtil(QObject *parent)
{
connect(m_sensor, &QOrientationSensor::activeChanged, this, &ScreenRotationUtil::availableChanged);
connect(KScreen::ConfigMonitor::instance(), &KScreen::ConfigMonitor::configurationChanged, this, [this]() {
Q_EMIT autoScreenRotationEnabledChanged();
});
connect(new KScreen::GetConfigOperation(), &KScreen::GetConfigOperation::finished, this, [this](auto *op) {
m_config = qobject_cast<KScreen::GetConfigOperation *>(op)->config();
KScreen::ConfigMonitor::instance()->addConfig(m_config);
// update all screens with event connect
for (KScreen::OutputPtr output : m_config->outputs()) {

View file

@ -29,8 +29,8 @@ Q_SIGNALS:
private:
void actuallySetAutoScreenRotationEnabled(bool value);
KScreen::ConfigPtr m_config;
QOrientationSensor *m_sensor;
KScreen::ConfigPtr m_config{nullptr};
QOrientationSensor *m_sensor{nullptr};
bool m_available;
bool m_available{false};
};