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);
}
//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<KPluginInfo> pluginInfo = KPluginInfo::fromMetaData(KPluginLoader::findPlugins(QStringLiteral("kdeconnect/")));
QList<KPluginInfo> availablePluginInfo;
const QVector<KPluginMetaData> pluginInfo = KPluginLoader::findPlugins(QStringLiteral("kdeconnect/"));
QVector<KPluginMetaData> 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();
}

View file

@ -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);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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