quicksettings/screenrotation: Fix initial state of quicksetting always being off

Fixes https://invent.kde.org/plasma/plasma-mobile/-/issues/298
This commit is contained in:
Devin Lin 2024-01-30 14:57:11 -05:00
parent 6f67fdd0c5
commit fffcd04aeb

View file

@ -25,7 +25,6 @@ ScreenRotationUtil::ScreenRotationUtil(QObject *parent)
m_config = qobject_cast<KScreen::GetConfigOperation *>(op)->config(); m_config = qobject_cast<KScreen::GetConfigOperation *>(op)->config();
// update all screens with event connect // update all screens with event connect
Q_EMIT autoScreenRotationEnabledChanged();
for (KScreen::OutputPtr output : m_config->outputs()) { for (KScreen::OutputPtr output : m_config->outputs()) {
connect(output.data(), &KScreen::Output::autoRotatePolicyChanged, this, &ScreenRotationUtil::autoScreenRotationEnabledChanged); connect(output.data(), &KScreen::Output::autoRotatePolicyChanged, this, &ScreenRotationUtil::autoScreenRotationEnabledChanged);
} }
@ -35,6 +34,9 @@ ScreenRotationUtil::ScreenRotationUtil(QObject *parent)
Q_EMIT autoScreenRotationEnabledChanged(); Q_EMIT autoScreenRotationEnabledChanged();
connect(output.data(), &KScreen::Output::autoRotatePolicyChanged, this, &ScreenRotationUtil::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(); const auto outputs = m_config->outputs();
for (KScreen::OutputPtr output : outputs) { for (KScreen::OutputPtr output : outputs) {
if (output->autoRotatePolicy() != KScreen::Output::AutoRotatePolicy::Always) { if (output->autoRotatePolicy() == KScreen::Output::AutoRotatePolicy::Never) {
return false; return false;
} }
} }