/* This file is part of the KDE project * SPDX-FileCopyrightText: 2021 Dag Andersen * * SPDX-License-Identifier: LGPL-2.0-or-later */ // clazy:excludeall=qstring-arg #include "TestSchedulerPluginLoader.h" #include "kptschedulerplugin.h" #include "kptdebug.h" #include #include #include namespace KPlato { TestSchedulerPluginLoader::TestSchedulerPluginLoader(QObject * parent) : QObject(parent) { } TestSchedulerPluginLoader::~TestSchedulerPluginLoader() { qInfo()< offers = KoPluginLoader::pluginLoaders(dir); for(QPluginLoader *pluginLoader : offers) { KPluginFactory *factory = qobject_cast(pluginLoader->instance()); if (!factory) { errorPlan << "KPluginFactory could not load the plugin:" << pluginLoader->fileName(); continue; } QJsonObject json = pluginLoader->metaData().value("MetaData").toObject(); json = json.value("KPlugin").toObject(); const QString key = json.value(QStringLiteral("Name")).toString(); // use unlocalized name as plugin identifier const QString name = readLocalValue(json, QStringLiteral("Name")).toString(); const QString comment = readLocalValue(json, QStringLiteral("Description")).toString(); if (key == name_) { debugPlan << "Load plugin:" << key << name << ", " << comment; schedulerPlugin = factory->create(this); Q_ASSERT(schedulerPlugin); schedulerPlugin->setName(name); schedulerPlugin->setComment(comment); break; } } qDeleteAll(offers); return schedulerPlugin; } } //namespace KPlato