Compare commits

...

1 commit

Author SHA1 Message Date
Nicolas Fella
82aace3c37 WIP: port 2021-11-18 00:12:28 +01:00
8 changed files with 23 additions and 29 deletions

View file

@ -175,9 +175,6 @@ void KdeConnectKcm::deviceSelected(const QModelIndex& current)
disconnect(currentDevice, 0, this, 0); disconnect(currentDevice, 0, this, 0);
} }
//Store previous device config
pluginsConfigChanged();
if (!current.isValid()) { if (!current.isValid()) {
currentDevice = nullptr; currentDevice = nullptr;
kcmUi->deviceInfo->setVisible(false); kcmUi->deviceInfo->setVisible(false);
@ -225,13 +222,8 @@ void KdeConnectKcm::resetCurrentDevice()
void KdeConnectKcm::resetDeviceView() 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->verificationKey->setText(i18n("Key: %1", QString::fromUtf8(currentDevice->verificationKey())));
kcmUi->pluginSelector->setConfigurationArguments(QStringList(currentDevice->id()));
kcmUi->name_label->setText(currentDevice->name()); kcmUi->name_label->setText(currentDevice->name());
setWhenAvailable(currentDevice->isTrusted(), [this](bool trusted) { setWhenAvailable(currentDevice->isTrusted(), [this](bool trusted) {
@ -243,20 +235,22 @@ void KdeConnectKcm::resetDeviceView()
}, this); }, this);
}, this); }, this);
const QList<KPluginInfo> pluginInfo = KPluginInfo::fromMetaData(KPluginLoader::findPlugins(QStringLiteral("kdeconnect/"))); const QVector<KPluginMetaData> pluginInfo = KPluginLoader::findPlugins(QStringLiteral("kdeconnect/"));
QList<KPluginInfo> availablePluginInfo; QVector<KPluginMetaData> availablePluginInfo;
m_oldSupportedPluginNames = currentDevice->supportedPlugins(); m_oldSupportedPluginNames = currentDevice->supportedPlugins();
for (auto it = pluginInfo.cbegin(), itEnd = pluginInfo.cend(); it!=itEnd; ++it) { 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); availablePluginInfo.append(*it);
} }
} }
KSharedConfigPtr deviceConfig = KSharedConfig::openConfig(currentDevice->pluginsConfigFile()); KSharedConfigPtr deviceConfig = KSharedConfig::openConfig(currentDevice->pluginsConfigFile());
kcmUi->pluginSelector->addPlugins(availablePluginInfo, KPluginSelector::ReadConfigFile, i18n("Available plugins"), QString(), deviceConfig); kcmUi->pluginSelector->clear();
connect(kcmUi->pluginSelector, &KPluginSelector::changed, this, &KdeConnectKcm::pluginsConfigChanged); 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() 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 //Store previous selection
if (!currentDevice) return; 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(); kcmUi->pluginSelector->save();
currentDevice = auxCurrentDevice;
currentDevice->reloadPlugins(); currentDevice->reloadPlugins();
} }
void KdeConnectKcm::save() void KdeConnectKcm::save()
{ {
pluginsConfigChanged();
KCModule::save(); KCModule::save();
} }

View file

@ -36,7 +36,7 @@ private:
private Q_SLOTS: private Q_SLOTS:
void deviceSelected(const QModelIndex& current); void deviceSelected(const QModelIndex& current);
void requestPair(); void requestPair();
void pluginsConfigChanged(); void pluginsConfigChanged(const QString &id, bool enabled);
void sendPing(); void sendPing();
void resetSelection(); void resetSelection();
void trustedChanged(bool); void trustedChanged(bool);

View file

@ -315,7 +315,7 @@
<widget class="KMessageWidget" name="messages" native="true"/> <widget class="KMessageWidget" name="messages" native="true"/>
</item> </item>
<item> <item>
<widget class="KPluginSelector" name="pluginSelector" native="true"> <widget class="KPluginWidget" name="pluginSelector" native="true">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -374,9 +374,9 @@
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>
<class>KPluginSelector</class> <class>KPluginWidget</class>
<extends>QWidget</extends> <extends>QWidget</extends>
<header>kpluginselector.h</header> <header>kpluginwidget.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget> <customwidget>

View file

@ -127,5 +127,6 @@
}, },
"X-KdeConnect-SupportedPacketType": [ "X-KdeConnect-SupportedPacketType": [
"kdeconnect.findmyphone.request" "kdeconnect.findmyphone.request"
] ],
"X-KDE-ConfigModule": "kdeconnect_findthisdevice_config"
} }

View file

@ -144,5 +144,6 @@
}, },
"X-KdeConnect-SupportedPacketType": [ "X-KdeConnect-SupportedPacketType": [
"kdeconnect.telephony" "kdeconnect.telephony"
] ],
"X-KDE-ConfigModule": "kdeconnect_pausemusic_config"
} }

View file

@ -193,5 +193,6 @@
], ],
"X-KdeConnect-SupportedPacketType": [ "X-KdeConnect-SupportedPacketType": [
"kdeconnect.runcommand.request" "kdeconnect.runcommand.request"
] ],
"X-KDE-ConfigModule": "kdeconnect_runcommand_config"
} }

View file

@ -93,5 +93,6 @@
], ],
"X-KdeConnect-SupportedPacketType": [ "X-KdeConnect-SupportedPacketType": [
"kdeconnect.notification.request" "kdeconnect.notification.request"
] ],
"X-KDE-ConfigModule": "kdeconnect_sendnotifications_config"
} }

View file

@ -149,5 +149,6 @@
], ],
"X-KdeConnect-SupportedPacketType": [ "X-KdeConnect-SupportedPacketType": [
"kdeconnect.share.request" "kdeconnect.share.request"
] ],
"X-KDE-ConfigModule": "kdeconnect_share_config"
} }