new AppletInterface in case of inexistent plugin
if the plugin name is wrong, create a fullfledged appletinterface for the error visualization. This will make applet removal possible BUG:332971
This commit is contained in:
parent
0bc18eef01
commit
aeabbe9444
@ -448,23 +448,28 @@ void AppletQuickItem::init()
|
||||
//Initialize the main QML file
|
||||
QQmlEngine *engine = d->qmlObject->engine();
|
||||
|
||||
PackageUrlInterceptor *interceptor = new PackageUrlInterceptor(engine, d->applet->package());
|
||||
interceptor->addAllowedPath(d->coronaPackage.path());
|
||||
engine->setUrlInterceptor(interceptor);
|
||||
if (d->applet->package().isValid()) {
|
||||
PackageUrlInterceptor *interceptor = new PackageUrlInterceptor(engine, d->applet->package());
|
||||
interceptor->addAllowedPath(d->coronaPackage.path());
|
||||
engine->setUrlInterceptor(interceptor);
|
||||
}
|
||||
|
||||
d->qmlObject->setSource(QUrl::fromLocalFile(d->applet->package().filePath("mainscript")));
|
||||
|
||||
if (!engine || !engine->rootContext() || !engine->rootContext()->isValid() || d->qmlObject->mainComponent()->isError()) {
|
||||
QString reason;
|
||||
foreach (QQmlError error, d->qmlObject->mainComponent()->errors()) {
|
||||
reason += error.toString()+'\n';
|
||||
if (d->applet->package().isValid()) {
|
||||
foreach (QQmlError error, d->qmlObject->mainComponent()->errors()) {
|
||||
reason += error.toString()+'\n';
|
||||
}
|
||||
reason = i18n("Error loading QML file: %1", reason);
|
||||
} else {
|
||||
reason = i18n("Error loading Applet: package inexistent. %1", applet()->launchErrorMessage());
|
||||
}
|
||||
reason = i18n("Error loading QML file: %1", reason);
|
||||
|
||||
d->qmlObject->setSource(QUrl::fromLocalFile(d->coronaPackage.filePath("appleterror")));
|
||||
d->qmlObject->completeInitialization();
|
||||
|
||||
|
||||
//even the error message QML may fail
|
||||
if (d->qmlObject->mainComponent()->isError()) {
|
||||
return;
|
||||
|
@ -85,6 +85,39 @@ AppletInterface::AppletInterface(DeclarativeAppletScript *script, QQuickItem *pa
|
||||
}
|
||||
}
|
||||
|
||||
AppletInterface::AppletInterface(Plasma::Applet *a, QQuickItem *parent)
|
||||
: AppletQuickItem(a, parent),
|
||||
m_actionSignals(0),
|
||||
m_appletScriptEngine(0),
|
||||
m_backgroundHints(Plasma::Types::StandardBackground),
|
||||
m_busy(false),
|
||||
m_hideOnDeactivate(true)
|
||||
{
|
||||
qmlRegisterType<QAction>();
|
||||
|
||||
connect(this, &AppletInterface::configNeedsSaving,
|
||||
applet(), &Plasma::Applet::configNeedsSaving);
|
||||
connect(applet(), &Plasma::Applet::immutabilityChanged,
|
||||
this, &AppletInterface::immutableChanged);
|
||||
connect(applet(), &Plasma::Applet::userConfiguringChanged,
|
||||
this, &AppletInterface::userConfiguringChanged);
|
||||
|
||||
connect(applet(), &Plasma::Applet::statusChanged,
|
||||
this, &AppletInterface::statusChanged);
|
||||
|
||||
connect(appletScript(), &DeclarativeAppletScript::formFactorChanged,
|
||||
this, &AppletInterface::formFactorChanged);
|
||||
connect(appletScript(), &DeclarativeAppletScript::locationChanged,
|
||||
this, &AppletInterface::locationChanged);
|
||||
connect(appletScript(), &DeclarativeAppletScript::contextChanged,
|
||||
this, &AppletInterface::contextChanged);
|
||||
|
||||
if (applet()->containment()) {
|
||||
connect(applet()->containment(), &Plasma::Containment::screenChanged,
|
||||
this, &ContainmentInterface::screenChanged);
|
||||
}
|
||||
}
|
||||
|
||||
AppletInterface::~AppletInterface()
|
||||
{
|
||||
}
|
||||
|
@ -168,6 +168,7 @@ class AppletInterface : public PlasmaQuick::AppletQuickItem
|
||||
|
||||
public:
|
||||
AppletInterface(DeclarativeAppletScript *script, QQuickItem *parent = 0);
|
||||
AppletInterface(Plasma::Applet *applet, QQuickItem *parent = 0);
|
||||
~AppletInterface();
|
||||
|
||||
//API not intended for the QML part
|
||||
|
@ -505,20 +505,15 @@ void ContainmentInterface::appletAddedForward(Plasma::Applet *applet)
|
||||
qDebug() << "Applet added on containment:" << containment()->title() << contGraphicObject
|
||||
<< "Applet: " << applet << applet->title() << appletGraphicObject;
|
||||
|
||||
if (contGraphicObject && appletGraphicObject) {
|
||||
if (!appletGraphicObject) {
|
||||
appletGraphicObject = new AppletInterface(applet, this);
|
||||
applet->setProperty("_plasma_graphicObject", QVariant::fromValue(appletGraphicObject));
|
||||
static_cast<AppletInterface *>(appletGraphicObject)->init();
|
||||
}
|
||||
|
||||
if (contGraphicObject) {
|
||||
appletGraphicObject->setProperty("visible", false);
|
||||
appletGraphicObject->setProperty("parent", QVariant::fromValue(contGraphicObject));
|
||||
|
||||
//if an appletGraphicObject is not set, we have to display some error message
|
||||
} else if (contGraphicObject) {
|
||||
QObject *errorUi = qmlObject()->createObjectFromSource(QUrl::fromLocalFile(containment()->corona()->package().filePath("appleterror")));
|
||||
|
||||
if (errorUi) {
|
||||
errorUi->setProperty("visible", false);
|
||||
errorUi->setProperty("parent", QVariant::fromValue(contGraphicObject));
|
||||
errorUi->setProperty("reason", applet->launchErrorMessage());
|
||||
appletGraphicObject = errorUi;
|
||||
}
|
||||
}
|
||||
|
||||
m_appletInterfaces << appletGraphicObject;
|
||||
|
Loading…
Reference in New Issue
Block a user