put ContainmentInterface into its own file
also try and get rid of a few unneeded headers
This commit is contained in:
parent
3b6f014824
commit
0846a611e9
@ -18,6 +18,7 @@ set(declarative_appletscript_SRCS
|
||||
declarative/packageaccessmanagerfactory.cpp
|
||||
declarative/qmlobject.cpp
|
||||
plasmoid/appletinterface.cpp
|
||||
plasmoid/containmentinterface.cpp
|
||||
plasmoid/declarativeappletscript.cpp
|
||||
)
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
/*
|
||||
* Copyright 2008 Chani Armitage <chani@kde.org>
|
||||
* Copyright 2008, 2009 Aaron Seigo <aseigo@kde.org>
|
||||
* Copyright 2010 Marco Martin <mart@kde.org>
|
||||
* Copyright 2008-2013 Aaron Seigo <aseigo@kde.org>
|
||||
* Copyright 2010-2013 Marco Martin <mart@kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
@ -42,6 +41,8 @@
|
||||
#include <Plasma/Corona>
|
||||
#include <Plasma/Package>
|
||||
|
||||
#include "containmentinterface.h"
|
||||
|
||||
Q_DECLARE_METATYPE(AppletInterface*)
|
||||
|
||||
AppletInterface::AppletInterface(DeclarativeAppletScript *script, QQuickItem *parent)
|
||||
@ -475,135 +476,4 @@ void AppletInterface::geometryChanged(const QRectF &newGeometry, const QRectF &o
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
///////////// ContainmentInterface
|
||||
|
||||
ContainmentInterface::ContainmentInterface(DeclarativeAppletScript *parent)
|
||||
: AppletInterface(parent),
|
||||
m_movableApplets(true)
|
||||
{
|
||||
qmlRegisterType<ContainmentInterface>();
|
||||
|
||||
connect(containment(), SIGNAL(appletRemoved(Plasma::Applet *)), this, SLOT(appletRemovedForward(Plasma::Applet *)));
|
||||
connect(containment(), SIGNAL(appletAdded(Plasma::Applet *, const QPointF &)), this, SLOT(appletAddedForward(Plasma::Applet *, const QPointF &)));
|
||||
connect(containment(), SIGNAL(screenChanged(int, int, Plasma::Containment*)), this, SIGNAL(screenChanged()));
|
||||
connect(containment(), SIGNAL(activityChanged()), this, SIGNAL(activityChanged()));
|
||||
connect(containment(), SIGNAL(wallpaperChanged()), this, SLOT(loadWallpaper()));
|
||||
|
||||
if (containment()->corona()) {
|
||||
connect(containment()->corona(), SIGNAL(availableScreenRegionChanged()),
|
||||
this, SIGNAL(availableScreenRegionChanged()));
|
||||
}
|
||||
}
|
||||
|
||||
QVariantList ContainmentInterface::applets()
|
||||
{
|
||||
QVariantList list;
|
||||
int i = 0;
|
||||
foreach (Plasma::Applet *applet, containment()->applets()) {
|
||||
list << QVariant::fromValue(applet);
|
||||
++i;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
void ContainmentInterface::setDrawWallpaper(bool drawWallpaper)
|
||||
{
|
||||
m_appletScriptEngine->setDrawWallpaper(drawWallpaper);
|
||||
}
|
||||
|
||||
bool ContainmentInterface::drawWallpaper()
|
||||
{
|
||||
return m_appletScriptEngine->drawWallpaper();
|
||||
}
|
||||
|
||||
ContainmentInterface::Type ContainmentInterface::containmentType() const
|
||||
{
|
||||
return (ContainmentInterface::Type)m_appletScriptEngine->containmentType();
|
||||
}
|
||||
|
||||
void ContainmentInterface::setContainmentType(ContainmentInterface::Type type)
|
||||
{
|
||||
m_appletScriptEngine->setContainmentType((Plasma::Containment::Type)type);
|
||||
}
|
||||
|
||||
int ContainmentInterface::screen() const
|
||||
{
|
||||
return containment()->screen();
|
||||
}
|
||||
|
||||
QRectF ContainmentInterface::screenGeometry(int id) const
|
||||
{
|
||||
QRectF rect;
|
||||
if (containment()->corona()) {
|
||||
rect = QRectF(containment()->corona()->screenGeometry(id));
|
||||
}
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
QVariantList ContainmentInterface::availableScreenRegion(int id) const
|
||||
{
|
||||
QRegion reg;
|
||||
if (containment()->corona()) {
|
||||
reg = containment()->corona()->availableScreenRegion(id);
|
||||
}
|
||||
|
||||
QVariantList regVal;
|
||||
foreach (QRect rect, reg.rects()) {
|
||||
regVal << QVariant::fromValue(QRectF(rect));
|
||||
}
|
||||
return regVal;
|
||||
}
|
||||
|
||||
void ContainmentInterface::appletAddedForward(Plasma::Applet *applet, const QPointF &pos)
|
||||
{
|
||||
QObject *appletGraphicObject = applet->property("graphicObject").value<QObject *>();
|
||||
QObject *contGraphicObject = containment()->property("graphicObject").value<QObject *>();
|
||||
|
||||
qDebug() << "Applet added:" << applet << applet->title() << appletGraphicObject;
|
||||
|
||||
if (applet && contGraphicObject && appletGraphicObject) {
|
||||
appletGraphicObject->setProperty("visible", false);
|
||||
appletGraphicObject->setProperty("parent", QVariant::fromValue(contGraphicObject));
|
||||
|
||||
//if an appletGraphicObject is not set, we have to display some error message
|
||||
} else if (applet && contGraphicObject) {
|
||||
QQmlComponent *component = new QQmlComponent(m_appletScriptEngine->engine(), applet);
|
||||
component->loadUrl(QUrl::fromLocalFile(containment()->corona()->package().filePath("ui", "AppletError.qml")));
|
||||
QObject *errorUi = component->create();
|
||||
|
||||
if (errorUi) {
|
||||
errorUi->setProperty("visible", false);
|
||||
errorUi->setProperty("parent", QVariant::fromValue(contGraphicObject));
|
||||
errorUi->setProperty("reason", applet->launchErrorMessage());
|
||||
appletGraphicObject = errorUi;
|
||||
}
|
||||
}
|
||||
|
||||
emit appletAdded(appletGraphicObject, pos);
|
||||
}
|
||||
|
||||
void ContainmentInterface::appletRemovedForward(Plasma::Applet *applet)
|
||||
{
|
||||
QObject *appletGraphicObject = applet->property("graphicObject").value<QObject *>();
|
||||
emit appletRemoved(appletGraphicObject);
|
||||
}
|
||||
|
||||
void ContainmentInterface::loadWallpaper()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString ContainmentInterface::activityId() const
|
||||
{
|
||||
return containment()->activity();
|
||||
}
|
||||
|
||||
#include "moc_appletinterface.cpp"
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include <QScriptValue>
|
||||
|
||||
#include <Plasma/Applet>
|
||||
#include <Plasma/Containment>
|
||||
#include <Plasma/Theme>
|
||||
|
||||
#include "declarativeappletscript.h"
|
||||
@ -240,57 +239,4 @@ private:
|
||||
bool m_expanded : 1;
|
||||
};
|
||||
|
||||
|
||||
class ContainmentInterface : public AppletInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QVariantList applets READ applets)
|
||||
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(QString activityId READ activityId NOTIFY activityIdChanged)
|
||||
Q_ENUMS(Type)
|
||||
|
||||
public:
|
||||
enum Type {
|
||||
NoContainmentType = -1, /**< @internal */
|
||||
DesktopContainment = 0, /**< A desktop containment */
|
||||
PanelContainment, /**< A desktop panel */
|
||||
CustomContainment = 127, /**< A containment that is neither a desktop nor a panel
|
||||
but something application specific */
|
||||
CustomPanelContainment = 128 /**< A customized desktop panel */
|
||||
};
|
||||
ContainmentInterface(DeclarativeAppletScript *parent);
|
||||
|
||||
inline Plasma::Containment *containment() const { return static_cast<Plasma::Containment *>(m_appletScriptEngine->applet()); }
|
||||
|
||||
QVariantList applets();
|
||||
|
||||
void setDrawWallpaper(bool drawWallpaper);
|
||||
bool drawWallpaper();
|
||||
Type containmentType() const;
|
||||
void setContainmentType(Type type);
|
||||
int screen() const;
|
||||
|
||||
QString activityId() const;
|
||||
|
||||
Q_INVOKABLE QRectF screenGeometry(int id) const;
|
||||
Q_INVOKABLE QVariantList availableScreenRegion(int id) const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void appletAdded(QObject *applet, const QPointF &pos);
|
||||
void appletRemoved(QObject *applet);
|
||||
void screenChanged();
|
||||
void activityIdChanged();
|
||||
void availableScreenRegionChanged();
|
||||
|
||||
protected Q_SLOTS:
|
||||
void appletAddedForward(Plasma::Applet *applet, const QPointF &pos);
|
||||
void appletRemovedForward(Plasma::Applet *applet);
|
||||
void loadWallpaper();
|
||||
|
||||
private:
|
||||
bool m_movableApplets;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include "plasmoid/declarativeappletscript.h"
|
||||
|
||||
#include "plasmoid/appletinterface.h"
|
||||
#include "plasmoid/containmentinterface.h"
|
||||
|
||||
#include "common/scriptenv.h"
|
||||
#include "declarative/qmlobject.h"
|
||||
|
Loading…
Reference in New Issue
Block a user