From a13924740305ddaef64c150b51d00b7f1ce06aba Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 15 Feb 2013 18:07:38 +0100 Subject: [PATCH] correctly emit appletRemoved applet remove animation At the moment is possible only to animate the disappearance of the background, the applet is immediately deleted. how could be possible to animate the applet as well? (the graphic object should get to live more than Applet* and AppletScript* themselves) --- src/plasma/containment.cpp | 2 +- src/plasma/private/applet_p.cpp | 6 ++++++ .../testcontainment/contents/ui/main.qml | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/plasma/containment.cpp b/src/plasma/containment.cpp index 037a640ee..e6885298d 100644 --- a/src/plasma/containment.cpp +++ b/src/plasma/containment.cpp @@ -534,7 +534,7 @@ void Containment::addApplet(Applet *applet, const QPointF &pos) connect(applet, SIGNAL(configNeedsSaving()), this, SIGNAL(configNeedsSaving())); connect(applet, SIGNAL(releaseVisualFocus()), this, SIGNAL(releaseVisualFocus())); - connect(applet, SIGNAL(appletDeleted(Plasma::Applet*)), this, SLOT(appletDestroyed(Plasma::Applet*))); + connect(applet, SIGNAL(appletDeleted(Plasma::Applet*)), this, SLOT(appletDeleted(Plasma::Applet*))); connect(applet, SIGNAL(statusChanged(Plasma::ItemStatus)), this, SLOT(checkStatus(Plasma::ItemStatus))); connect(applet, SIGNAL(activate()), this, SIGNAL(activate())); diff --git a/src/plasma/private/applet_p.cpp b/src/plasma/private/applet_p.cpp index e09cb15cc..1dbea570d 100644 --- a/src/plasma/private/applet_p.cpp +++ b/src/plasma/private/applet_p.cpp @@ -172,6 +172,12 @@ void AppletPrivate::cleanUpAndDelete() resetConfigurationObject(); + if (isContainment) { + // prematurely emit our destruction if we are a Containment, + // giving Corona a chance to remove this Containment from its collection + emit q->QObject::destroyed(q); + } + q->deleteLater(); } diff --git a/src/shell/containments/testcontainment/contents/ui/main.qml b/src/shell/containments/testcontainment/contents/ui/main.qml index b869b47ae..67459f6df 100644 --- a/src/shell/containments/testcontainment/contents/ui/main.qml +++ b/src/shell/containments/testcontainment/contents/ui/main.qml @@ -52,6 +52,11 @@ Item { height: large + frame.margins.top + frame.margins.bottom property alias applet: appletContainer.children + onAppletChanged: { + if (appletContainer.children.length == 0) { + killAnim.running = true + } + } property int small: 90 property int large: 400 @@ -102,6 +107,16 @@ Item { running: visible anchors.centerIn: parent } + SequentialAnimation { + id: killAnim + NumberAnimation { + target: frame + properties: "scale" + to: 0 + duration: 250 + } + ScriptAction { script: frame.destroy()} + } } }