diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp index 9bf227897..5ed31027e 100644 --- a/kcm/kcm.cpp +++ b/kcm/kcm.cpp @@ -175,9 +175,6 @@ void KdeConnectKcm::deviceSelected(const QModelIndex& current) disconnect(currentDevice, 0, this, 0); } - //Store previous device config - pluginsConfigChanged(); - if (!current.isValid()) { currentDevice = nullptr; kcmUi->deviceInfo->setVisible(false); @@ -225,13 +222,8 @@ void KdeConnectKcm::resetCurrentDevice() void KdeConnectKcm::resetDeviceView() { - //KPluginSelector has no way to remove a list of plugins and load another, so we need to destroy and recreate it each time - delete kcmUi->pluginSelector; - kcmUi->pluginSelector = new KPluginSelector(this); - kcmUi->deviceInfo_layout->addWidget(kcmUi->pluginSelector); kcmUi->verificationKey->setText(i18n("Key: %1", QString::fromUtf8(currentDevice->verificationKey()))); - kcmUi->pluginSelector->setConfigurationArguments(QStringList(currentDevice->id())); kcmUi->name_label->setText(currentDevice->name()); setWhenAvailable(currentDevice->isTrusted(), [this](bool trusted) { @@ -243,20 +235,22 @@ void KdeConnectKcm::resetDeviceView() }, this); }, this); - const QList pluginInfo = KPluginInfo::fromMetaData(KPluginLoader::findPlugins(QStringLiteral("kdeconnect/"))); - QList availablePluginInfo; + const QVector pluginInfo = KPluginLoader::findPlugins(QStringLiteral("kdeconnect/")); + QVector availablePluginInfo; m_oldSupportedPluginNames = currentDevice->supportedPlugins(); for (auto it = pluginInfo.cbegin(), itEnd = pluginInfo.cend(); it!=itEnd; ++it) { - if (m_oldSupportedPluginNames.contains(it->pluginName())) { + if (m_oldSupportedPluginNames.contains(it->pluginId())) { availablePluginInfo.append(*it); } } KSharedConfigPtr deviceConfig = KSharedConfig::openConfig(currentDevice->pluginsConfigFile()); - kcmUi->pluginSelector->addPlugins(availablePluginInfo, KPluginSelector::ReadConfigFile, i18n("Available plugins"), QString(), deviceConfig); - connect(kcmUi->pluginSelector, &KPluginSelector::changed, this, &KdeConnectKcm::pluginsConfigChanged); - + kcmUi->pluginSelector->clear(); + kcmUi->pluginSelector->setConfigurationArguments(QStringList(currentDevice->id())); + kcmUi->pluginSelector->addPlugins(availablePluginInfo, i18n("Available plugins")); + kcmUi->pluginSelector->setConfig(deviceConfig->group("Plugins")); + connect(kcmUi->pluginSelector, &KPluginWidget::changed, this, &KdeConnectKcm::pluginsConfigChanged); } void KdeConnectKcm::requestPair() @@ -342,22 +336,17 @@ void KdeConnectKcm::setCurrentDeviceTrusted(KdeConnectKcm::TrustStatus trusted) } } -void KdeConnectKcm::pluginsConfigChanged() +void KdeConnectKcm::pluginsConfigChanged(const QString &id, bool enabled) { //Store previous selection if (!currentDevice) return; - DeviceDbusInterface* auxCurrentDevice = currentDevice; - currentDevice = nullptr; //HACK to avoid infinite recursion (for some reason calling save on pluginselector emits changed) kcmUi->pluginSelector->save(); - currentDevice = auxCurrentDevice; - currentDevice->reloadPlugins(); } void KdeConnectKcm::save() { - pluginsConfigChanged(); KCModule::save(); } diff --git a/kcm/kcm.h b/kcm/kcm.h index 2c8d86bfc..5f52c4040 100644 --- a/kcm/kcm.h +++ b/kcm/kcm.h @@ -36,7 +36,7 @@ private: private Q_SLOTS: void deviceSelected(const QModelIndex& current); void requestPair(); - void pluginsConfigChanged(); + void pluginsConfigChanged(const QString &id, bool enabled); void sendPing(); void resetSelection(); void trustedChanged(bool); diff --git a/kcm/kcm.ui b/kcm/kcm.ui index 5ed440ed5..6de99fe51 100644 --- a/kcm/kcm.ui +++ b/kcm/kcm.ui @@ -315,7 +315,7 @@ - + 0 @@ -374,9 +374,9 @@ - KPluginSelector + KPluginWidget QWidget -
kpluginselector.h
+
kpluginwidget.h
1
diff --git a/plugins/findthisdevice/kdeconnect_findthisdevice.json b/plugins/findthisdevice/kdeconnect_findthisdevice.json index 0154ba7f8..8f52ac543 100644 --- a/plugins/findthisdevice/kdeconnect_findthisdevice.json +++ b/plugins/findthisdevice/kdeconnect_findthisdevice.json @@ -127,5 +127,6 @@ }, "X-KdeConnect-SupportedPacketType": [ "kdeconnect.findmyphone.request" - ] + ], + "X-KDE-ConfigModule": "kdeconnect_findthisdevice_config" } diff --git a/plugins/pausemusic/kdeconnect_pausemusic.json b/plugins/pausemusic/kdeconnect_pausemusic.json index 011011c4d..044cf78c3 100644 --- a/plugins/pausemusic/kdeconnect_pausemusic.json +++ b/plugins/pausemusic/kdeconnect_pausemusic.json @@ -144,5 +144,6 @@ }, "X-KdeConnect-SupportedPacketType": [ "kdeconnect.telephony" - ] + ], + "X-KDE-ConfigModule": "kdeconnect_pausemusic_config" } diff --git a/plugins/runcommand/kdeconnect_runcommand.json b/plugins/runcommand/kdeconnect_runcommand.json index 1b4165b06..a7aa33c8b 100644 --- a/plugins/runcommand/kdeconnect_runcommand.json +++ b/plugins/runcommand/kdeconnect_runcommand.json @@ -193,5 +193,6 @@ ], "X-KdeConnect-SupportedPacketType": [ "kdeconnect.runcommand.request" - ] + ], + "X-KDE-ConfigModule": "kdeconnect_runcommand_config" } diff --git a/plugins/sendnotifications/kdeconnect_sendnotifications.json.in b/plugins/sendnotifications/kdeconnect_sendnotifications.json.in index 2de23f506..c63f9fa3e 100644 --- a/plugins/sendnotifications/kdeconnect_sendnotifications.json.in +++ b/plugins/sendnotifications/kdeconnect_sendnotifications.json.in @@ -93,5 +93,6 @@ ], "X-KdeConnect-SupportedPacketType": [ "kdeconnect.notification.request" - ] + ], + "X-KDE-ConfigModule": "kdeconnect_sendnotifications_config" } diff --git a/plugins/share/kdeconnect_share.json b/plugins/share/kdeconnect_share.json index c4214aa4e..1b8d75808 100644 --- a/plugins/share/kdeconnect_share.json +++ b/plugins/share/kdeconnect_share.json @@ -149,5 +149,6 @@ ], "X-KdeConnect-SupportedPacketType": [ "kdeconnect.share.request" - ] + ], + "X-KDE-ConfigModule": "kdeconnect_share_config" }