track changes in destroyed()

Change-Id: Ibc4dcc64028e1127dd55e7c7d4d73000d2964dab
This commit is contained in:
Marco Martin 2014-10-30 18:05:44 +01:00
parent f870ea1a11
commit 73500516ff
4 changed files with 22 additions and 0 deletions

View File

@ -258,6 +258,7 @@ void Applet::destroy()
}
d->transient = true;
emit destroyedChanged(true);
//FIXME: an animation on leave if !isContainment() would be good again .. which should be handled by the containment class
d->cleanUpAndDelete();
}

View File

@ -383,6 +383,13 @@ Q_SIGNALS:
*/
void statusChanged(Plasma::Types::ItemStatus status);
/**
* Emitted when the applet has been scheduled for destruction
* or the destruction has been undone
* @since 5.4
*/
void destroyedChanged(bool destroyed);
//CONFIGURATION
/**
* Emitted when an applet has changed values in its configuration

View File

@ -232,6 +232,7 @@ void AppletPrivate::askDestroy()
//There is no confirmation anymore for panels removal:
//this needs users feedback
transient = true;
emit q->destroyedChanged(true);
//no parent, but it won't leak, since it will be closed both in case of timeout
//or direct action
deleteNotification = new KNotification("plasmoidDeleted", KNotification::Persistent, 0);
@ -242,6 +243,7 @@ void AppletPrivate::askDestroy()
QObject::connect(deleteNotification.data(), &KNotification::action1Activated,
[=]() {
transient = false;
emit q->destroyedChanged(false);
if (!q->isContainment() && q->containment()) {
//make sure the applets are sorted by id
auto position = std::lower_bound(q->containment()->d->applets.begin(), q->containment()->d->applets.end(), q, [](Plasma::Applet *a1, Plasma::Applet *a2) {
@ -263,6 +265,7 @@ void AppletPrivate::askDestroy()
//If the timer still exists, it meand the undo action was NOT triggered
if (deleteNotificationTimer) {
transient = true;
emit q->destroyedChanged(true);
cleanUpAndDelete();
}
});
@ -279,6 +282,7 @@ void AppletPrivate::askDestroy()
deleteNotification->close();
}
transient = true;
emit q->destroyedChanged(true);
cleanUpAndDelete();
});
deleteNotificationTimer->start();

View File

@ -73,6 +73,11 @@ AppletInterface::AppletInterface(DeclarativeAppletScript *script, const QVariant
connect(applet(), &Plasma::Applet::statusChanged,
this, &AppletInterface::statusChanged);
connect(applet(), &Plasma::Applet::destroyedChanged,
[=] () {
setVisible(!applet()->destroyed());
});
connect(applet(), &Plasma::Applet::activated,
this, &AppletInterface::activated);
@ -125,6 +130,11 @@ AppletInterface::AppletInterface(Plasma::Applet *a, const QVariantList &args, QQ
connect(applet(), &Plasma::Applet::statusChanged,
this, &AppletInterface::statusChanged);
connect(applet(), &Plasma::Applet::destroyedChanged,
[=] () {
setVisible(!applet()->destroyed());
});
connect(appletScript(), &DeclarativeAppletScript::formFactorChanged,
this, &AppletInterface::formFactorChanged);
connect(appletScript(), &DeclarativeAppletScript::locationChanged,