Commit 7e98fd7c authored by Bhushan Shah's avatar Bhushan Shah 📱

feat(kded): add a dbus method to lock current rotation

Summary:
This allows to lock the current rotation or temporary inhibit auto
rotation behavior on mobile

Test Plan: tested on mobile

Reviewers: romangg

Reviewed By: romangg

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D28115
parent d6d02319
......@@ -94,6 +94,19 @@ void Config::setDeviceOrientation(QOrientationReading::Orientation orientation)
}
}
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));
......
......@@ -47,6 +47,7 @@ public:
void activateControlWatching();
bool autoRotationRequested() const;
void setDeviceOrientation(QOrientationReading::Orientation orientation);
void setAutoRotate(bool value);
void log();
void setValidityFlags(KScreen::Config::ValidityFlags flags) {
......
......@@ -246,6 +246,16 @@ void KScreenDaemon::applyLayoutPreset(const QString &presetName)
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) {
......
......@@ -52,6 +52,7 @@ public:
public Q_SLOTS:
// DBus
void applyLayoutPreset(const QString &presetName);
void lockAutoRotate(bool value);
Q_SIGNALS:
// DBus
......
......@@ -5,6 +5,9 @@
<method name="applyLayoutPreset">
<arg type="s" name="presetName" direction="in" />
</method>
<method name="lockAutoRotate">
<arg type="b" name="lock" direction="in" />
</method>
<signal name="outputConnected">
<arg type="s" name="outputName" direction="out" />
</signal>
......@@ -12,4 +15,4 @@
<arg type="s" name="outputName" direction="out" />
</signal>
</interface>
</node>
\ No newline at end of file
</node>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment