From 8ab91f219de28989833088cbcb257bcfc0eb2c0d Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Thu, 5 Jun 2014 02:12:07 +0200 Subject: [PATCH] Expose the screenGeometry on the applet interface It's useful to be able to figure out information about the current screen without having to ask the corona. --- src/scriptengines/qml/plasmoid/appletinterface.cpp | 5 +++++ src/scriptengines/qml/plasmoid/appletinterface.h | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/src/scriptengines/qml/plasmoid/appletinterface.cpp b/src/scriptengines/qml/plasmoid/appletinterface.cpp index fc075fe9e..af0ebc38e 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.cpp +++ b/src/scriptengines/qml/plasmoid/appletinterface.cpp @@ -460,6 +460,11 @@ int AppletInterface::screen() const return -1; } +QRect AppletInterface::screenGeometry() const +{ + return applet()->containment()->corona()->screenGeometry(applet()->containment()->screen()); +} + void AppletInterface::setHideOnWindowDeactivate(bool hide) { if (m_hideOnDeactivate != hide) { diff --git a/src/scriptengines/qml/plasmoid/appletinterface.h b/src/scriptengines/qml/plasmoid/appletinterface.h index 1092f0bce..fe508256a 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.h +++ b/src/scriptengines/qml/plasmoid/appletinterface.h @@ -150,6 +150,12 @@ class AppletInterface : public PlasmaQuick::AppletQuickItem // would be preferrable if found. Q_PROPERTY(int screen READ screen NOTIFY screenChanged) + /** + * Provides access to the geometry of the applet is in. + * Can be useful to figure out what's the absolute position of the applet. + */ + Q_PROPERTY(QRect screenGeometry READ screenGeometry NOTIFY screenChanged) + /** * Whether the dialog should be hidden when the dialog loses focus. * @@ -273,6 +279,7 @@ public: Plasma::Types::ItemStatus status() const; int screen() const; + QRect screenGeometry() const; bool immutable() const; bool userConfiguring() const;