if no parent is given, make the applet the parent of the svgs

svn path=/trunk/KDE/kdebase/workspace/plasma/scriptengines/javascript/; revision=906379
This commit is contained in:
Aaron J. Seigo 2009-01-06 03:53:04 +00:00
parent 3394124002
commit f50517cb87

View File

@ -575,8 +575,23 @@ QScriptValue SimpleJavaScriptApplet::newPlasmaSvg(QScriptContext *context, QScri
parent = qscriptvalue_cast<QObject *>(context->argument(1));
}
bool parentedToApplet = false;
if (!parent) {
QScriptValue appletValue = engine->globalObject().property("plasmoid");
//kDebug() << "appletValue is " << appletValue.toString();
QObject *appletObject = appletValue.toQObject();
if (appletObject) {
AppletInterface *interface = qobject_cast<AppletInterface*>(appletObject);
if (interface) {
parentedToApplet = true;
parent = interface->applet();
}
}
}
Svg *svg = new Svg(parent);
svg->setImagePath(findSvg(engine, filename));
svg->setImagePath(parentedToApplet ? filename : findSvg(engine, filename));
return engine->newQObject(svg);
}
@ -593,8 +608,23 @@ QScriptValue SimpleJavaScriptApplet::newPlasmaFrameSvg(QScriptContext *context,
parent = qscriptvalue_cast<QObject *>(context->argument(1));
}
bool parentedToApplet = false;
if (!parent) {
QScriptValue appletValue = engine->globalObject().property("plasmoid");
//kDebug() << "appletValue is " << appletValue.toString();
QObject *appletObject = appletValue.toQObject();
if (appletObject) {
AppletInterface *interface = qobject_cast<AppletInterface*>(appletObject);
if (interface) {
parentedToApplet = true;
parent = interface->applet();
}
}
}
FrameSvg *frameSvg = new FrameSvg(parent);
frameSvg->setImagePath(findSvg(engine, filename));
frameSvg->setImagePath(parentedToApplet ? filename : findSvg(engine, filename));
return engine->newQObject(frameSvg);
}