From b34b9e9f6a56aa26af1619e246920f76ac83f5c5 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 13 Feb 2013 21:15:09 +0100 Subject: [PATCH] prefer an applet-provided compactRepresentation if possible, still fallback to a default one --- scriptengines/qml/plasmoid/appletinterface.cpp | 8 ++++++-- shell/testapplet/contents/ui/main.qml | 9 +++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/scriptengines/qml/plasmoid/appletinterface.cpp b/scriptengines/qml/plasmoid/appletinterface.cpp index 925278d12..237f70e55 100644 --- a/scriptengines/qml/plasmoid/appletinterface.cpp +++ b/scriptengines/qml/plasmoid/appletinterface.cpp @@ -417,8 +417,12 @@ void AppletInterface::geometryChanged(const QRectF &newGeometry, const QRectF &o //build the icon representation if (m_compactUiObject) { - QQmlComponent *compactComponent = new QQmlComponent(m_appletScriptEngine->engine(), this); - compactComponent->loadUrl(QUrl::fromLocalFile(applet()->containment()->corona()->package().filePath("ui", "DefaultCompactRepresentation.qml"))); + QQmlComponent *compactComponent = m_uiObject.data()->property("compactRepresentation").value(); + + if (!compactComponent) { + compactComponent = new QQmlComponent(m_appletScriptEngine->engine(), this); + compactComponent->loadUrl(QUrl::fromLocalFile(applet()->containment()->corona()->package().filePath("ui", "DefaultCompactRepresentation.qml"))); + } compactRepresentation = compactComponent->create(m_appletScriptEngine->engine()->rootContext()); if (compactRepresentation) { compactComponent->setParent(compactRepresentation); diff --git a/shell/testapplet/contents/ui/main.qml b/shell/testapplet/contents/ui/main.qml index 7454017cb..87420fccf 100644 --- a/shell/testapplet/contents/ui/main.qml +++ b/shell/testapplet/contents/ui/main.qml @@ -29,6 +29,15 @@ Rectangle { radius: 10 smooth: true + property Component compactRepresentation: Component { + Rectangle { + MouseArea { + anchors.fill: parent + onClicked: plasmoid.expanded = !plasmoid.expanded + } + } + } + Column { anchors.centerIn: parent Text {