From fffcd04aeb149a2a394d487a03c4cb8dc6e8a557 Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Tue, 30 Jan 2024 14:57:11 -0500 Subject: [PATCH] quicksettings/screenrotation: Fix initial state of quicksetting always being off Fixes https://invent.kde.org/plasma/plasma-mobile/-/issues/298 --- quicksettings/screenrotation/screenrotationutil.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/quicksettings/screenrotation/screenrotationutil.cpp b/quicksettings/screenrotation/screenrotationutil.cpp index cc829e20..f9a1d080 100644 --- a/quicksettings/screenrotation/screenrotationutil.cpp +++ b/quicksettings/screenrotation/screenrotationutil.cpp @@ -25,7 +25,6 @@ ScreenRotationUtil::ScreenRotationUtil(QObject *parent) m_config = qobject_cast(op)->config(); // update all screens with event connect - Q_EMIT autoScreenRotationEnabledChanged(); for (KScreen::OutputPtr output : m_config->outputs()) { connect(output.data(), &KScreen::Output::autoRotatePolicyChanged, this, &ScreenRotationUtil::autoScreenRotationEnabledChanged); } @@ -35,6 +34,9 @@ ScreenRotationUtil::ScreenRotationUtil(QObject *parent) Q_EMIT autoScreenRotationEnabledChanged(); connect(output.data(), &KScreen::Output::autoRotatePolicyChanged, this, &ScreenRotationUtil::autoScreenRotationEnabledChanged); }); + + // trigger update + Q_EMIT autoScreenRotationEnabledChanged(); }); } @@ -46,7 +48,7 @@ bool ScreenRotationUtil::autoScreenRotationEnabled() const auto outputs = m_config->outputs(); for (KScreen::OutputPtr output : outputs) { - if (output->autoRotatePolicy() != KScreen::Output::AutoRotatePolicy::Always) { + if (output->autoRotatePolicy() == KScreen::Output::AutoRotatePolicy::Never) { return false; } }