Commit d291d3af authored by Aaron J. Seigo's avatar Aaron J. Seigo
Browse files

thanks to the changes in Package, Applet can now be lazier

REVIEW:108664
parent 4eccd4cc
......@@ -1786,7 +1786,7 @@ bool Applet::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
QGraphicsWidget *pw = this;
//This is for the rare case of applet in applet (systray)
//if the applet is in an applet that is not a containment, don't create the handle BUG:301648
while (pw = pw->parentWidget()) {
while ((pw = pw->parentWidget())) {
if (qobject_cast<Containment *>(pw)) {
break;
} else if (qobject_cast<Applet *>(pw)) {
......@@ -2783,53 +2783,32 @@ void AppletPrivate::init(const QString &packagePath)
// we have a scripted plasmoid
if (!api.isEmpty()) {
// find where the Package is
QString path = packagePath;
if (path.isEmpty()) {
QString subPath = q->packageStructure()->defaultPackageRoot() + '/' + appletDescription.pluginName() + '/';
path = KStandardDirs::locate("data", subPath + "metadata.desktop");
if (path.isEmpty()) {
path = KStandardDirs::locate("data", subPath);
} else {
path.remove(QString("metadata.desktop"));
}
} else if (!path.endsWith('/')) {
path.append('/');
}
if (path.isEmpty()) {
q->setFailedToLaunch(
true,
i18nc("Package file, name of the widget",
"Could not locate the %1 package required for the %2 widget.",
appletDescription.pluginName(), appletDescription.name()));
} else {
// create the package and see if we have something real
//kDebug() << "trying for" << path;
PackageStructure::Ptr structure = Plasma::packageStructure(api, Plasma::AppletComponent);
structure->setPath(path);
package = new Package(path, structure);
if (package->isValid()) {
// now we try and set up the script engine.
// it will be parented to this applet and so will get
// deleted when the applet does
script = Plasma::loadScriptEngine(api, q);
if (!script) {
delete package;
package = 0;
q->setFailedToLaunch(true,
i18nc("API or programming language the widget was written in, name of the widget",
"Could not create a %1 ScriptEngine for the %2 widget.",
api, appletDescription.name()));
}
} else {
q->setFailedToLaunch(true, i18nc("Package file, name of the widget",
"Could not open the %1 package required for the %2 widget.",
appletDescription.pluginName(), appletDescription.name()));
QString path = packagePath.isEmpty() ? appletDescription.pluginName() : packagePath;
// create the package and see if we have something real
PackageStructure::Ptr structure = Plasma::packageStructure(api, Plasma::AppletComponent);
package = new Package(path, structure);
//kDebug() << "***** package is" << package->path();
if (package->isValid()) {
// now we try and set up the script engine.
// it will be parented to this applet and so will get
// deleted when the applet does
script = Plasma::loadScriptEngine(api, q);
if (!script) {
delete package;
package = 0;
q->setFailedToLaunch(true,
i18nc("API or programming language the widget was written in, name of the widget",
"Could not create a %1 ScriptEngine for the %2 widget.",
api, appletDescription.name()));
}
} else {
q->setFailedToLaunch(true, i18nc("Package file, name of the widget",
"Could not open the %1 package required for the %2 widget.",
appletDescription.pluginName(), appletDescription.name()));
delete package;
package = 0;
}
}
}
......@@ -2843,8 +2822,8 @@ void AppletPrivate::setupScriptSupport()
}
kDebug() << "setting up script support, package is in" << package->path()
<< "which is a" << package->structure()->type() << "package"
<< ", main script is" << package->filePath("mainscript");
<< "which is a" << package->structure()->type() << "package"
<< ", main script is" << package->filePath("mainscript");
QString translationsPath = package->filePath("translations");
if (!translationsPath.isEmpty()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment