From 920eef166644e0fcd23046637852848a84d7c22a Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Tue, 9 Mar 2010 20:01:51 +0000 Subject: [PATCH] support for Svg* marshalling, used with e.g. Plasma::SvgWidget svn path=/trunk/KDE/kdebase/runtime/; revision=1101267 --- .../simplebindings/qscriptbookkeeping.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/scriptengines/javascript/simplebindings/qscriptbookkeeping.cpp b/scriptengines/javascript/simplebindings/qscriptbookkeeping.cpp index 8f7a969ec..5c0360000 100644 --- a/scriptengines/javascript/simplebindings/qscriptbookkeeping.cpp +++ b/scriptengines/javascript/simplebindings/qscriptbookkeeping.cpp @@ -42,6 +42,7 @@ Q_DECLARE_METATYPE(Plasma::Animation*) Q_DECLARE_METATYPE(Plasma::Applet*) Q_DECLARE_METATYPE(Plasma::Extender*) Q_DECLARE_METATYPE(Plasma::VideoWidget::Controls) +Q_DECLARE_METATYPE(Plasma::Svg*) Q_DECLARE_METATYPE(AppletInterface*) @@ -167,12 +168,24 @@ QScriptValue qScriptValueFromQGraphicsWidget(QScriptEngine *engine, const QGraph return engine->newQObject(const_cast(anim), QScriptEngine::AutoOwnership, QScriptEngine::PreferExistingWrapperObject); } -void qGraphicsWidgetFromQScriptValue(const QScriptValue &scriptValue, QGraphicsWidgetPtr &anim) +void graphicsWidgetFromQScriptValue(const QScriptValue &scriptValue, QGraphicsWidgetPtr &anim) { QObject *obj = scriptValue.toQObject(); anim = static_cast(obj); } +typedef Plasma::Svg * SvgPtr; +QScriptValue qScriptValueFromSvg(QScriptEngine *engine, const SvgPtr &anim) +{ + return engine->newQObject(const_cast(anim), QScriptEngine::AutoOwnership, QScriptEngine::PreferExistingWrapperObject); +} + +void svgFromQScriptValue(const QScriptValue &scriptValue, SvgPtr &anim) +{ + QObject *obj = scriptValue.toQObject(); + anim = static_cast(obj); +} + typedef Plasma::Extender *ExtenderPtr; QScriptValue qScriptValueFromExtender(QScriptEngine *engine, const ExtenderPtr &extender) { @@ -189,7 +202,8 @@ using namespace Plasma; void registerSimpleAppletMetaTypes(QScriptEngine *engine) { - qScriptRegisterMetaType(engine, qScriptValueFromQGraphicsWidget, qGraphicsWidgetFromQScriptValue); + qScriptRegisterMetaType(engine, qScriptValueFromQGraphicsWidget, graphicsWidgetFromQScriptValue); + qScriptRegisterMetaType(engine, qScriptValueFromSvg, svgFromQScriptValue); qScriptRegisterMetaType(engine, qScriptValueFromKConfigGroup, kConfigGroupFromScriptValue, QScriptValue()); qScriptRegisterMetaType(engine, qScriptValueFromKJob, qKJobFromQScriptValue);