movableApplets property of Containment
just for scripted contaiments, C++ ones can easily implement it themselves
This commit is contained in:
parent
33fe3f4874
commit
f07062fae5
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user