don't re-bind what was done in libkdeclarative

This commit is contained in:
Marco Martin 2011-04-07 23:27:05 +02:00
parent 2a54c9c416
commit 6f9f911c68
3 changed files with 8 additions and 20 deletions

View File

@ -133,10 +133,7 @@ set(declarative_appletscript_SRCS
simplebindings/dataengine.cpp simplebindings/dataengine.cpp
simplebindings/dataenginereceiver.cpp simplebindings/dataenginereceiver.cpp
simplebindings/filedialogproxy.cpp simplebindings/filedialogproxy.cpp
simplebindings/i18n.cpp
simplebindings/icon.cpp
simplebindings/qscriptbookkeeping.cpp simplebindings/qscriptbookkeeping.cpp
simplebindings/url.cpp
) )
include_directories(${PHONON_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR}/common) include_directories(${PHONON_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR}/common)

View File

@ -52,8 +52,11 @@
#include "common/scriptenv.h" #include "common/scriptenv.h"
#include "declarative/packageaccessmanagerfactory.h" #include "declarative/packageaccessmanagerfactory.h"
#include "simplebindings/bytearrayclass.h" #include "simplebindings/bytearrayclass.h"
//not pretty but only way to avoid a double Q_DECLARE_METATYPE(QVariant) in dataengine.h
#define DECLARATIVE_BINDING
#include "simplebindings/dataengine.h"
#include "simplebindings/dataenginereceiver.h" #include "simplebindings/dataenginereceiver.h"
#include "simplebindings/i18n.h"
K_EXPORT_PLASMA_APPLETSCRIPTENGINE(declarativeappletscript, DeclarativeAppletScript) K_EXPORT_PLASMA_APPLETSCRIPTENGINE(declarativeappletscript, DeclarativeAppletScript)
@ -61,8 +64,6 @@ K_EXPORT_PLASMA_APPLETSCRIPTENGINE(declarativeappletscript, DeclarativeAppletScr
QScriptValue constructIconClass(QScriptEngine *engine); QScriptValue constructIconClass(QScriptEngine *engine);
QScriptValue constructKUrlClass(QScriptEngine *engine); QScriptValue constructKUrlClass(QScriptEngine *engine);
void registerSimpleAppletMetaTypes(QScriptEngine *engine); void registerSimpleAppletMetaTypes(QScriptEngine *engine);
void registerNonGuiMetaTypes(QScriptEngine *engine);
DeclarativeAppletScript::DeclarativeAppletScript(QObject *parent, const QVariantList &args) DeclarativeAppletScript::DeclarativeAppletScript(QObject *parent, const QVariantList &args)
: AbstractJsAppletScript(parent, args), : AbstractJsAppletScript(parent, args),
m_engine(0), m_engine(0),
@ -348,11 +349,6 @@ void DeclarativeAppletScript::setupObjects()
m_engine = m_declarativeWidget->scriptEngine(); m_engine = m_declarativeWidget->scriptEngine();
connect(m_engine, SIGNAL(signalHandlerException(const QScriptValue &)), connect(m_engine, SIGNAL(signalHandlerException(const QScriptValue &)),
this, SLOT(signalHandlerException(const QScriptValue &))); this, SLOT(signalHandlerException(const QScriptValue &)));
QScriptValue originalGlobalObject = m_engine->globalObject();
QScriptValue newGlobalObject = m_engine->newObject();
m_engine->setGlobalObject(newGlobalObject);
delete m_env; delete m_env;
m_env = new ScriptEnv(this, m_engine); m_env = new ScriptEnv(this, m_engine);
@ -378,19 +374,14 @@ void DeclarativeAppletScript::setupObjects()
ScriptEnv::registerEnums(global, AppletInterface::staticMetaObject); ScriptEnv::registerEnums(global, AppletInterface::staticMetaObject);
bindI18N(m_engine);
global.setProperty("dataEngine", m_engine->newFunction(DeclarativeAppletScript::dataEngine)); global.setProperty("dataEngine", m_engine->newFunction(DeclarativeAppletScript::dataEngine));
global.setProperty("service", m_engine->newFunction(DeclarativeAppletScript::service)); global.setProperty("service", m_engine->newFunction(DeclarativeAppletScript::service));
global.setProperty("loadService", m_engine->newFunction(DeclarativeAppletScript::loadService)); global.setProperty("loadService", m_engine->newFunction(DeclarativeAppletScript::loadService));
//Add stuff from Qt //Add stuff from Qt
//TODO: move to libkdeclarative?
ByteArrayClass *baClass = new ByteArrayClass(m_engine); ByteArrayClass *baClass = new ByteArrayClass(m_engine);
global.setProperty("ByteArray", baClass->constructor()); global.setProperty("ByteArray", baClass->constructor());
global.setProperty("QIcon", constructIconClass(m_engine));
// Add stuff from KDE libs
qScriptRegisterSequenceMetaType<KUrl::List>(m_engine);
global.setProperty("Url", constructKUrlClass(m_engine));
// Add stuff from Plasma // Add stuff from Plasma
global.setProperty("Svg", m_engine->newFunction(DeclarativeAppletScript::newPlasmaSvg)); global.setProperty("Svg", m_engine->newFunction(DeclarativeAppletScript::newPlasmaSvg));
@ -401,10 +392,8 @@ void DeclarativeAppletScript::setupObjects()
return; return;
} }
qScriptRegisterSequenceMetaType<KUrl::List>(m_engine);
registerNonGuiMetaTypes(m_engine);
registerSimpleAppletMetaTypes(m_engine); registerSimpleAppletMetaTypes(m_engine);
registerDataEngineMetaTypes(m_engine);
QTimer::singleShot(0, this, SLOT(configChanged())); QTimer::singleShot(0, this, SLOT(configChanged()));
} }

View File

@ -32,7 +32,9 @@ using namespace Plasma;
Q_DECLARE_METATYPE(Service*) Q_DECLARE_METATYPE(Service*)
Q_DECLARE_METATYPE(ServiceJob*) Q_DECLARE_METATYPE(ServiceJob*)
#ifndef DECLARATIVE_BINDING
Q_DECLARE_METATYPE(QVariant) Q_DECLARE_METATYPE(QVariant)
#endif
Q_DECLARE_METATYPE(DataEngine::Dict) Q_DECLARE_METATYPE(DataEngine::Dict)
Q_DECLARE_METATYPE(DataEngine::Data) Q_DECLARE_METATYPE(DataEngine::Data)