diff --git a/src/plasma/applet.cpp b/src/plasma/applet.cpp index 5cb638451..8546a6533 100644 --- a/src/plasma/applet.cpp +++ b/src/plasma/applet.cpp @@ -255,20 +255,6 @@ void Applet::destroy() return; //don't double delete } - if (isContainment()) { - QMessageBox *box = new QMessageBox(QMessageBox::Warning, i18nc("@title:window %1 is the name of the containment", "Remove %1", title()), i18nc("%1 is the name of the containment", "Do you really want to remove this %1?", title()), QMessageBox::StandardButtons( QMessageBox::Yes | QMessageBox::No )); - box->setWindowFlags((Qt::WindowFlags)(box->windowFlags() | Qt::WA_DeleteOnClose)); - box->open(); - - connect(box->button(QMessageBox::Yes), &QAbstractButton::clicked, - [=] () { - d->transient = true; - d->cleanUpAndDelete(); - }); - - return; - } - d->transient = true; //FIXME: an animation on leave if !isContainment() would be good again .. which should be handled by the containment class d->cleanUpAndDelete(); @@ -480,7 +466,7 @@ void Applet::flushPendingConstraintsEvents() if (closeApplet) { closeApplet->setEnabled(unlocked); closeApplet->setVisible(unlocked); - connect(closeApplet, SIGNAL(triggered(bool)), this, SLOT(destroy()), Qt::UniqueConnection); + connect(closeApplet, SIGNAL(triggered(bool)), this, SLOT(askDestroy()), Qt::UniqueConnection); } QAction *configAction = d->actions->action("configure"); diff --git a/src/plasma/applet.h b/src/plasma/applet.h index 20485b98f..7784ae5b0 100644 --- a/src/plasma/applet.h +++ b/src/plasma/applet.h @@ -589,6 +589,7 @@ class PLASMA_EXPORT Applet : public QObject Applet(const QString &packagePath, uint appletId); Q_PRIVATE_SLOT(d, void cleanUpAndDelete()) + Q_PRIVATE_SLOT(d, void askDestroy()) Q_PRIVATE_SLOT(d, void updateShortcuts()) Q_PRIVATE_SLOT(d, void globalShortcutChanged()) Q_PRIVATE_SLOT(d, void propagateConfigChanged()) diff --git a/src/plasma/private/applet_p.cpp b/src/plasma/private/applet_p.cpp index 26d48e306..d5d8c5917 100644 --- a/src/plasma/private/applet_p.cpp +++ b/src/plasma/private/applet_p.cpp @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -180,6 +181,30 @@ void AppletPrivate::showConfigurationRequiredMessage(bool show, const QString &r Q_UNUSED(reason) } +void AppletPrivate::askDestroy() +{ + if (q->immutability() != Types::Mutable || transient || !started) { + return; //don't double delete + } + + if (q->isContainment()) { + QMessageBox *box = new QMessageBox(QMessageBox::Warning, i18nc("@title:window %1 is the name of the containment", "Remove %1", q->title()), i18nc("%1 is the name of the containment", "Do you really want to remove this %1?", q->title()), QMessageBox::StandardButtons( QMessageBox::Yes | QMessageBox::No )); + box->setWindowFlags((Qt::WindowFlags)(box->windowFlags() | Qt::WA_DeleteOnClose)); + box->open(); + + QObject::connect(box->button(QMessageBox::Yes), &QAbstractButton::clicked, + [=] () { + transient = true; + cleanUpAndDelete(); + }); + + return; + } + + transient = true; + cleanUpAndDelete(); +} + void AppletPrivate::globalShortcutChanged() { if (!activationAction) { diff --git a/src/plasma/private/applet_p.h b/src/plasma/private/applet_p.h index a14a84431..a9a2e4c8c 100644 --- a/src/plasma/private/applet_p.h +++ b/src/plasma/private/applet_p.h @@ -50,6 +50,7 @@ public: // the interface virtual void showConfigurationRequiredMessage(bool show, const QString &reason); + void askDestroy(); virtual void cleanUpAndDelete(); // put all setup routines for script here. at this point we can assume that