Commit b9a3005f authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

Restore old applet configuration after switching to alternative

In task manager, switching between icon task manager and text task manager
loses the old settings, which is inconvenient. This copies the old
configuration to the new applet to fix that behavior.

BUG: 355588
FIXED-IN: 5.26
parent 02196b1d
Pipeline #194408 failed with stage
in 5 minutes and 5 seconds
......@@ -9,6 +9,8 @@
#include <QQmlContext>
#include <QQmlEngine>
#include <KConfigLoader>
#include <Plasma/Containment>
#include <Plasma/PluginLoader>
......@@ -60,21 +62,23 @@ void AlternativesHelper::loadAlternative(const QString &plugin)
const QPoint newPos = appletItem->mapToItem(contItem, QPointF(0, 0)).toPoint();
m_applet->destroy();
Plasma::Applet *newApplet = 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);
KConfigGroup newCg(newApplet->config());
m_applet->config().copyTo(&newCg);
// To let ConfigPropertyMap reload its config
Q_EMIT newApplet->configScheme()->configChanged();
}
connect(m_applet, &QObject::destroyed, contItem, [=]() {
Plasma::Applet *newApplet = 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);
}
});
m_applet->destroy();
}
#include "moc_alternativeshelper.cpp"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment