drop QwaitingDeletionStatus
emit appletRemoved and appletAdded instead, making the graphics representation (almost) just work Change-Id: I481dbbb4dbf7d01a121b92511410dfee79b16469
This commit is contained in:
parent
781d30cfef
commit
f870ea1a11
@ -104,8 +104,7 @@ Applet::Applet(const QString &packagePath, uint appletId)
|
||||
|
||||
Applet::~Applet()
|
||||
{
|
||||
if (status() == Types::AwaitingDeletionStatus) {
|
||||
d->transient = true;
|
||||
if (d->transient) {
|
||||
d->resetConfigurationObject();
|
||||
}
|
||||
//let people know that i will die
|
||||
|
@ -254,7 +254,6 @@ public:
|
||||
NeedsAttentionStatus = 3, /**< The Item needs attention **/
|
||||
RequiresAttentionStatus = 4, /**< The Item needs persistent attention **/
|
||||
AcceptingInputStatus = 5, /**< The Item is accepting input **/
|
||||
AwaitingDeletionStatus = -1 /**< @since 5.3 The user asked to delete this applet*/
|
||||
};
|
||||
Q_ENUMS(ItemStatus)
|
||||
|
||||
|
@ -62,7 +62,6 @@ AppletPrivate::AppletPrivate(KService::Ptr service, const KPluginInfo *info, int
|
||||
actions(AppletPrivate::defaultActions(applet)),
|
||||
activationAction(0),
|
||||
itemStatus(Types::UnknownStatus),
|
||||
oldItemStatus(Types::UnknownStatus),
|
||||
modificationsTimer(Q_NULLPTR),
|
||||
deleteNotificationTimer(Q_NULLPTR),
|
||||
hasConfigurationInterface(false),
|
||||
@ -227,14 +226,12 @@ void AppletPrivate::askDestroy()
|
||||
return; //don't double delete
|
||||
}
|
||||
|
||||
if (itemStatus == Types::AwaitingDeletionStatus) {
|
||||
transient = true;
|
||||
if (transient) {
|
||||
cleanUpAndDelete();
|
||||
} else {
|
||||
//There is no confirmation anymore for panels removal:
|
||||
//this needs users feedback
|
||||
oldItemStatus = itemStatus;
|
||||
q->setStatus(Types::AwaitingDeletionStatus);
|
||||
transient = 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);
|
||||
@ -244,7 +241,15 @@ void AppletPrivate::askDestroy()
|
||||
deleteNotification->setActions(actions);
|
||||
QObject::connect(deleteNotification.data(), &KNotification::action1Activated,
|
||||
[=]() {
|
||||
q->setStatus(qMax(oldItemStatus, Types::UnknownStatus));
|
||||
transient = 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) {
|
||||
return a1->id() < a2->id();
|
||||
});
|
||||
q->containment()->d->applets.insert(position, q);
|
||||
emit q->containment()->appletAdded(q);
|
||||
}
|
||||
if (deleteNotification) {
|
||||
deleteNotification->close();
|
||||
}
|
||||
@ -278,6 +283,10 @@ void AppletPrivate::askDestroy()
|
||||
});
|
||||
deleteNotificationTimer->start();
|
||||
}
|
||||
if (!q->isContainment() && q->containment()) {
|
||||
q->containment()->d->applets.removeAll(q);
|
||||
emit q->containment()->appletRemoved(q);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,6 @@ public:
|
||||
QAction *activationAction;
|
||||
|
||||
Types::ItemStatus itemStatus;
|
||||
Types::ItemStatus oldItemStatus;
|
||||
|
||||
// timerEvent bookkeeping
|
||||
QBasicTimer constraintsTimer;
|
||||
|
@ -115,9 +115,6 @@ void ContainmentPrivate::configChanged()
|
||||
|
||||
void ContainmentPrivate::checkStatus(Plasma::Types::ItemStatus appletStatus)
|
||||
{
|
||||
if (appletStatus == Types::AwaitingDeletionStatus) {
|
||||
return;
|
||||
}
|
||||
//qDebug() << "================== "<< appletStatus << q->status();
|
||||
if (appletStatus == q->status()) {
|
||||
emit q->statusChanged(appletStatus);
|
||||
|
@ -369,7 +369,10 @@ private:
|
||||
Plasma::Types::BackgroundHints m_backgroundHints;
|
||||
bool m_busy : 1;
|
||||
bool m_hideOnDeactivate : 1;
|
||||
|
||||
friend class ContainmentInterface;
|
||||
//This is used by ContainmentInterface
|
||||
QPointF m_positionBeforeRemoval;
|
||||
};
|
||||
|
||||
QML_DECLARE_TYPEINFO(AppletInterface, QML_HAS_ATTACHED_PROPERTIES)
|
||||
|
@ -554,8 +554,8 @@ void ContainmentInterface::appletAddedForward(Plasma::Applet *applet)
|
||||
return;
|
||||
}
|
||||
|
||||
QObject *appletGraphicObject = applet->property("_plasma_graphicObject").value<QObject *>();
|
||||
QObject *contGraphicObject = m_containment->property("_plasma_graphicObject").value<QObject *>();
|
||||
AppletInterface *appletGraphicObject = applet->property("_plasma_graphicObject").value<AppletInterface *>();
|
||||
AppletInterface *contGraphicObject = m_containment->property("_plasma_graphicObject").value<AppletInterface *>();
|
||||
|
||||
// qDebug() << "Applet added on containment:" << m_containment->title() << contGraphicObject
|
||||
// << "Applet: " << applet << applet->title() << appletGraphicObject;
|
||||
@ -572,14 +572,15 @@ void ContainmentInterface::appletAddedForward(Plasma::Applet *applet)
|
||||
}
|
||||
|
||||
m_appletInterfaces << appletGraphicObject;
|
||||
emit appletAdded(appletGraphicObject, -1, -1);
|
||||
emit appletAdded(appletGraphicObject, appletGraphicObject->m_positionBeforeRemoval.x(), appletGraphicObject->m_positionBeforeRemoval.y());
|
||||
emit appletsChanged();
|
||||
}
|
||||
|
||||
void ContainmentInterface::appletRemovedForward(Plasma::Applet *applet)
|
||||
{
|
||||
QObject *appletGraphicObject = applet->property("_plasma_graphicObject").value<QObject *>();
|
||||
AppletInterface *appletGraphicObject = applet->property("_plasma_graphicObject").value<AppletInterface *>();
|
||||
m_appletInterfaces.removeAll(appletGraphicObject);
|
||||
appletGraphicObject->m_positionBeforeRemoval = appletGraphicObject->mapToItem(this, QPointF());
|
||||
emit appletRemoved(appletGraphicObject);
|
||||
emit appletsChanged();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user