prefer an applet-provided compactRepresentation

if possible, still fallback to a default one
This commit is contained in:
Marco Martin 2013-02-13 21:15:09 +01:00
parent f51895ab91
commit b34b9e9f6a
2 changed files with 15 additions and 2 deletions

View File

@ -417,8 +417,12 @@ void AppletInterface::geometryChanged(const QRectF &newGeometry, const QRectF &o
//build the icon representation //build the icon representation
if (m_compactUiObject) { if (m_compactUiObject) {
QQmlComponent *compactComponent = new QQmlComponent(m_appletScriptEngine->engine(), this); QQmlComponent *compactComponent = m_uiObject.data()->property("compactRepresentation").value<QQmlComponent *>();
compactComponent->loadUrl(QUrl::fromLocalFile(applet()->containment()->corona()->package().filePath("ui", "DefaultCompactRepresentation.qml")));
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()); compactRepresentation = compactComponent->create(m_appletScriptEngine->engine()->rootContext());
if (compactRepresentation) { if (compactRepresentation) {
compactComponent->setParent(compactRepresentation); compactComponent->setParent(compactRepresentation);

View File

@ -29,6 +29,15 @@ Rectangle {
radius: 10 radius: 10
smooth: true smooth: true
property Component compactRepresentation: Component {
Rectangle {
MouseArea {
anchors.fill: parent
onClicked: plasmoid.expanded = !plasmoid.expanded
}
}
}
Column { Column {
anchors.centerIn: parent anchors.centerIn: parent
Text { Text {