reorg the sources; was growing increasingly messy and was only going to get "worse" as DataEngine grows
svn path=/trunk/KDE/kdebase/runtime/; revision=1159715
This commit is contained in:
parent
87d6ebf09a
commit
b5669412c5
@ -1,11 +1,11 @@
|
||||
# APPLET
|
||||
|
||||
set(simple_javascript_engine_SRCS
|
||||
appletauthorization.cpp
|
||||
scriptenvui.cpp
|
||||
simplejavascriptapplet.cpp
|
||||
common/scriptenvui.cpp
|
||||
plasmoid/appletauthorization.cpp
|
||||
plasmoid/appletinterface.cpp
|
||||
plasmoid/simplejavascriptapplet.cpp
|
||||
simplebindings/animationgroup.cpp
|
||||
simplebindings/appletinterface.cpp
|
||||
simplebindings/anchorlayout.cpp
|
||||
simplebindings/dataenginereceiver.cpp
|
||||
simplebindings/bytearrayclass.cpp
|
||||
@ -33,7 +33,7 @@ set(simple_javascript_engine_SRCS
|
||||
simplebindings/variant.cpp
|
||||
)
|
||||
|
||||
include_directories(${PHONON_INCLUDES})
|
||||
include_directories(${PHONON_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR}/common)
|
||||
|
||||
kde4_add_plugin(plasma_appletscript_simple_javascript ${simple_javascript_engine_SRCS})
|
||||
|
||||
@ -52,8 +52,8 @@ install(FILES data/plasma-scriptengine-applet-simple-javascript.desktop DESTINAT
|
||||
# RUNNER
|
||||
|
||||
set(javascript_runner_engine_SRCS
|
||||
javascriptrunner.cpp
|
||||
scriptenv.cpp
|
||||
common/scriptenv.cpp
|
||||
runner/javascriptrunner.cpp
|
||||
)
|
||||
|
||||
kde4_add_plugin(plasma_runnerscript_javascript ${javascript_runner_engine_SRCS})
|
||||
@ -71,8 +71,8 @@ install(FILES data/plasma-scriptengine-runner-javascript.desktop DESTINATION ${S
|
||||
# DATAENGINE
|
||||
|
||||
set(javascript_dataengine_engine_SRCS
|
||||
javascriptdataengine.cpp
|
||||
scriptenv.cpp
|
||||
dataengine/javascriptdataengine.cpp
|
||||
common/scriptenv.cpp
|
||||
simplebindings/dataengine.cpp
|
||||
simplebindings/variant.cpp
|
||||
)
|
||||
|
@ -1,2 +1,2 @@
|
||||
#! /usr/bin/env bash
|
||||
$XGETTEXT *.cpp simplebindings/*.cpp -o $podir/plasma_scriptengine_qscript.pot
|
||||
$XGETTEXT *.cpp dataengine/*.cpp runner/*.cpp plasmoid/*.cpp common/*.cpp simplebindings/*.cpp -o $podir/plasma_scriptengine_qscript.pot
|
||||
|
@ -34,6 +34,8 @@
|
||||
#include <Plasma/Context>
|
||||
#include <Plasma/Package>
|
||||
|
||||
Q_DECLARE_METATYPE(AppletInterface*)
|
||||
|
||||
AppletInterface::AppletInterface(SimpleJavaScriptApplet *parent)
|
||||
: QObject(parent),
|
||||
m_appletScriptEngine(parent),
|
||||
@ -47,6 +49,12 @@ AppletInterface::~AppletInterface()
|
||||
{
|
||||
}
|
||||
|
||||
AppletInterface *AppletInterface::extract(QScriptEngine *engine)
|
||||
{
|
||||
QScriptValue appletValue = engine->globalObject().property("plasmoid");
|
||||
return qobject_cast<AppletInterface*>(appletValue.toQObject());
|
||||
}
|
||||
|
||||
Plasma::DataEngine* AppletInterface::dataEngine(const QString &name)
|
||||
{
|
||||
return applet()->dataEngine(name);
|
@ -277,6 +277,7 @@ enum IntervalAlignment {
|
||||
bool userConfiguring() const;
|
||||
int apiVersion() const;
|
||||
|
||||
static AppletInterface *extract(QScriptEngine *engine);
|
||||
inline Plasma::Applet *applet() const { return m_appletScriptEngine->applet(); }
|
||||
|
||||
Q_SIGNALS:
|
@ -56,12 +56,12 @@
|
||||
#include <Plasma/VideoWidget>
|
||||
|
||||
#include "appletauthorization.h"
|
||||
#include "appletinterface.h"
|
||||
#include "scriptenv.h"
|
||||
#include "simplebindings/animationgroup.h"
|
||||
#include "simplebindings/dataengine.h"
|
||||
#include "simplebindings/dataenginereceiver.h"
|
||||
#include "simplebindings/i18n.h"
|
||||
#include "simplebindings/appletinterface.h"
|
||||
#include "simplebindings/bytearrayclass.h"
|
||||
#include "simplebindings/variant.h"
|
||||
|
||||
@ -123,7 +123,7 @@ void SimpleJavaScriptApplet::engineReportsError(ScriptEnv *engine, bool fatal)
|
||||
void SimpleJavaScriptApplet::reportError(ScriptEnv *env, bool fatal)
|
||||
{
|
||||
SimpleJavaScriptApplet *jsApplet = qobject_cast<SimpleJavaScriptApplet *>(env->parent());
|
||||
AppletInterface *interface = extractAppletInterface(env->engine());
|
||||
AppletInterface *interface = AppletInterface::extract(env->engine());
|
||||
const QScriptValue error = env->engine()->uncaughtException();
|
||||
QString file = error.property("fileName").toString();
|
||||
if (interface) {
|
||||
@ -573,19 +573,13 @@ QSet<QString> SimpleJavaScriptApplet::loadedExtensions() const
|
||||
return m_env->loadedExtensions();
|
||||
}
|
||||
|
||||
AppletInterface *SimpleJavaScriptApplet::extractAppletInterface(QScriptEngine *engine)
|
||||
{
|
||||
QScriptValue appletValue = engine->globalObject().property("plasmoid");
|
||||
return qobject_cast<AppletInterface*>(appletValue.toQObject());
|
||||
}
|
||||
|
||||
QScriptValue SimpleJavaScriptApplet::dataEngine(QScriptContext *context, QScriptEngine *engine)
|
||||
{
|
||||
if (context->argumentCount() != 1) {
|
||||
return context->throwError(i18n("dataEngine() takes one argument"));
|
||||
}
|
||||
|
||||
AppletInterface *interface = extractAppletInterface(engine);
|
||||
AppletInterface *interface = AppletInterface::extract(engine);
|
||||
if (!interface) {
|
||||
return context->throwError(i18n("Could not extract the Applet"));
|
||||
}
|
||||
@ -606,7 +600,7 @@ QScriptValue SimpleJavaScriptApplet::service(QScriptContext *context, QScriptEng
|
||||
|
||||
QString dataEngine = context->argument(0).toString();
|
||||
|
||||
AppletInterface *interface = extractAppletInterface(engine);
|
||||
AppletInterface *interface = AppletInterface::extract(engine);
|
||||
if (!interface) {
|
||||
return context->throwError(i18n("Could not extract the Applet"));
|
||||
}
|
||||
@ -707,19 +701,9 @@ QScriptValue SimpleJavaScriptApplet::loadui(QScriptContext *context, QScriptEngi
|
||||
return engine->newQObject(w, QScriptEngine::AutoOwnership);
|
||||
}
|
||||
|
||||
QString SimpleJavaScriptApplet::findImageFile(QScriptEngine *engine, const QString &file)
|
||||
{
|
||||
AppletInterface *interface = extractAppletInterface(engine);
|
||||
if (!interface) {
|
||||
return QString();
|
||||
}
|
||||
|
||||
return interface->package()->filePath("images", file);
|
||||
}
|
||||
|
||||
QString SimpleJavaScriptApplet::findSvg(QScriptEngine *engine, const QString &file)
|
||||
{
|
||||
AppletInterface *interface = extractAppletInterface(engine);
|
||||
AppletInterface *interface = AppletInterface::extract(engine);
|
||||
if (!interface) {
|
||||
return file;
|
||||
}
|
||||
@ -778,7 +762,7 @@ QScriptValue SimpleJavaScriptApplet::newPlasmaExtenderItem(QScriptContext *conte
|
||||
}
|
||||
|
||||
if (!extender) {
|
||||
AppletInterface *interface = extractAppletInterface(engine);
|
||||
AppletInterface *interface = AppletInterface::extract(engine);
|
||||
if (!interface) {
|
||||
engine->undefinedValue();
|
||||
}
|
||||
@ -831,7 +815,7 @@ QGraphicsWidget *SimpleJavaScriptApplet::extractParent(QScriptContext *context,
|
||||
}
|
||||
|
||||
if (!parent) {
|
||||
AppletInterface *interface = extractAppletInterface(engine);
|
||||
AppletInterface *interface = AppletInterface::extract(engine);
|
||||
if (!interface) {
|
||||
return 0;
|
||||
}
|
@ -60,8 +60,6 @@ public:
|
||||
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
|
||||
static QString findImageFile(QScriptEngine *engine, const QString &file);
|
||||
|
||||
public Q_SLOTS:
|
||||
void dataUpdated( const QString &name, const Plasma::DataEngine::Data &data );
|
||||
void configChanged();
|
||||
@ -104,7 +102,6 @@ private:
|
||||
static QScriptValue createWidget(QScriptContext *context, QScriptEngine *engine);
|
||||
static QScriptValue widgetAdjustSize(QScriptContext *context, QScriptEngine *engine);
|
||||
|
||||
static AppletInterface *extractAppletInterface(QScriptEngine *engine);
|
||||
static QGraphicsWidget *extractParent(QScriptContext *context,
|
||||
QScriptEngine *engine,
|
||||
int parentIndex = 0,
|
@ -25,8 +25,7 @@
|
||||
|
||||
#include <Plasma/Applet>
|
||||
|
||||
#include "../backportglobal.h"
|
||||
#include "appletinterface.h"
|
||||
#include "backportglobal.h"
|
||||
|
||||
Q_DECLARE_METATYPE(QScript::Pointer<QGraphicsItem>::wrapped_pointer_type)
|
||||
Q_DECLARE_METATYPE(QGraphicsWidget*)
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include <QtScript/QScriptEngine>
|
||||
#include <QtScript/QScriptContext>
|
||||
#include <QtGui/QColor>
|
||||
#include "../backportglobal.h"
|
||||
#include "backportglobal.h"
|
||||
|
||||
Q_DECLARE_METATYPE(QColor*)
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include <QScriptContext>
|
||||
#include <QScriptable>
|
||||
|
||||
#include "../backportglobal.h"
|
||||
#include "backportglobal.h"
|
||||
|
||||
Q_DECLARE_METATYPE(QEasingCurve)
|
||||
Q_DECLARE_METATYPE(QEasingCurve*)
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include <QtScript/QScriptEngine>
|
||||
#include <QtScript/QScriptContext>
|
||||
#include <QtGui/QFont>
|
||||
#include "../backportglobal.h"
|
||||
#include "backportglobal.h"
|
||||
|
||||
Q_DECLARE_METATYPE(QFont*)
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <QtGui/QCursor>
|
||||
#include <QtGui/QGraphicsItem>
|
||||
#include <QtGui/QGraphicsScene>
|
||||
#include "../backportglobal.h"
|
||||
#include "backportglobal.h"
|
||||
|
||||
Q_DECLARE_METATYPE(QScript::Pointer<QGraphicsItem>::wrapped_pointer_type)
|
||||
Q_DECLARE_METATYPE(QList<QGraphicsItem*>)
|
||||
|
@ -25,8 +25,7 @@
|
||||
|
||||
#include <Plasma/Applet>
|
||||
|
||||
#include "../backportglobal.h"
|
||||
#include "appletinterface.h"
|
||||
#include "backportglobal.h"
|
||||
|
||||
#define DECLARE_INT_NUMBER_GET_METHOD(Class, __get__) \
|
||||
BEGIN_DECLARE_METHOD(Class, __get__) { \
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
#include <KIcon>
|
||||
|
||||
#include "../backportglobal.h"
|
||||
#include "backportglobal.h"
|
||||
|
||||
Q_DECLARE_METATYPE(QIcon)
|
||||
Q_DECLARE_METATYPE(QIcon*)
|
||||
|
@ -27,8 +27,8 @@
|
||||
|
||||
#include <Plasma/Applet>
|
||||
|
||||
#include "../backportglobal.h"
|
||||
#include "appletinterface.h"
|
||||
#include "backportglobal.h"
|
||||
#include "plasmoid/appletinterface.h"
|
||||
|
||||
Q_DECLARE_METATYPE(QScript::Pointer<QGraphicsItem>::wrapped_pointer_type)
|
||||
Q_DECLARE_METATYPE(QGraphicsWidget*)
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
#include <QtCore/qdebug.h>
|
||||
|
||||
#include "../backportglobal.h"
|
||||
#include "backportglobal.h"
|
||||
|
||||
Q_DECLARE_METATYPE(QPolygonF)
|
||||
Q_DECLARE_METATYPE(QPainterPath)
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include <QtScript/QScriptEngine>
|
||||
#include <QtScript/QScriptContext>
|
||||
#include <QtGui/QPen>
|
||||
#include "../backportglobal.h"
|
||||
#include "backportglobal.h"
|
||||
|
||||
Q_DECLARE_METATYPE(QPen*)
|
||||
|
||||
|
@ -20,8 +20,8 @@
|
||||
#include <QtScript/QScriptEngine>
|
||||
#include <QtScript/QScriptContext>
|
||||
#include <QtGui/QPixmap>
|
||||
#include "../backportglobal.h"
|
||||
#include "../simplejavascriptapplet.h"
|
||||
#include "backportglobal.h"
|
||||
#include "plasmoid/appletinterface.h"
|
||||
|
||||
Q_DECLARE_METATYPE(QPixmap*)
|
||||
Q_DECLARE_METATYPE(QPixmap)
|
||||
@ -30,7 +30,9 @@ static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
|
||||
{
|
||||
if (ctx->argumentCount() == 1 && ctx->argument(0).isString()) {
|
||||
// a path on disk in the package
|
||||
return qScriptValueFromValue(eng, QPixmap(SimpleJavaScriptApplet::findImageFile(eng, ctx->argument(0).toString())));
|
||||
AppletInterface *interface = AppletInterface::extract(eng);
|
||||
const QString path = interface ? interface->file("images", ctx->argument(0).toString()) : QString();
|
||||
return qScriptValueFromValue(eng, QPixmap(path));
|
||||
}
|
||||
|
||||
if (ctx->argumentCount() == 2) {
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include <QtScript/QScriptEngine>
|
||||
#include <QtScript/QScriptContext>
|
||||
#include <QtCore/QPoint>
|
||||
#include "../backportglobal.h"
|
||||
#include "backportglobal.h"
|
||||
|
||||
Q_DECLARE_METATYPE(QPoint*)
|
||||
Q_DECLARE_METATYPE(QPoint)
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include <Plasma/Extender>
|
||||
#include <Plasma/VideoWidget>
|
||||
|
||||
#include "appletinterface.h"
|
||||
#include "dataengine.h"
|
||||
#include "variant.h"
|
||||
|
||||
@ -45,11 +44,6 @@ Q_DECLARE_METATYPE(Plasma::VideoWidget::Controls)
|
||||
Q_DECLARE_METATYPE(Plasma::Svg*)
|
||||
Q_DECLARE_METATYPE(Qt::MouseButton)
|
||||
|
||||
Q_DECLARE_METATYPE(AppletInterface*)
|
||||
|
||||
//Q_SCRIPT_DECLARE_QMETAOBJECT(AppletInterface, SimpleJavaScriptApplet*)
|
||||
|
||||
|
||||
QScriptValue qScriptValueFromControls(QScriptEngine *engine, const Plasma::VideoWidget::Controls &controls)
|
||||
{
|
||||
return QScriptValue(engine, controls);
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include <QtScript/QScriptEngine>
|
||||
#include <QtScript/QScriptContext>
|
||||
#include <QtCore/QRectF>
|
||||
#include "../backportglobal.h"
|
||||
#include "backportglobal.h"
|
||||
|
||||
Q_DECLARE_METATYPE(QRectF*)
|
||||
Q_DECLARE_METATYPE(QRectF)
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include <QtScript/QScriptEngine>
|
||||
#include <QtScript/QScriptContext>
|
||||
#include <QtCore/QSizeF>
|
||||
#include "../backportglobal.h"
|
||||
#include "backportglobal.h"
|
||||
|
||||
Q_DECLARE_METATYPE(QSizeF*)
|
||||
Q_DECLARE_METATYPE(QSizeF)
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include <QtScript/QScriptEngine>
|
||||
#include <QtScript/QScriptContext>
|
||||
#include <QtGui/QSizePolicy>
|
||||
#include "../backportglobal.h"
|
||||
#include "backportglobal.h"
|
||||
|
||||
Q_DECLARE_METATYPE(QSizePolicy*)
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include <QtScript/QScriptContext>
|
||||
#include <QtScript/QScriptable>
|
||||
#include <QtCore/QTimer>
|
||||
#include "../backportglobal.h"
|
||||
#include "backportglobal.h"
|
||||
|
||||
Q_DECLARE_METATYPE(QTimer*)
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include <QtScript/QScriptEngine>
|
||||
#include <QtScript/QScriptContext>
|
||||
#include <KUrl>
|
||||
#include "../backportglobal.h"
|
||||
#include "backportglobal.h"
|
||||
|
||||
Q_DECLARE_METATYPE(KUrl*)
|
||||
//Q_DECLARE_METATYPE(KUrl) unneeded; found in kurl.h
|
||||
|
Loading…
x
Reference in New Issue
Block a user