From 22ba8186f083fd8d7ff6612825234ab63c2b7a5e Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Thu, 25 Aug 2016 15:55:18 +0100 Subject: [PATCH] When marking a containment as deleted, also mark all sub-applets as deleted - fixes system tray container configs not being deleted This allows a custom applet to do cleanup (like the system tray, to delete the inner containment) REVIEW: 128754 --- src/plasma/applet.cpp | 3 +-- src/plasma/private/applet_p.cpp | 25 ++++++++++++++++--------- src/plasma/private/applet_p.h | 1 + 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/plasma/applet.cpp b/src/plasma/applet.cpp index 58c794fa3..5e278dc69 100644 --- a/src/plasma/applet.cpp +++ b/src/plasma/applet.cpp @@ -261,8 +261,7 @@ void Applet::destroy() return; //don't double delete } - d->transient = true; - emit destroyedChanged(true); + d->setDestroyed(true); //FIXME: an animation on leave if !isContainment() would be good again .. which should be handled by the containment class d->cleanUpAndDelete(); } diff --git a/src/plasma/private/applet_p.cpp b/src/plasma/private/applet_p.cpp index b0f9edb56..0f37fe5e3 100644 --- a/src/plasma/private/applet_p.cpp +++ b/src/plasma/private/applet_p.cpp @@ -229,6 +229,20 @@ void AppletPrivate::cleanUpAndDelete() q->deleteLater(); } +void AppletPrivate::setDestroyed(bool destroyed) +{ + transient = destroyed; + emit q->destroyedChanged(destroyed); + //when an applet gets transient, it's "systemimmutable" + emit q->immutabilityChanged(q->immutability()); + + Plasma::Containment *asContainment = qobject_cast(q); + if (asContainment) { + foreach(Applet *a , asContainment->applets()) + a->d->setDestroyed(destroyed); + } +} + void AppletPrivate::askDestroy() { if (q->immutability() != Types::Mutable || !started) { @@ -240,10 +254,7 @@ void AppletPrivate::askDestroy() } else { //There is no confirmation anymore for panels removal: //this needs users feedback - transient = true; - emit q->destroyedChanged(true); - //when an applet gets transient, it's "systemimmutable" - emit q->immutabilityChanged(q->immutability()); + setDestroyed(true); //no parent, but it won't leak, since it will be closed both in case of timeout //or direct action deleteNotification = new KNotification(QStringLiteral("plasmoidDeleted")); @@ -270,7 +281,7 @@ void AppletPrivate::askDestroy() deleteNotification->setActions(actions); QObject::connect(deleteNotification.data(), &KNotification::action1Activated, [=]() { - transient = false; + setDestroyed(false); if (!q->isContainment() && q->containment()) { Plasma::Applet *containmentApplet = static_cast(q->containment()); if (containmentApplet && containmentApplet->d->deleteNotificationTimer) { @@ -288,9 +299,6 @@ void AppletPrivate::askDestroy() q->containment()->d->applets.insert(position, q); emit q->containment()->appletAdded(q); } - emit q->destroyedChanged(false); - //when an applet gets transient, it's "systemimmutable" - emit q->immutabilityChanged(q->immutability()); if (deleteNotification) { deleteNotification->close(); } else if (deleteNotificationTimer) { @@ -303,7 +311,6 @@ void AppletPrivate::askDestroy() [=]() { //If the timer still exists, it means the undo action was NOT triggered if (transient) { - emit q->destroyedChanged(true); cleanUpAndDelete(); } if (deleteNotificationTimer) { diff --git a/src/plasma/private/applet_p.h b/src/plasma/private/applet_p.h index 7a7dc3d4b..c3fe1d2e3 100644 --- a/src/plasma/private/applet_p.h +++ b/src/plasma/private/applet_p.h @@ -51,6 +51,7 @@ public: void init(const QString &packagePath = QString(), const QVariantList &args = QVariantList()); + void setDestroyed(bool destroyed); void askDestroy(); virtual void cleanUpAndDelete();