FEATURE: expose the activity name and id

expose activity name and activityid in the containment wrapper interface
This commit is contained in:
Marco Martin 2011-04-04 15:14:19 +02:00
parent da186219ae
commit 2754c01add
2 changed files with 21 additions and 1 deletions

View File

@ -453,6 +453,9 @@ ContainmentInterface::ContainmentInterface(AbstractJsAppletScript *parent)
connect(containment(), SIGNAL(appletAdded(Plasma::Applet *, const QPointF &)), this, SLOT(appletAddedForward(Plasma::Applet *, const QPointF &))); 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())); connect(containment(), SIGNAL(screenChanged(int, int, Plasma::Containment)), this, SLOT(screenChanged()));
connect(containment()->context(), SIGNAL(activityChanged(Plasma::Context *)), this, SIGNAL(activityNameChanged()));
connect(containment()->context(), SIGNAL(changed(Plasma::Context *)), this, SIGNAL(activityIdChanged()));
} }
QScriptValue ContainmentInterface::applets() QScriptValue ContainmentInterface::applets()
@ -556,6 +559,16 @@ bool ContainmentInterface::hasMovableApplets() const
return m_movableApplets; return m_movableApplets;
} }
QString ContainmentInterface::activityName() const
{
return containment()->context()->currentActivity();
}
QString ContainmentInterface::activityId() const
{
return containment()->context()->currentActivityId();
}
#ifndef USE_JS_SCRIPTENGINE #ifndef USE_JS_SCRIPTENGINE
#include "appletinterface.moc" #include "appletinterface.moc"
#endif #endif

View File

@ -367,6 +367,8 @@ class ContainmentInterface : public APPLETSUPERCLASS
Q_PROPERTY(Type containmentType READ containmentType WRITE setContainmentType) Q_PROPERTY(Type containmentType READ containmentType WRITE setContainmentType)
Q_PROPERTY(int screen READ screen NOTIFY screenChanged) Q_PROPERTY(int screen READ screen NOTIFY screenChanged)
Q_PROPERTY(bool movableApplets READ hasMovableApplets WRITE setMovableApplets) Q_PROPERTY(bool movableApplets READ hasMovableApplets WRITE setMovableApplets)
Q_PROPERTY(QString activityName READ activityName NOTIFY activityNameChanged)
Q_PROPERTY(QString activityId READ activityId NOTIFY activityIdChanged)
Q_ENUMS(Type) Q_ENUMS(Type)
public: public:
@ -393,6 +395,9 @@ public:
void setMovableApplets(bool movable); void setMovableApplets(bool movable);
bool hasMovableApplets() const; bool hasMovableApplets() const;
QString activityName() const;
QString activityId() const;
Q_INVOKABLE QScriptValue screenGeometry(int id) const; Q_INVOKABLE QScriptValue screenGeometry(int id) const;
Q_INVOKABLE QScriptValue availableScreenRegion(int id) const; Q_INVOKABLE QScriptValue availableScreenRegion(int id) const;
@ -400,6 +405,8 @@ Q_SIGNALS:
void appletAdded(QGraphicsWidget *applet, const QPointF &pos); void appletAdded(QGraphicsWidget *applet, const QPointF &pos);
void appletRemoved(QGraphicsWidget *applet); void appletRemoved(QGraphicsWidget *applet);
void screenChanged(); void screenChanged();
void activityNameChanged();
void activityIdChanged();
protected Q_SLOTS: protected Q_SLOTS:
void appletAddedForward(Plasma::Applet *applet, const QPointF &pos); void appletAddedForward(Plasma::Applet *applet, const QPointF &pos);