From 7737bb48ba7ac86705b5ab4a63e6b9210f1f8910 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Fri, 27 Apr 2012 19:13:54 +0100 Subject: [PATCH] Register non-gui types properly for declarative applets It was not previously possible to use KConfig etc. from declarative applets, because the relevant qScriptRegisterMetaType functions were not called. This fixes that by calling registerNonGuiMetaTypes from registerSimpleAppletMetaTypes. --- scriptengines/javascript/plasmoid/simplejavascriptapplet.cpp | 2 -- .../javascript/simplebindings/qscriptbookkeeping.cpp | 4 +++- .../javascript/simplebindings/qscriptnonguibookkeeping.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scriptengines/javascript/plasmoid/simplejavascriptapplet.cpp b/scriptengines/javascript/plasmoid/simplejavascriptapplet.cpp index 5804114d6..131bcca08 100644 --- a/scriptengines/javascript/plasmoid/simplejavascriptapplet.cpp +++ b/scriptengines/javascript/plasmoid/simplejavascriptapplet.cpp @@ -93,7 +93,6 @@ QScriptValue constructQRectFClass(QScriptEngine *engine); QScriptValue constructQSizeFClass(QScriptEngine *engine); QScriptValue constructQSizePolicyClass(QScriptEngine *engine); QScriptValue constructTimerClass(QScriptEngine *engine); -void registerNonGuiMetaTypes(QScriptEngine *engine); void registerSimpleAppletMetaTypes(QScriptEngine *engine); KSharedPtr SimpleJavaScriptApplet::s_widgetLoader; @@ -581,7 +580,6 @@ void SimpleJavaScriptApplet::setupObjects() global.setProperty("FrameSvg", m_engine->newFunction(SimpleJavaScriptApplet::newPlasmaFrameSvg)); global.setProperty("ExtenderItem", m_engine->newFunction(SimpleJavaScriptApplet::newPlasmaExtenderItem)); - registerNonGuiMetaTypes(m_engine); registerSimpleAppletMetaTypes(m_engine); installWidgets(m_engine); } diff --git a/scriptengines/javascript/simplebindings/qscriptbookkeeping.cpp b/scriptengines/javascript/simplebindings/qscriptbookkeeping.cpp index 1e35fea20..bc9cb8b7b 100644 --- a/scriptengines/javascript/simplebindings/qscriptbookkeeping.cpp +++ b/scriptengines/javascript/simplebindings/qscriptbookkeeping.cpp @@ -127,10 +127,13 @@ void mouseButtonFromScriptValue(const QScriptValue &scriptValue, Qt::MouseButton button = static_cast(scriptValue.toInt32()); } +#include "simplebindings/qscriptnonguibookkeeping.cpp" + using namespace Plasma; void registerSimpleAppletMetaTypes(QScriptEngine *engine) { + registerNonGuiMetaTypes(engine); qScriptRegisterMetaType(engine, qScriptValueFromQGraphicsWidget, graphicsWidgetFromQScriptValue); qScriptRegisterMetaType(engine, qScriptValueFromSvg, svgFromQScriptValue); @@ -141,5 +144,4 @@ void registerSimpleAppletMetaTypes(QScriptEngine *engine) qScriptRegisterMetaType(engine, qScriptValueFromMouseButton, mouseButtonFromScriptValue); } -#include "simplebindings/qscriptnonguibookkeeping.cpp" diff --git a/scriptengines/javascript/simplebindings/qscriptnonguibookkeeping.cpp b/scriptengines/javascript/simplebindings/qscriptnonguibookkeeping.cpp index 18c8f8cc9..a3162e2dc 100644 --- a/scriptengines/javascript/simplebindings/qscriptnonguibookkeeping.cpp +++ b/scriptengines/javascript/simplebindings/qscriptnonguibookkeeping.cpp @@ -100,7 +100,7 @@ using namespace Plasma; void registerNonGuiMetaTypes(QScriptEngine *engine) { - qScriptRegisterMetaType(engine, qScriptValueFromKConfigGroup, kConfigGroupFromScriptValue, QScriptValue()); + qScriptRegisterMetaType(engine, qScriptValueFromKConfigGroup, kConfigGroupFromScriptValue); qScriptRegisterMetaType(engine, qScriptValueFromKJob, qKJobFromQScriptValue); qScriptRegisterMetaType(engine, qScriptValueFromKIOJob, qKIOJobFromQScriptValue); registerDataEngineMetaTypes(engine);