diff --git a/containments/panel/CMakeLists.txt b/containments/panel/CMakeLists.txt
index 49cb9c91..13e6417b 100644
--- a/containments/panel/CMakeLists.txt
+++ b/containments/panel/CMakeLists.txt
@@ -1,4 +1,5 @@
-qt5_add_dbus_interfaces(DBUS_SRCS dbus/org.kde.KWin.Screenshot.xml)
+qt5_add_dbus_interfaces(DBUS_SRCS dbus/org.kde.KWin.Screenshot.xml
+ dbus/org.kde.KScreen.xml)
set(phonepanel_SRCS
phonepanel.cpp
diff --git a/containments/panel/dbus/org.kde.KScreen.xml b/containments/panel/dbus/org.kde.KScreen.xml
new file mode 100644
index 00000000..5c6f3a86
--- /dev/null
+++ b/containments/panel/dbus/org.kde.KScreen.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/containments/panel/package/contents/ui/quicksettings/QuickSettings.qml b/containments/panel/package/contents/ui/quicksettings/QuickSettings.qml
index c0fdccf9..1e0d79ae 100644
--- a/containments/panel/package/contents/ui/quicksettings/QuickSettings.qml
+++ b/containments/panel/package/contents/ui/quicksettings/QuickSettings.qml
@@ -60,6 +60,12 @@ Item {
settingsModel.get(2).enabled = !enabledConnections.wwanEnabled
}
+ function toggleRotation() {
+ const enable = !plasmoid.nativeInterface.autoRotateEnabled
+ plasmoid.nativeInterface.autoRotateEnabled = enable
+ settingsModel.get(8).enabled = enable
+ }
+
function requestShutdown() {
print("Shutdown requested, depends on ksmserver running");
var service = pmSource.serviceForSource("PowerDevil");
@@ -199,6 +205,14 @@ Item {
"toggleFunction": "requestScreenshot",
"applet": null
});
+ settingsModel.append({
+ "text": i18n("Auto-rotate"),
+ "icon": "rotation-allowed",
+ "enabled": plasmoid.nativeInterface.autoRotateEnabled,
+ "settingsCommand": "",
+ "toggleFunction": "toggleRotation",
+ "applet": null
+ });
brightnessSlider.moved.connect(function() {
root.screenBrightness = brightnessSlider.value;
diff --git a/containments/panel/phonepanel.cpp b/containments/panel/phonepanel.cpp
index f3cd43dc..7c8843fc 100644
--- a/containments/panel/phonepanel.cpp
+++ b/containments/panel/phonepanel.cpp
@@ -35,6 +35,7 @@ PhonePanel::PhonePanel(QObject *parent, const QVariantList &args)
: Plasma::Containment(parent, args)
{
//setHasConfigurationInterface(true);
+ m_kscreenInterface = new org::kde::KScreen(QStringLiteral("org.kde.kded5"), QStringLiteral("/modules/kscreen"), QDBusConnection::sessionBus(), this);
m_screenshotInterface = new org::kde::kwin::Screenshot(QStringLiteral("org.kde.KWin"), QStringLiteral("/Screenshot"), QDBusConnection::sessionBus(), this);
}
@@ -79,6 +80,29 @@ void PhonePanel::toggleTorch()
}
}
+bool PhonePanel::autoRotate()
+{
+ QDBusPendingReply reply = m_kscreenInterface->getAutoRotate();
+ reply.waitForFinished();
+ if (reply.isError()) {
+ qWarning() << "Getting auto rotate failed:" << reply.error().name() << reply.error().message();
+ return false;
+ } else {
+ return reply.value();
+ }
+}
+
+void PhonePanel::setAutoRotate(bool value)
+{
+ QDBusPendingReply<> reply = m_kscreenInterface->setAutoRotate(value);
+ reply.waitForFinished();
+ if (reply.isError()) {
+ qWarning() << "Setting auto rotate failed:" << reply.error().name() << reply.error().message();
+ } else {
+ emit autoRotateChanged(value);
+ }
+}
+
void PhonePanel::takeScreenshot()
{
// wait ~200 ms to wait for rest of animations
diff --git a/containments/panel/phonepanel.h b/containments/panel/phonepanel.h
index 4e0bc67b..4403fff5 100644
--- a/containments/panel/phonepanel.h
+++ b/containments/panel/phonepanel.h
@@ -26,11 +26,13 @@
#include
+#include "kscreeninterface.h"
#include "screenshotinterface.h"
class PhonePanel : public Plasma::Containment
{
Q_OBJECT
+ Q_PROPERTY(bool autoRotateEnabled READ autoRotate WRITE setAutoRotate NOTIFY autoRotateChanged);
public:
PhonePanel( QObject *parent, const QVariantList &args );
@@ -41,12 +43,19 @@ public Q_SLOTS:
void toggleTorch();
void takeScreenshot();
+ bool autoRotate();
+ void setAutoRotate(bool value);
+
+signals:
+ void autoRotateChanged(bool value);
+
private:
GstElement* m_pipeline;
GstElement* m_sink;
GstElement* m_source;
bool m_running = false;
+ org::kde::KScreen *m_kscreenInterface;
org::kde::kwin::Screenshot *m_screenshotInterface;
};