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
This commit is contained in:
David Edmundson 2016-08-25 15:55:18 +01:00 committed by David Edmundson
parent 7bcd088d7d
commit 22ba8186f0
3 changed files with 18 additions and 11 deletions

View File

@ -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();
}

View File

@ -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<Plasma::Containment *>(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<Plasma::Applet *>(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) {

View File

@ -51,6 +51,7 @@ public:
void init(const QString &packagePath = QString(), const QVariantList &args = QVariantList());
void setDestroyed(bool destroyed);
void askDestroy();
virtual void cleanUpAndDelete();