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
wilder-5.26
Fushan Wen 4 years ago
parent 02196b1de5
commit b9a3005f39
  1. 12
      shell/alternativeshelper.cpp

@ -9,6 +9,8 @@
#include <QQmlContext> #include <QQmlContext>
#include <QQmlEngine> #include <QQmlEngine>
#include <KConfigLoader>
#include <Plasma/Containment> #include <Plasma/Containment>
#include <Plasma/PluginLoader> #include <Plasma/PluginLoader>
@ -60,9 +62,6 @@ void AlternativesHelper::loadAlternative(const QString &plugin)
const QPoint newPos = appletItem->mapToItem(contItem, QPointF(0, 0)).toPoint(); const QPoint newPos = appletItem->mapToItem(contItem, QPointF(0, 0)).toPoint();
m_applet->destroy();
connect(m_applet, &QObject::destroyed, contItem, [=]() {
Plasma::Applet *newApplet = nullptr; Plasma::Applet *newApplet = nullptr;
QMetaObject::invokeMethod(contItem, QMetaObject::invokeMethod(contItem,
"createApplet", "createApplet",
@ -73,8 +72,13 @@ void AlternativesHelper::loadAlternative(const QString &plugin)
if (newApplet) { if (newApplet) {
newApplet->setGlobalShortcut(shortcut); newApplet->setGlobalShortcut(shortcut);
KConfigGroup newCg(newApplet->config());
m_applet->config().copyTo(&newCg);
// To let ConfigPropertyMap reload its config
Q_EMIT newApplet->configScheme()->configChanged();
} }
});
m_applet->destroy();
} }
#include "moc_alternativeshelper.cpp" #include "moc_alternativeshelper.cpp"

Loading…
Cancel
Save