diff --git a/scriptengines/javascript/plasmoid/appletinterface.cpp b/scriptengines/javascript/plasmoid/appletinterface.cpp index 4a1471421..e062789d0 100644 --- a/scriptengines/javascript/plasmoid/appletinterface.cpp +++ b/scriptengines/javascript/plasmoid/appletinterface.cpp @@ -436,7 +436,8 @@ QGraphicsWidget *PopupAppletInterface::popupWidget() } ContainmentInterface::ContainmentInterface(AbstractJsAppletScript *parent) - : APPLETSUPERCLASS(parent) + : APPLETSUPERCLASS(parent), + m_movableApplets(true) { connect(containment(), SIGNAL(appletRemoved(Plasma::Applet *)), this, SLOT(appletRemovedForward(Plasma::Applet *))); @@ -498,14 +499,34 @@ QScriptValue ContainmentInterface::screenGeometry(int id) const void ContainmentInterface::appletAddedForward(Plasma::Applet *applet, const QPointF &pos) { + applet->setFlag(QGraphicsItem::ItemIsMovable, m_movableApplets); emit appletAdded(applet, pos); } void ContainmentInterface::appletRemovedForward(Plasma::Applet *applet) { + applet->setFlag(QGraphicsItem::ItemIsMovable, true); emit appletRemoved(applet); } +void ContainmentInterface::setMovableApplets(bool movable) +{ + if (m_movableApplets == movable) { + return; + } + + m_movableApplets = movable; + + foreach (Plasma::Applet *applet, containment()->applets()) { + applet->setFlag(QGraphicsItem::ItemIsMovable, movable); + } +} + +bool ContainmentInterface::hasMovableApplets() const +{ + return m_movableApplets; +} + #ifndef USE_JS_SCRIPTENGINE #include "appletinterface.moc" #endif diff --git a/scriptengines/javascript/plasmoid/appletinterface.h b/scriptengines/javascript/plasmoid/appletinterface.h index 096888617..edfcbc80a 100644 --- a/scriptengines/javascript/plasmoid/appletinterface.h +++ b/scriptengines/javascript/plasmoid/appletinterface.h @@ -362,6 +362,7 @@ class ContainmentInterface : public APPLETSUPERCLASS Q_PROPERTY(bool drawWallpaper READ drawWallpaper WRITE setDrawWallpaper) Q_PROPERTY(Type containmentType READ containmentType WRITE setContainmentType) Q_PROPERTY(int screen READ screen NOTIFY screenChanged) + Q_PROPERTY(bool movableApplets READ hasMovableApplets WRITE setMovableApplets) Q_ENUMS(Type) public: @@ -385,6 +386,9 @@ public: void setContainmentType(Type type); int screen() const; + void setMovableApplets(bool movable); + bool hasMovableApplets() const; + Q_INVOKABLE QScriptValue screenGeometry(int id) const; Q_SIGNALS: @@ -395,6 +399,9 @@ Q_SIGNALS: protected Q_SLOTS: void appletAddedForward(Plasma::Applet *applet, const QPointF &pos); void appletRemovedForward(Plasma::Applet *applet); + +private: + bool m_movableApplets; }; #endif