quicksettings/screenrotation: Ensure that state is up to date when screens are added

This commit is contained in:
Devin Lin 2023-12-17 17:46:40 -08:00
parent 2329e0a15d
commit f2836a81d7

View file

@ -24,7 +24,17 @@ ScreenRotationUtil::ScreenRotationUtil(QObject *parent)
connect(new KScreen::GetConfigOperation(), &KScreen::GetConfigOperation::finished, this, [this](auto *op) {
m_config = qobject_cast<KScreen::GetConfigOperation *>(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);
}
// listen to all new screens and connect
connect(m_config.data(), &KScreen::Config::outputAdded, this, [this](const auto &output) {
Q_EMIT autoScreenRotationEnabledChanged();
connect(output.data(), &KScreen::Output::autoRotatePolicyChanged, this, &ScreenRotationUtil::autoScreenRotationEnabledChanged);
});
});
}