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
|
//Code borrowed from KWin
|
||||||
foreach (const QString& pluginName, loader->getPluginList()) {
|
foreach (const QString& pluginName, loader->getPluginList()) {
|
||||||
if (isPluginEnabled(pluginName)) {
|
const KPluginMetaData service = loader->getPluginInfo(pluginName);
|
||||||
KdeConnectPlugin* plugin = m_plugins.take(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 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 bool pluginEnabled = isPluginEnabled(pluginName);
|
||||||
|
if (pluginEnabled)
|
||||||
supportedIncomingInterfaces += incomingInterfaces;
|
supportedIncomingInterfaces += incomingInterfaces;
|
||||||
|
|
||||||
//If we don't find intersection with the received on one end and the sent on the other, we don't
|
//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
|
//let the plugin stay
|
||||||
//Also, if no capabilities are specified on the other end, we don't apply this optimizaton, as
|
//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.
|
//we assume that the other client doesn't know about capabilities.
|
||||||
if ((!m_incomingCapabilities.isEmpty() || !m_outgoingCapabilities.isEmpty())
|
if ((!m_incomingCapabilities.isEmpty() || !m_outgoingCapabilities.isEmpty())
|
||||||
&& (m_incomingCapabilities & outgoingInterfaces).isEmpty()
|
&& (m_incomingCapabilities & outgoingInterfaces).isEmpty()
|
||||||
&& (m_outgoingCapabilities & incomingInterfaces).isEmpty()
|
&& (m_outgoingCapabilities & incomingInterfaces).isEmpty()
|
||||||
) {
|
) {
|
||||||
qCWarning(KDECONNECT_CORE) << "not loading " << pluginName << "because of unmatched capabilities";
|
qCWarning(KDECONNECT_CORE) << "not loading " << pluginName << "because of unmatched capabilities";
|
||||||
delete plugin;
|
unsupportedPlugins.append(pluginName);
|
||||||
unsupportedPlugins.append(pluginName);
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
|
||||||
|
if (pluginEnabled) {
|
||||||
|
KdeConnectPlugin* plugin = m_plugins.take(pluginName);
|
||||||
|
|
||||||
if (!plugin) {
|
if (!plugin) {
|
||||||
plugin = loader->instantiatePluginForDevice(pluginName, this);
|
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)
|
void KdeConnectKcm::deviceSelected(const QModelIndex& current)
|
||||||
{
|
{
|
||||||
|
|
||||||
kcmUi->noDevicePlaceholder->setVisible(false);
|
|
||||||
|
|
||||||
if (currentDevice) {
|
if (currentDevice) {
|
||||||
disconnect(currentDevice,SIGNAL(pairingChanged(bool)),
|
disconnect(currentDevice, 0, this, 0);
|
||||||
this, SLOT(pairingChanged(bool)));
|
|
||||||
disconnect(currentDevice,SIGNAL(pairingFailed(QString)),
|
|
||||||
this, SLOT(pairingFailed(QString)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Store previous device config
|
//Store previous device config
|
||||||
|
@ -175,6 +169,16 @@ void KdeConnectKcm::deviceSelected(const QModelIndex& current)
|
||||||
currentIndex = sortProxyModel->mapToSource(current);
|
currentIndex = sortProxyModel->mapToSource(current);
|
||||||
currentDevice = devicesModel->getDevice(currentIndex.row());
|
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());
|
bool valid = (currentDevice != nullptr && currentDevice->isValid());
|
||||||
kcmUi->deviceInfo->setVisible(valid);
|
kcmUi->deviceInfo->setVisible(valid);
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
|
@ -210,11 +214,6 @@ void KdeConnectKcm::deviceSelected(const QModelIndex& current)
|
||||||
kcmUi->name_label->setText(currentDevice->name());
|
kcmUi->name_label->setText(currentDevice->name());
|
||||||
kcmUi->status_label->setText(currentDevice->isPaired()? i18n("(paired)") : i18n("(unpaired)"));
|
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/"));
|
const QList<KPluginInfo> pluginInfo = KPluginInfo::fromMetaData(KPluginLoader::findPlugins("kdeconnect/"));
|
||||||
QList<KPluginInfo> availablePluginInfo;
|
QList<KPluginInfo> availablePluginInfo;
|
||||||
QList<KPluginInfo> missingPluginInfo;
|
QList<KPluginInfo> missingPluginInfo;
|
||||||
|
@ -234,7 +233,6 @@ void KdeConnectKcm::deviceSelected(const QModelIndex& current)
|
||||||
|
|
||||||
connect(kcmUi->pluginSelector, SIGNAL(changed(bool)),
|
connect(kcmUi->pluginSelector, SIGNAL(changed(bool)),
|
||||||
this, SLOT(pluginsConfigChanged()));
|
this, SLOT(pluginsConfigChanged()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KdeConnectKcm::requestPair()
|
void KdeConnectKcm::requestPair()
|
||||||
|
|
|
@ -59,6 +59,7 @@ private Q_SLOTS:
|
||||||
void renameShow();
|
void renameShow();
|
||||||
void renameDone();
|
void renameDone();
|
||||||
void setRenameMode(bool b);
|
void setRenameMode(bool b);
|
||||||
|
void resetCurrentDevice();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::KdeConnectKcmUi* kcmUi;
|
Ui::KdeConnectKcmUi* kcmUi;
|
||||||
|
|
Loading…
Reference in a new issue