register extra types on QScriptEngine

only if hasn't been done yet
This commit is contained in:
Marco Martin 2011-11-01 18:55:57 +01:00
parent 38c8915cd7
commit 2bb756cfe7
2 changed files with 15 additions and 1 deletions

View File

@ -23,7 +23,7 @@ qt4_automoc(${corebindings_SRCS})
add_library(corebindingsplugin SHARED ${corebindings_SRCS})
target_link_libraries(corebindingsplugin ${KDE4_PLASMA_LIBS} ${QT_QTSCRIPT_LIBRARY} ${QT_QTDECLARATIVE_LIBRARY})
target_link_libraries(corebindingsplugin ${KDE4_PLASMA_LIBS} ${QT_QTSCRIPT_LIBRARY} ${QT_QTDECLARATIVE_LIBRARY} kdeclarative)
install(TARGETS corebindingsplugin DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/plasma/core)
install(FILES qmldir DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/plasma/core)

View File

@ -23,6 +23,9 @@
#include <QtDeclarative/qdeclarative.h>
#include <QDeclarativeContext>
#include <QScriptEngine>
#include <kdeclarative.h>
#include <Plasma/FrameSvg>
#include <Plasma/Svg>
@ -43,6 +46,17 @@ void CoreBindingsPlugin::initializeEngine(QDeclarativeEngine *engine, const char
ThemeProxy *theme = new ThemeProxy(context);
context->setContextProperty("theme", theme);
KDeclarative kdeclarative;
kdeclarative.setDeclarativeEngine(engine);
kdeclarative.initialize();
QScriptEngine *scriptEngine = kdeclarative.scriptEngine();
kWarning()<<"AAAAA"<<scriptEngine->globalObject().property("i18n").isValid();
//inject the hack only if wasn't injected already
if (!scriptEngine->globalObject().property("i18n").isValid()) {
//binds things like kconfig and icons
kdeclarative.setupBindings();
}
}
void CoreBindingsPlugin::registerTypes(const char *uri)