Utilize KCModuleLoader::loadModule for loading KCMs

This will take care of showing user-visible error messages in case the
plugin does not exist.

While we get a log message from KCoreAddons with the change of 728b449891,
the user does not get prompted. Especially if the kcmshell/systemsettings
was not opened from the command line, spotting those error messages is more difficult.
This commit is contained in:
Alexander Lohnau 2022-01-11 19:37:45 +01:00
parent fdea6d151e
commit c4bcfd0b8c

View file

@ -15,6 +15,7 @@
#include <KAboutData> #include <KAboutData>
#include <KCModule> #include <KCModule>
#include <KCModuleLoader>
#include <KConfigGroup> #include <KConfigGroup>
#include <KLocalizedString> #include <KLocalizedString>
#include <KPackage/PackageLoader> #include <KPackage/PackageLoader>
@ -601,14 +602,10 @@ QModelIndex EffectsModel::findByPluginId(const QString &pluginId) const
return index(std::distance(m_effects.constBegin(), it), 0); return index(std::distance(m_effects.constBegin(), it), 0);
} }
static KCModule *loadBinaryConfig(const QString &configModule, QObject *parent) static KCModule *loadBinaryConfig(const QString &configModule, QWidget *parent)
{ {
if (configModule.isEmpty()) {
return nullptr;
}
const KPluginMetaData metaData(QStringLiteral("kwin/effects/configs/") + configModule); const KPluginMetaData metaData(QStringLiteral("kwin/effects/configs/") + configModule);
return KPluginFactory::instantiatePlugin<KCModule>(metaData, parent).plugin; return KCModuleLoader::loadModule(metaData, parent);
} }
static KCModule *findScriptedConfig(const QString &pluginId, QObject *parent) static KCModule *findScriptedConfig(const QString &pluginId, QObject *parent)
@ -636,11 +633,6 @@ void EffectsModel::requestConfigure(const QModelIndex &index, QWindow *transient
module = loadBinaryConfig(configModule, dialog); module = loadBinaryConfig(configModule, dialog);
} }
if (!module) {
delete dialog;
return;
}
dialog->setWindowTitle(index.data(NameRole).toString()); dialog->setWindowTitle(index.data(NameRole).toString());
dialog->winId(); dialog->winId();
dialog->windowHandle()->setTransientParent(transientParent); dialog->windowHandle()->setTransientParent(transientParent);