2010-10-14 20:34:46 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2009 by Alan Alpert <alan.alpert@nokia.com>
|
|
|
|
* Copyright 2010 by Ménard Alexis <menard@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
|
|
|
|
* published by the Free Software Foundation; either version 2, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DECLARATIVE_APPLETSCRIPT_H
|
|
|
|
#define DECLARATIVE_APPLETSCRIPT_H
|
|
|
|
|
|
|
|
#include <QScriptValue>
|
|
|
|
#include <QScriptContext>
|
|
|
|
|
|
|
|
#include "abstractjsappletscript.h"
|
2010-10-21 22:37:47 +02:00
|
|
|
#include "plasmoid/appletauthorization.h"
|
2010-10-14 20:34:46 +02:00
|
|
|
#include <Plasma/DataEngine>
|
|
|
|
|
|
|
|
class AppletInterface;
|
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
class DeclarativeWidget;
|
|
|
|
class ExtenderItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
class ScriptEnv;
|
|
|
|
class EngineAccess;
|
|
|
|
|
|
|
|
class DeclarativeAppletScript : public AbstractJsAppletScript
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
DeclarativeAppletScript(QObject *parent, const QVariantList &args);
|
|
|
|
~DeclarativeAppletScript();
|
|
|
|
|
|
|
|
QString filePath(const QString &type, const QString &file) const;
|
|
|
|
|
2011-06-09 14:31:03 +02:00
|
|
|
QList<QAction*> contextualActions();
|
2010-10-14 20:34:46 +02:00
|
|
|
|
|
|
|
void constraintsEvent(Plasma::Constraints constraints);
|
|
|
|
|
|
|
|
bool include(const QString &path);
|
|
|
|
|
|
|
|
ScriptEnv *scriptEnv();
|
|
|
|
|
2011-02-20 19:45:12 +01:00
|
|
|
QScriptEngine *engine() const;
|
|
|
|
|
2010-10-14 20:34:46 +02:00
|
|
|
QScriptValue variantToScriptValue(QVariant var);
|
|
|
|
|
2010-10-22 12:12:35 +02:00
|
|
|
static QScriptValue loadui(QScriptContext *context, QScriptEngine *engine);
|
2010-10-14 20:34:46 +02:00
|
|
|
static QScriptValue newPlasmaSvg(QScriptContext *context, QScriptEngine *engine);
|
|
|
|
static QScriptValue newPlasmaFrameSvg(QScriptContext *context, QScriptEngine *engine);
|
|
|
|
static QScriptValue newPlasmaExtenderItem(QScriptContext *context, QScriptEngine *engine);
|
|
|
|
static QScriptValue dataEngine(QScriptContext *context, QScriptEngine *engine);
|
|
|
|
static QScriptValue service(QScriptContext *context, QScriptEngine *engine);
|
2010-10-23 19:30:10 +02:00
|
|
|
static QScriptValue loadService(QScriptContext *context, QScriptEngine *engine);
|
2010-10-14 20:34:46 +02:00
|
|
|
|
|
|
|
public Q_SLOTS:
|
2011-06-09 14:31:03 +02:00
|
|
|
void executeAction(const QString &name);
|
2010-10-14 20:34:46 +02:00
|
|
|
void dataUpdated(const QString &name, const Plasma::DataEngine::Data &data);
|
|
|
|
void signalHandlerException(const QScriptValue &exception);
|
|
|
|
void popupEvent(bool popped);
|
|
|
|
void activate();
|
|
|
|
void extenderItemRestored(Plasma::ExtenderItem* item);
|
|
|
|
void collectGarbage();
|
|
|
|
void configChanged();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool init();
|
|
|
|
void setupObjects();
|
|
|
|
static QGraphicsWidget *extractParent(QScriptContext *context,
|
|
|
|
QScriptEngine *engine,
|
|
|
|
int parentIndex = 0,
|
|
|
|
bool *parentedToApplet = 0);
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void formFactorChanged();
|
|
|
|
void locationChanged();
|
|
|
|
void contextChanged();
|
|
|
|
|
|
|
|
private:
|
2011-06-09 14:31:03 +02:00
|
|
|
void callPlasmoidFunction(const QString &functionName, const QScriptValueList &args, ScriptEnv *env);
|
2010-10-14 20:34:46 +02:00
|
|
|
Plasma::DeclarativeWidget *m_declarativeWidget;
|
|
|
|
AppletInterface *m_interface;
|
|
|
|
EngineAccess *m_engineAccess;
|
|
|
|
QScriptEngine *m_engine;
|
|
|
|
QScriptValue m_self;
|
|
|
|
ScriptEnv *m_env;
|
2010-10-21 22:37:47 +02:00
|
|
|
AppletAuthorization m_auth;
|
2010-10-14 20:34:46 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|