expose containmentInterface::actions

the toolbox will use it
This commit is contained in:
Marco Martin 2013-09-16 17:08:48 +02:00
parent 2817591bee
commit 70cef22211
2 changed files with 26 additions and 0 deletions

View File

@ -555,6 +555,24 @@ QString ContainmentInterface::activity() const
return containment()->activity();
}
QList<QObject*> ContainmentInterface::actions() const
{
//FIXME: giving directly a QList<QAction*> crashes
//use a multimap to sort by action type
QMultiMap<int, QObject*> actions;
foreach (QAction *a, containment()->actions()->actions()) {
if (a->isEnabled()) {
actions.insert(a->data().toInt(), a);
}
}
foreach (QAction *a, containment()->corona()->actions()->actions()) {
if (a->isEnabled()) {
actions.insert(a->data().toInt(), a);
}
}
return actions.values();
}

View File

@ -58,6 +58,11 @@ class ContainmentInterface : public AppletInterface
*/
Q_PROPERTY(QString activity READ activity NOTIFY activityChanged)
/**
* Actions associated to this containment or corona
*/
Q_PROPERTY(QList<QObject*> actions READ actions NOTIFY actionsChanged)
public:
ContainmentInterface(DeclarativeAppletScript *parent);
//Not for QML
@ -75,6 +80,8 @@ public:
QString activity() const;
QList<QObject*> actions() const;
/**
* FIXME: either a property or not accessible at all. Lock or unlock widgets
*/
@ -127,6 +134,7 @@ Q_SIGNALS:
void drawWallpaperChanged();
void containmentTypeChanged();
///void immutableChanged();
void actionsChanged();
protected Q_SLOTS:
void appletAddedForward(Plasma::Applet *applet);