diff --git a/components/rotationplugin/rotationutil.cpp b/components/rotationplugin/rotationutil.cpp index 51d9ccb6..c1ba46ee 100644 --- a/components/rotationplugin/rotationutil.cpp +++ b/components/rotationplugin/rotationutil.cpp @@ -51,11 +51,14 @@ RotationUtil::Rotation mapRotation(KScreen::Output::Rotation rotation) } RotationUtil::RotationUtil(QObject *parent) -: QObject{parent} -, m_sensor{new QOrientationSensor(this)} + : QObject{parent} + , m_sensor{new QOrientationSensor(this)} { connect(new KScreen::GetConfigOperation(), &KScreen::GetConfigOperation::finished, this, [this](auto *op) { m_config = qobject_cast(op)->config(); + if (!m_config) { + return; + } KScreen::ConfigMonitor::instance()->addConfig(m_config); // update all screens with event connect @@ -95,9 +98,9 @@ void RotationUtil::rotateToSuggestedRotation() } auto setop = new KScreen::SetConfigOperation(m_config, this); - setop->exec(); - - updateShowRotationButton(); + connect(setop, &KScreen::SetConfigOperation::finished, this, [this]() { + updateShowRotationButton(); + }); } bool RotationUtil::showRotationButton() const @@ -155,4 +158,4 @@ void RotationUtil::updateShowRotationButton() m_showRotationButton = false; Q_EMIT rotationChanged(); -} \ No newline at end of file +} diff --git a/quicksettings/screenrotation/screenrotationutil.cpp b/quicksettings/screenrotation/screenrotationutil.cpp index 3c5c8f3b..4e5ae0e2 100644 --- a/quicksettings/screenrotation/screenrotationutil.cpp +++ b/quicksettings/screenrotation/screenrotationutil.cpp @@ -101,7 +101,7 @@ void ScreenRotationUtil::actuallySetAutoScreenRotationEnabled(bool value) } auto setop = new KScreen::SetConfigOperation(m_config, this); - setop->exec(); - - Q_EMIT autoScreenRotationEnabledChanged(); + connect(setop, &KScreen::SetConfigOperation::finished, this, [this]() { + Q_EMIT autoScreenRotationEnabledChanged(); + }); }