support availableScreenregion()

FEATURE: bridge to Corona::availableScreenRegion(), as an array of rects
This commit is contained in:
Marco Martin 2011-03-13 17:26:08 +01:00
parent f07062fae5
commit fcd51b4c67
2 changed files with 21 additions and 0 deletions

View File

@ -497,6 +497,26 @@ QScriptValue ContainmentInterface::screenGeometry(int id) const
return val;
}
QScriptValue ContainmentInterface::availableScreenRegion(int id) const
{
QRegion reg;
if (containment()->corona()) {
reg = containment()->corona()->availableScreenRegion(id);
}
QScriptValue regVal = m_appletScriptEngine->engine()->newArray(reg.rects().size());
int i = 0;
foreach (QRect rect, reg.rects()) {
QScriptValue val = m_appletScriptEngine->engine()->newObject();
val.setProperty("x", rect.x());
val.setProperty("y", rect.y());
val.setProperty("width", rect.width());
val.setProperty("height", rect.height());
regVal.setProperty(i++, val);
}
return regVal;
}
void ContainmentInterface::appletAddedForward(Plasma::Applet *applet, const QPointF &pos)
{
applet->setFlag(QGraphicsItem::ItemIsMovable, m_movableApplets);

View File

@ -390,6 +390,7 @@ public:
bool hasMovableApplets() const;
Q_INVOKABLE QScriptValue screenGeometry(int id) const;
Q_INVOKABLE QScriptValue availableScreenRegion(int id) const;
Q_SIGNALS:
void appletAdded(QGraphicsWidget *applet, const QPointF &pos);