Let the KPluginSelector react to changes in the plugin configuration
Mainly whenever the remote capabilities change. Reviewed by The Vaca Man
This commit is contained in:
parent
b101e828a4
commit
a0da8ba858
3 changed files with 32 additions and 32 deletions
|
@ -120,28 +120,29 @@ void Device::reloadPlugins()
|
|||
|
||||
//Code borrowed from KWin
|
||||
foreach (const QString& pluginName, loader->getPluginList()) {
|
||||
if (isPluginEnabled(pluginName)) {
|
||||
KdeConnectPlugin* plugin = m_plugins.take(pluginName);
|
||||
|
||||
const KPluginMetaData service = loader->getPluginInfo(pluginName);
|
||||
QSet<QString> incomingInterfaces = KPluginMetaData::readStringList(service.rawData(), "X-KdeConnect-SupportedPackageType").toSet();
|
||||
QSet<QString> outgoingInterfaces = KPluginMetaData::readStringList(service.rawData(), "X-KdeConnect-OutgoingPackageType").toSet();
|
||||
const KPluginMetaData service = loader->getPluginInfo(pluginName);
|
||||
const QSet<QString> incomingInterfaces = KPluginMetaData::readStringList(service.rawData(), "X-KdeConnect-SupportedPackageType").toSet();
|
||||
const QSet<QString> outgoingInterfaces = KPluginMetaData::readStringList(service.rawData(), "X-KdeConnect-OutgoingPackageType").toSet();
|
||||
|
||||
const bool pluginEnabled = isPluginEnabled(pluginName);
|
||||
if (pluginEnabled)
|
||||
supportedIncomingInterfaces += incomingInterfaces;
|
||||
|
||||
//If we don't find intersection with the received on one end and the sent on the other, we don't
|
||||
//let the plugin stay
|
||||
//Also, if no capabilities are specified on the other end, we don't apply this optimizaton, as
|
||||
//we assume that the other client doesn't know about capabilities.
|
||||
if ((!m_incomingCapabilities.isEmpty() || !m_outgoingCapabilities.isEmpty())
|
||||
&& (m_incomingCapabilities & outgoingInterfaces).isEmpty()
|
||||
&& (m_outgoingCapabilities & incomingInterfaces).isEmpty()
|
||||
) {
|
||||
qCWarning(KDECONNECT_CORE) << "not loading " << pluginName << "because of unmatched capabilities";
|
||||
delete plugin;
|
||||
unsupportedPlugins.append(pluginName);
|
||||
continue;
|
||||
}
|
||||
//If we don't find intersection with the received on one end and the sent on the other, we don't
|
||||
//let the plugin stay
|
||||
//Also, if no capabilities are specified on the other end, we don't apply this optimizaton, as
|
||||
//we assume that the other client doesn't know about capabilities.
|
||||
if ((!m_incomingCapabilities.isEmpty() || !m_outgoingCapabilities.isEmpty())
|
||||
&& (m_incomingCapabilities & outgoingInterfaces).isEmpty()
|
||||
&& (m_outgoingCapabilities & incomingInterfaces).isEmpty()
|
||||
) {
|
||||
qCWarning(KDECONNECT_CORE) << "not loading " << pluginName << "because of unmatched capabilities";
|
||||
unsupportedPlugins.append(pluginName);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pluginEnabled) {
|
||||
KdeConnectPlugin* plugin = m_plugins.take(pluginName);
|
||||
|
||||
if (!plugin) {
|
||||
plugin = loader->instantiatePluginForDevice(pluginName, this);
|
||||
|
|
24
kcm/kcm.cpp
24
kcm/kcm.cpp
|
@ -153,14 +153,8 @@ void KdeConnectKcm::resetSelection()
|
|||
|
||||
void KdeConnectKcm::deviceSelected(const QModelIndex& current)
|
||||
{
|
||||
|
||||
kcmUi->noDevicePlaceholder->setVisible(false);
|
||||
|
||||
if (currentDevice) {
|
||||
disconnect(currentDevice,SIGNAL(pairingChanged(bool)),
|
||||
this, SLOT(pairingChanged(bool)));
|
||||
disconnect(currentDevice,SIGNAL(pairingFailed(QString)),
|
||||
this, SLOT(pairingFailed(QString)));
|
||||
disconnect(currentDevice, 0, this, 0);
|
||||
}
|
||||
|
||||
//Store previous device config
|
||||
|
@ -175,6 +169,16 @@ void KdeConnectKcm::deviceSelected(const QModelIndex& current)
|
|||
currentIndex = sortProxyModel->mapToSource(current);
|
||||
currentDevice = devicesModel->getDevice(currentIndex.row());
|
||||
|
||||
resetCurrentDevice();
|
||||
|
||||
connect(currentDevice, SIGNAL(pluginsChanged()), this, SLOT(resetCurrentDevice()));
|
||||
connect(currentDevice, SIGNAL(pairingChanged(bool)), this, SLOT(pairingChanged(bool)));
|
||||
connect(currentDevice, SIGNAL(pairingFailed(QString)), this, SLOT(pairingFailed(QString)));
|
||||
}
|
||||
|
||||
void KdeConnectKcm::resetCurrentDevice()
|
||||
{
|
||||
kcmUi->noDevicePlaceholder->setVisible(false);
|
||||
bool valid = (currentDevice != nullptr && currentDevice->isValid());
|
||||
kcmUi->deviceInfo->setVisible(valid);
|
||||
if (!valid) {
|
||||
|
@ -210,11 +214,6 @@ void KdeConnectKcm::deviceSelected(const QModelIndex& current)
|
|||
kcmUi->name_label->setText(currentDevice->name());
|
||||
kcmUi->status_label->setText(currentDevice->isPaired()? i18n("(paired)") : i18n("(unpaired)"));
|
||||
|
||||
connect(currentDevice,SIGNAL(pairingChanged(bool)),
|
||||
this, SLOT(pairingChanged(bool)));
|
||||
connect(currentDevice,SIGNAL(pairingFailed(QString)),
|
||||
this, SLOT(pairingFailed(QString)));
|
||||
|
||||
const QList<KPluginInfo> pluginInfo = KPluginInfo::fromMetaData(KPluginLoader::findPlugins("kdeconnect/"));
|
||||
QList<KPluginInfo> availablePluginInfo;
|
||||
QList<KPluginInfo> missingPluginInfo;
|
||||
|
@ -234,7 +233,6 @@ void KdeConnectKcm::deviceSelected(const QModelIndex& current)
|
|||
|
||||
connect(kcmUi->pluginSelector, SIGNAL(changed(bool)),
|
||||
this, SLOT(pluginsConfigChanged()));
|
||||
|
||||
}
|
||||
|
||||
void KdeConnectKcm::requestPair()
|
||||
|
|
|
@ -59,6 +59,7 @@ private Q_SLOTS:
|
|||
void renameShow();
|
||||
void renameDone();
|
||||
void setRenameMode(bool b);
|
||||
void resetCurrentDevice();
|
||||
|
||||
private:
|
||||
Ui::KdeConnectKcmUi* kcmUi;
|
||||
|
|
Loading…
Reference in a new issue