export the QRectF as an objecy QtScript understand

This commit is contained in:
Marco Martin 2011-03-02 15:40:47 +01:00
parent 0dda9c72ee
commit 33fe3f4874
2 changed files with 16 additions and 7 deletions

View File

@ -441,6 +441,8 @@ ContainmentInterface::ContainmentInterface(AbstractJsAppletScript *parent)
connect(containment(), SIGNAL(appletRemoved(Plasma::Applet *)), this, SLOT(appletRemovedForward(Plasma::Applet *)));
connect(containment(), SIGNAL(appletAdded(Plasma::Applet *, const QPointF &)), this, SLOT(appletAddedForward(Plasma::Applet *, const QPointF &)));
connect(containment(), SIGNAL(screenChanged(int, int, Plasma::Containment)), this, SLOT(screenChanged()));
}
QScriptValue ContainmentInterface::applets()
@ -476,16 +478,22 @@ void ContainmentInterface::setContainmentType(ContainmentInterface::Type type)
int ContainmentInterface::screen() const
{
return screen();
return containment()->screen();
}
QRect ContainmentInterface::screenGeometry(int id) const
QScriptValue ContainmentInterface::screenGeometry(int id) const
{
QRectF rect;
if (containment()->corona()) {
return containment()->corona()->screenGeometry(id);
} else {
return QRect();
rect = QRectF(containment()->corona()->screenGeometry(id));
}
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());
return val;
}
void ContainmentInterface::appletAddedForward(Plasma::Applet *applet, const QPointF &pos)

View File

@ -361,7 +361,7 @@ class ContainmentInterface : public APPLETSUPERCLASS
Q_PROPERTY(QScriptValue applets READ applets)
Q_PROPERTY(bool drawWallpaper READ drawWallpaper WRITE setDrawWallpaper)
Q_PROPERTY(Type containmentType READ containmentType WRITE setContainmentType)
Q_PROPERTY(int screen READ screen)
Q_PROPERTY(int screen READ screen NOTIFY screenChanged)
Q_ENUMS(Type)
public:
@ -385,11 +385,12 @@ public:
void setContainmentType(Type type);
int screen() const;
Q_INVOKABLE QRect screenGeometry(int id) const;
Q_INVOKABLE QScriptValue screenGeometry(int id) const;
Q_SIGNALS:
void appletAdded(QGraphicsWidget *applet, const QPointF &pos);
void appletRemoved(QGraphicsWidget *applet);
void screenChanged();
protected Q_SLOTS:
void appletAddedForward(Plasma::Applet *applet, const QPointF &pos);