diff --git a/plasma/private/packages.cpp b/plasma/private/packages.cpp index 2251e22b6..3e7172a14 100644 --- a/plasma/private/packages.cpp +++ b/plasma/private/packages.cpp @@ -280,6 +280,7 @@ void ContainmentActionsPackage::initPackage(Package *package) void GenericPackage::initPackage(Package *package) { + PlasmoidPackage::initPackage(package); package->setDefaultPackageRoot("plasma/packages/"); } diff --git a/scriptengines/qml/declarative/qmlobject.cpp b/scriptengines/qml/declarative/qmlobject.cpp index 7d336168d..472f56dd6 100644 --- a/scriptengines/qml/declarative/qmlobject.cpp +++ b/scriptengines/qml/declarative/qmlobject.cpp @@ -92,6 +92,11 @@ void QmlObjectPrivate::execute(const QString &fileName) return; } + delete component; + component = new QQmlComponent(engine, q); + delete root; + root = 0; + KDeclarative kdeclarative; kdeclarative.setDeclarativeEngine(engine); kdeclarative.initialize(); @@ -122,8 +127,6 @@ QmlObject::QmlObject(QObject *parent) { d->engine = new QQmlEngine(this); //d->engine->setNetworkAccessManagerFactory(new PackageAccessManagerFactory()); - - d->component = new QQmlComponent(d->engine, this); } QmlObject::~QmlObject() @@ -173,6 +176,9 @@ QQmlComponent *QmlObject::mainComponent() const void QmlObject::completeInitialization() { + if (d->root) { + return; + } if (d->component->status() != QQmlComponent::Ready || d->component->isError()) { d->errorPrint(); return; diff --git a/scriptengines/qml/plasmoid/declarativeappletscript.cpp b/scriptengines/qml/plasmoid/declarativeappletscript.cpp index 36edc12bd..3150f4554 100644 --- a/scriptengines/qml/plasmoid/declarativeappletscript.cpp +++ b/scriptengines/qml/plasmoid/declarativeappletscript.cpp @@ -36,6 +36,7 @@ #include #include +#include #include #include #include @@ -95,8 +96,20 @@ bool DeclarativeAppletScript::init() foreach (QQmlError error, m_qmlObject->mainComponent()->errors()) { reason += error.toString()+'\n'; } + reason = i18n("Error loading QML file: %1", reason); + + m_qmlObject->setQmlPath(applet()->containment()->corona()->package().filePath("ui", "AppletError.qml")); + m_qmlObject->completeInitialization(); + + + //even the error message QML may fail + if (m_qmlObject->mainComponent()->isError()) { + return false; + } else { + m_qmlObject->rootObject()->setProperty("reason", reason); + } + setFailedToLaunch(true, reason); - return false; } Plasma::Applet *a = applet(); @@ -110,6 +123,7 @@ bool DeclarativeAppletScript::init() } else { m_interface = new AppletInterface(this); } + m_interface->setParent(this); connect(applet(), SIGNAL(activate()), @@ -118,11 +132,15 @@ bool DeclarativeAppletScript::init() setupObjects(); m_qmlObject->completeInitialization(); + m_qmlObject->rootObject()->setProperty("parent", QVariant::fromValue(m_interface)); - m_qmlObject->rootObject()->setProperty("anchors.fill", "parent"); + + //set anchors QQmlExpression expr(m_qmlObject->engine()->rootContext(), m_qmlObject->rootObject(), "parent"); QQmlProperty prop(m_qmlObject->rootObject(), "anchors.fill"); prop.write(expr.evaluate()); + + // set the graphicObject dynamic property on applet a->setProperty("graphicObject", QVariant::fromValue(m_interface)); qDebug() << "Graphic object created:" << a << a->property("graphicObject"); diff --git a/shell/qmlpackages/desktop/contents/ui/AppletError.qml b/shell/qmlpackages/desktop/contents/ui/AppletError.qml new file mode 100644 index 000000000..e7318e9bb --- /dev/null +++ b/shell/qmlpackages/desktop/contents/ui/AppletError.qml @@ -0,0 +1,45 @@ +/* + * Copyright 2013 Marco Martin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import QtQuick 2.0 + +import org.kde.plasma.core 0.1 as PlasmaCore +import org.kde.plasma.components 0.1 as PlasmaComponents + +Row { + id: root + + property alias reason: messageText.text + + clip: true + + PlasmaCore.IconItem { + id: icon + anchors.verticalCenter: parent + width: theme.hugeIconSize + height: width + source: "dialog-error" + } + + PlasmaComponents.Label { + id: messageText + anchors.verticalCenter: parent + width: parent.width - icon.width + wrapMode: Text.Wrap + } +} diff --git a/shell/testapplet/contents/ui/main.qml b/shell/testapplet/contents/ui/main.qml index 811632899..08a90bcac 100644 --- a/shell/testapplet/contents/ui/main.qml +++ b/shell/testapplet/contents/ui/main.qml @@ -26,6 +26,8 @@ Rectangle { color: "transparent" width: 100 height: 100 + radius: 10 + smooth: true Column { anchors.centerIn: parent diff --git a/shell/testcontainment/contents/ui/main.qml b/shell/testcontainment/contents/ui/main.qml index 349669a89..7ce7d3daa 100644 --- a/shell/testcontainment/contents/ui/main.qml +++ b/shell/testcontainment/contents/ui/main.qml @@ -116,8 +116,5 @@ Rectangle { Component.onCompleted: { print("Test Containment loaded") print(plasmoid) - for (var i in plasmoid) { - print(i+" "+plasmoid[i]) - } } } \ No newline at end of file