Alternatives: Add new applet only after the old one was removed

New applet is now added at the same position as the old one.

CCBUG: 358827

Differential Revision: https://phabricator.kde.org/D1134
wilder-5.14
David Rosca 10 years ago
parent e44468d454
commit 4c6707dbed
  1. 17
      shell/alternativeshelper.cpp

@ -68,19 +68,22 @@ void AlternativesHelper::loadAlternative(const QString &plugin)
return;
}
Plasma::Applet *newApplet = Q_NULLPTR;
//TODO: map the position to containment coordinates
QMetaObject::invokeMethod(contItem, "createApplet", Q_RETURN_ARG(Plasma::Applet *, newApplet), Q_ARG(QString, plugin), Q_ARG(QVariantList, QVariantList()), Q_ARG(QPoint, appletItem->mapToItem(contItem, QPointF(0,0)).toPoint()));
// ensure the global shortcut is moved to the new applet
const QKeySequence &shortcut = m_applet->globalShortcut();
m_applet->setGlobalShortcut(QKeySequence()); // need to unmap the old one first
if (newApplet) {
newApplet->setGlobalShortcut(shortcut);
}
const QPoint newPos = appletItem->mapToItem(contItem, QPointF(0,0)).toPoint();
m_applet->destroy();
connect(m_applet, &QObject::destroyed, [=]() {
Plasma::Applet *newApplet = Q_NULLPTR;
QMetaObject::invokeMethod(contItem, "createApplet", Q_RETURN_ARG(Plasma::Applet *, newApplet), Q_ARG(QString, plugin), Q_ARG(QVariantList, QVariantList()), Q_ARG(QPoint, newPos));
if (newApplet) {
newApplet->setGlobalShortcut(shortcut);
}
});
}
#include "moc_alternativeshelper.cpp"

Loading…
Cancel
Save