Index: src/scriptengines/qml/plasmoid/appletinterface.h =================================================================== --- src/scriptengines/qml/plasmoid/appletinterface.h +++ src/scriptengines/qml/plasmoid/appletinterface.h @@ -227,6 +227,18 @@ */ Q_PROPERTY(QString configurationRequiredReason READ configurationRequiredReason WRITE setConfigurationRequiredReason NOTIFY configurationRequiredReasonChanged) + /** + * 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: AppletInterface(DeclarativeAppletScript *script, const QVariantList &args = QVariantList(), QQuickItem *parent = 0); ~AppletInterface(); @@ -301,6 +313,10 @@ */ Q_INVOKABLE QStringList downloadedFiles() const; + QVariantList availableScreenRegion() const; + + QRect availableScreenRect() const; + static AppletInterface *qmlAttachedProperties(QObject *object) { return qobject_cast(AppletQuickItem::qmlAttachedProperties(object)); @@ -416,6 +432,8 @@ void hideOnWindowDeactivateChanged(); void associatedApplicationChanged(); void associatedApplicationUrlsChanged(); + void availableScreenRegionChanged(); + void availableScreenRectChanged(); void userConfiguringChanged(); void globalShortcutChanged(); Index: src/scriptengines/qml/plasmoid/appletinterface.cpp =================================================================== --- src/scriptengines/qml/plasmoid/appletinterface.cpp +++ src/scriptengines/qml/plasmoid/appletinterface.cpp @@ -656,6 +656,49 @@ } } +QVariantList AppletInterface::availableScreenRegion() const +{ + QVariantList regVal; + + if (!applet()->containment()) { + return regVal; + } + + QRegion reg = QRect(0, 0, width(), height()); + int screenId = screen(); + if (screenId > -1 && applet()->containment()->corona()) { + reg = applet()->containment()->corona()->availableScreenRegion(screenId); + } + + foreach (QRect rect, reg.rects()) { + //make it relative + QRect geometry = applet()->containment()->corona()->screenGeometry(screenId); + rect.moveTo(rect.topLeft() - geometry.topLeft()); + regVal << QVariant::fromValue(QRectF(rect)); + } + return regVal; +} + +QRect AppletInterface::availableScreenRect() const +{ + if (!applet()->containment()) { + return QRect(); + } + + QRect rect(0, 0, width(), height()); + + int screenId = screen(); + + if (screenId > -1 && applet()->containment()->corona()) { + rect = applet()->containment()->corona()->availableScreenRect(screenId); + //make it relative + QRect geometry = applet()->containment()->corona()->screenGeometry(screenId); + rect.moveTo(rect.topLeft() - geometry.topLeft()); + } + + return rect; +} + bool AppletInterface::event(QEvent *event) { // QAction keyboard shortcuts cannot work with QML2 (and probably newver will Index: src/scriptengines/qml/plasmoid/containmentinterface.h =================================================================== --- src/scriptengines/qml/plasmoid/containmentinterface.h +++ src/scriptengines/qml/plasmoid/containmentinterface.h @@ -76,18 +76,6 @@ */ 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()); @@ -113,10 +101,6 @@ QList actions() const; - QVariantList availableScreenRegion() 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 */ @@ -189,8 +173,6 @@ //Property notifiers void activityChanged(); void activityNameChanged(); - void availableScreenRegionChanged(); - void availableScreenRectChanged(); void appletsChanged(); void drawWallpaperChanged(); void containmentTypeChanged(); Index: src/scriptengines/qml/plasmoid/containmentinterface.cpp =================================================================== --- src/scriptengines/qml/plasmoid/containmentinterface.cpp +++ src/scriptengines/qml/plasmoid/containmentinterface.cpp @@ -190,40 +190,6 @@ appletScript()->setContainmentType(type); } -QVariantList ContainmentInterface::availableScreenRegion() const -{ - QRegion reg = QRect(0, 0, width(), height()); - int screenId = screen(); - if (screenId > -1 && m_containment->corona()) { - reg = m_containment->corona()->availableScreenRegion(screenId); - } - - QVariantList regVal; - foreach (QRect rect, reg.rects()) { - //make it relative - QRect geometry = m_containment->corona()->screenGeometry(screenId); - rect.moveTo(rect.topLeft() - geometry.topLeft()); - regVal << QVariant::fromValue(QRectF(rect)); - } - return regVal; -} - -QRect ContainmentInterface::availableScreenRect() const -{ - QRect rect(0, 0, width(), height()); - - int screenId = screen(); - - if (screenId > -1 && m_containment->corona()) { - rect = m_containment->corona()->availableScreenRect(screenId); - //make it relative - QRect geometry = m_containment->corona()->screenGeometry(screenId); - rect.moveTo(rect.topLeft() - geometry.topLeft()); - } - - return rect; -} - Plasma::Applet *ContainmentInterface::createApplet(const QString &plugin, const QVariantList &args, const QPoint &pos) { return createApplet(plugin, args, QRectF(pos, QSize()));