Prevent the kcm from refreshing the UI while interacting with it

Only refresh it when the available plugins actually change.
This commit is contained in:
Aleix Pol 2015-09-12 15:02:59 +02:00
parent 27302c0450
commit fe2679a8a5
2 changed files with 26 additions and 20 deletions

View file

@ -207,6 +207,9 @@ void KdeConnectKcm::resetCurrentDevice()
}
}
const QStringList unsupportedPluginNames = currentDevice->unsupportedPlugins();
if (m_oldUnsupportedPluginNames != unsupportedPluginNames) {
//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);
@ -219,12 +222,11 @@ void KdeConnectKcm::resetCurrentDevice()
const QList<KPluginInfo> pluginInfo = KPluginInfo::fromMetaData(KPluginLoader::findPlugins("kdeconnect/"));
QList<KPluginInfo> availablePluginInfo;
QList<KPluginInfo> missingPluginInfo;
QList<KPluginInfo> unsupportedPluginInfo;
QStringList missingPluginNames = currentDevice->unsupportedPlugins();
for (auto it = pluginInfo.cbegin(), itEnd = pluginInfo.cend(); it!=itEnd; ++it) {
if (missingPluginNames.contains(it->pluginName())) {
missingPluginInfo.append(*it);
if (unsupportedPluginNames.contains(it->pluginName())) {
unsupportedPluginInfo.append(*it);
} else {
availablePluginInfo.append(*it);
}
@ -232,7 +234,10 @@ void KdeConnectKcm::resetCurrentDevice()
KSharedConfigPtr deviceConfig = KSharedConfig::openConfig(currentDevice->pluginsConfigFile());
kcmUi->pluginSelector->addPlugins(availablePluginInfo, KPluginSelector::ReadConfigFile, i18n("Available plugins"), QString(), deviceConfig);
kcmUi->pluginSelector->addPlugins(missingPluginInfo, KPluginSelector::ReadConfigFile, i18n("Plugins unsupported by the device"), QString(), deviceConfig);
kcmUi->pluginSelector->addPlugins(unsupportedPluginInfo, KPluginSelector::ReadConfigFile, i18n("Plugins unsupported by the device"), QString(), deviceConfig);
m_oldUnsupportedPluginNames = unsupportedPluginNames;
}
connect(kcmUi->pluginSelector, SIGNAL(changed(bool)),
this, SLOT(pluginsConfigChanged()));

View file

@ -68,6 +68,7 @@ private:
DevicesSortProxyModel* sortProxyModel;
DeviceDbusInterface* currentDevice;
QModelIndex currentIndex;
QStringList m_oldUnsupportedPluginNames;
public Q_SLOTS:
void unpair();