diff --git a/kded/config.h b/kded/config.h --- a/kded/config.h +++ b/kded/config.h @@ -47,6 +47,7 @@ void activateControlWatching(); bool autoRotationRequested() const; void setDeviceOrientation(QOrientationReading::Orientation orientation); + void setAutoRotate(bool value); void log(); void setValidityFlags(KScreen::Config::ValidityFlags flags) { diff --git a/kded/config.cpp b/kded/config.cpp --- a/kded/config.cpp +++ b/kded/config.cpp @@ -94,6 +94,19 @@ } } +void Config::setAutoRotate(bool value) +{ + for (KScreen::OutputPtr &output : m_data->outputs()) { + if (output->type() != KScreen::Output::Type::Panel) { + continue; + } + if (m_control->getAutoRotate(output) != value) { + m_control->setAutoRotate(output, value); + } + } + m_control->writeFile(); +} + bool Config::fileExists() const { return (QFile::exists(configsDirPath() % id()) || QFile::exists(configsDirPath() % s_fixedConfigFileName)); diff --git a/kded/daemon.h b/kded/daemon.h --- a/kded/daemon.h +++ b/kded/daemon.h @@ -52,6 +52,7 @@ public Q_SLOTS: // DBus void applyLayoutPreset(const QString &presetName); + void lockAutoRotate(bool value); Q_SIGNALS: // DBus diff --git a/kded/daemon.cpp b/kded/daemon.cpp --- a/kded/daemon.cpp +++ b/kded/daemon.cpp @@ -246,6 +246,16 @@ applyOsdAction(action); } +void KScreenDaemon::lockAutoRotate(bool value) +{ + if (!m_monitoredConfig) { + return; + } + m_monitoredConfig->setAutoRotate(value); + m_orientationSensor->setEnabled(value); +} + + void KScreenDaemon::applyOsdAction(KScreen::OsdAction::Action action) { switch (action) { diff --git a/kded/org.kde.KScreen.xml b/kded/org.kde.KScreen.xml --- a/kded/org.kde.KScreen.xml +++ b/kded/org.kde.KScreen.xml @@ -5,11 +5,14 @@ + + + - \ No newline at end of file +