activityName available again

This commit is contained in:
Marco Martin 2013-12-23 17:00:15 +01:00
parent 3b24340cc8
commit 21fde267fb
3 changed files with 37 additions and 1 deletions

View File

@ -22,6 +22,7 @@ target_link_libraries(plasma_appletscript_declarative
Qt5::Qml
Qt5::Script
Qt5::UiTools
KF5::KActivities
KF5::KIOCore
KF5::KIOWidgets
KF5::Declarative

View File

@ -47,11 +47,14 @@
#include <Plasma/Package>
#include <Plasma/PluginLoader>
#include <kactivities/info.h>
#include "kdeclarative/configpropertymap.h"
ContainmentInterface::ContainmentInterface(DeclarativeAppletScript *parent)
: AppletInterface(parent),
m_wallpaperInterface(0)
m_wallpaperInterface(0),
m_activityInfo(0)
{
setAcceptedMouseButtons(Qt::AllButtons);
@ -63,6 +66,14 @@ ContainmentInterface::ContainmentInterface(DeclarativeAppletScript *parent)
this, &ContainmentInterface::appletAddedForward);
connect(containment(), &Plasma::Containment::activityChanged,
this, &ContainmentInterface::activityChanged);
connect(containment(), &Plasma::Containment::activityChanged,
[=]() {
delete m_activityInfo;
m_activityInfo = new KActivities::Info(containment()->activity(), this);
connect(m_activityInfo, &KActivities::Info::nameChanged,
this, &ContainmentInterface::activityNameChanged);
emit activityNameChanged();
});
connect(containment(), &Plasma::Containment::wallpaperChanged,
this, &ContainmentInterface::loadWallpaper);
connect(containment(), &Plasma::Containment::drawWallpaperChanged,
@ -82,6 +93,10 @@ ContainmentInterface::ContainmentInterface(DeclarativeAppletScript *parent)
void ContainmentInterface::init()
{
m_activityInfo = new KActivities::Info(containment()->activity(), this);
connect(m_activityInfo, &KActivities::Info::nameChanged,
this, &ContainmentInterface::activityNameChanged);
emit activityNameChanged();
AppletInterface::init();
@ -543,6 +558,14 @@ QString ContainmentInterface::activity() const
return containment()->activity();
}
QString ContainmentInterface::activityName() const
{
if (!m_activityInfo) {
return QString();
}
return m_activityInfo->name();
}
QList<QObject*> ContainmentInterface::actions() const
{
//FIXME: giving directly a QList<QAction*> crashes

View File

@ -34,6 +34,10 @@ namespace KIO {
class Job;
}
namespace KActivities {
class Info;
}
class ContainmentInterface : public AppletInterface
{
Q_OBJECT
@ -58,6 +62,11 @@ class ContainmentInterface : public AppletInterface
*/
Q_PROPERTY(QString activity READ activity NOTIFY activityChanged)
/**
* Activity name of this containment
*/
Q_PROPERTY(QString activityName READ activityName NOTIFY activityNameChanged)
/**
* Actions associated to this containment or corona
*/
@ -79,6 +88,7 @@ public:
void setContainmentType(Plasma::Types::ContainmentType type);
QString activity() const;
QString activityName() const;
QList<QObject*> actions() const;
@ -129,6 +139,7 @@ Q_SIGNALS:
//Property notifiers
void activityChanged();
void activityNameChanged();
void availableScreenRegionChanged();
void appletsChanged();
void drawWallpaperChanged();
@ -152,6 +163,7 @@ private:
QList<QObject *> m_appletInterfaces;
QHash<KJob*, QPoint> m_dropPoints;
QHash<KJob*, QMenu*> m_dropMenus;
KActivities::Info *m_activityInfo;
};
#endif