diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.cpp b/src/scriptengines/qml/plasmoid/containmentinterface.cpp index e33a5041a..bc06aae51 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.cpp +++ b/src/scriptengines/qml/plasmoid/containmentinterface.cpp @@ -174,35 +174,32 @@ void ContainmentInterface::lockWidgets(bool locked) emit immutableChanged(); } -QRectF ContainmentInterface::screenGeometry(int id) const +QVariantList ContainmentInterface::availableScreenRegion() const { - QRectF rect; - if (containment()->corona()) { - rect = QRectF(containment()->corona()->screenGeometry(id)); - } - - return rect; -} - -QVariantList ContainmentInterface::availableScreenRegion(int id) const -{ - QRegion reg; - if (containment()->corona()) { - reg = containment()->corona()->availableScreenRegion(id); + QRegion reg = QRect(0, 0, width(), height()); + if (containment()->screen() > -1 && containment()->corona()) { + reg = containment()->corona()->availableScreenRegion(containment()->screen()); } QVariantList regVal; foreach (QRect rect, reg.rects()) { + //make it relative + rect.setX(rect.x() - containment()->corona()->screenGeometry(containment()->screen()).x()); + rect.setY(rect.y() - containment()->corona()->screenGeometry(containment()->screen()).y()); regVal << QVariant::fromValue(QRectF(rect)); } return regVal; } -QRect ContainmentInterface::availableScreenRect(int id) const +QRect ContainmentInterface::availableScreenRect() const { - QRect rect; - if (containment()->corona()) { - rect = containment()->corona()->availableScreenRect(id); + QRect rect(0, 0, width(), height()); + + if (containment()->screen() > -1 && containment()->corona()) { + rect = containment()->corona()->availableScreenRect(containment()->screen()); + //make it relative + rect.setX(rect.x() - containment()->corona()->screenGeometry(containment()->screen()).x()); + rect.setY(rect.y() - containment()->corona()->screenGeometry(containment()->screen()).y()); } return rect; diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.h b/src/scriptengines/qml/plasmoid/containmentinterface.h index d8f818f18..ca899ce82 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.h +++ b/src/scriptengines/qml/plasmoid/containmentinterface.h @@ -69,6 +69,18 @@ class ContainmentInterface : public AppletInterface */ Q_PROPERTY(QList actions READ actions NOTIFY actionsChanged) + /** + * screen area free of panels: the coordinates are relative to the containment, + * it's independent from the screen position + * For more precise available geometry use availableScreenRegion() + */ + Q_PROPERTY(QRect availableScreenRect READ availableScreenRect NOTIFY availableScreenRectChanged) + + /** + * The available region of this screen, panels excluded. It's a list of rectangles + */ + Q_PROPERTY(QVariantList availableScreenRegion READ availableScreenRegion NOTIFY availableScreenRegionChanged) + public: ContainmentInterface(DeclarativeAppletScript *parent, const QVariantList &args = QVariantList()); @@ -99,21 +111,9 @@ public: */ Q_INVOKABLE void lockWidgets(bool locked); - /** - * Geometry of this screen - */ - Q_INVOKABLE QRectF screenGeometry(int id) const; + QVariantList availableScreenRegion() const; - /** - * The available region of this screen, panels excluded. It's a list of rectangles - */ - Q_INVOKABLE QVariantList availableScreenRegion(int id) const; - - /** - * The available rect of this screen, panels excluded. A simple rect area - * For more precise available geometry use availableScreenRegion() - */ - Q_INVOKABLE QRect availableScreenRect(int id) const; + QRect availableScreenRect() const; /** * Process the mime data arrived to a particular coordinate, either with a drag and drop or paste with middle mouse button