Commit 478db0b4 authored by Nicolas Fella's avatar Nicolas Fella
Browse files

Use KPluginMetaData to list containments

Instead of the half-deprecated KPluginInfo
parent 78f04b58
......@@ -152,9 +152,9 @@ PlasmaQuick::ConfigModel *ContainmentConfigView::containmentPluginsConfigModel()
if (!m_containmentPluginsConfigModel) {
m_containmentPluginsConfigModel = new PlasmaQuick::ConfigModel(this);
const KPluginInfo::List actions = Plasma::PluginLoader::self()->listContainmentsOfType(QStringLiteral("Desktop"));
for (const KPluginInfo &info : actions) {
m_containmentPluginsConfigModel->appendCategory(info.icon(), info.name(), QString(), info.pluginName());
const QList<KPluginMetaData> actions = Plasma::PluginLoader::self()->listContainmentsMetaDataOfType(QStringLiteral("Desktop"));
for (const KPluginMetaData &plugin : actions) {
m_containmentPluginsConfigModel->appendCategory(plugin.iconName(), plugin.name(), QString(), plugin.pluginId());
}
}
return m_containmentPluginsConfigModel;
......
......@@ -213,11 +213,11 @@ QStringList AppInterface::knownPanelTypes() const
QStringList AppInterface::knownContainmentTypes(const QString &type) const
{
QStringList containments;
const KPluginInfo::List infoLs = Plasma::PluginLoader::listContainmentsOfType(type);
const QList<KPluginMetaData> plugins = Plasma::PluginLoader::listContainmentsMetaDataOfType(type);
containments.reserve(infoLs.count());
for (const KPluginInfo &info : infoLs) {
containments.append(info.pluginName());
containments.reserve(plugins.count());
for (const KPluginMetaData &plugin : plugins) {
containments.append(plugin.pluginId());
}
return containments;
......
......@@ -382,9 +382,9 @@ QList<Containment *> ScriptEngine::desktopsForActivity(const QString &id)
Plasma::Containment *ScriptEngine::createContainment(const QString &type, const QString &plugin)
{
bool exists = false;
const KPluginInfo::List list = Plasma::PluginLoader::listContainmentsOfType(type);
foreach (const KPluginInfo &info, list) {
if (info.pluginName() == plugin) {
const QList<KPluginMetaData> list = Plasma::PluginLoader::listContainmentsMetaDataOfType(type);
foreach (const KPluginMetaData &pluginInfo, list) {
if (pluginInfo.pluginId() == plugin) {
exists = true;
break;
}
......
......@@ -1737,7 +1737,7 @@ void ShellCorona::checkAddPanelAction(const QStringList &sycocaChanges)
m_addPanelsMenu.reset(nullptr);
KPluginInfo::List panelContainmentPlugins = Plasma::PluginLoader::listContainmentsOfType(QStringLiteral("Panel"));
const QList<KPluginMetaData> panelContainmentPlugins = Plasma::PluginLoader::listContainmentsMetaDataOfType(QStringLiteral("Panel"));
auto filter = [](const KPluginMetaData &md) -> bool {
return md.value(QStringLiteral("NoDisplay")) != QLatin1String("true")
......@@ -1767,12 +1767,12 @@ void ShellCorona::checkAddPanelAction(const QStringList &sycocaChanges)
void ShellCorona::populateAddPanelsMenu()
{
m_addPanelsMenu->clear();
const KPluginInfo emptyInfo;
const KPluginMetaData emptyInfo;
const KPluginInfo::List panelContainmentPlugins = Plasma::PluginLoader::listContainmentsOfType(QStringLiteral("Panel"));
QMap<QString, QPair<KPluginInfo, KPluginMetaData>> sorted;
for (const KPluginInfo &plugin : panelContainmentPlugins) {
if (plugin.property(QStringLiteral("NoDisplay")).toString() == QLatin1String("true")) {
const QList<KPluginMetaData> panelContainmentPlugins = Plasma::PluginLoader::listContainmentsMetaDataOfType(QStringLiteral("Panel"));
QMap<QString, QPair<KPluginMetaData, KPluginMetaData>> sorted;
for (const KPluginMetaData &plugin : panelContainmentPlugins) {
if (plugin.value(QStringLiteral("NoDisplay")) == QLatin1String("true")) {
continue;
}
sorted.insert(plugin.name(), qMakePair(plugin, KPluginMetaData()));
......@@ -1787,26 +1787,26 @@ void ShellCorona::populateAddPanelsMenu()
sorted.insert(tpl.name(), qMakePair(emptyInfo, tpl));
}
QMapIterator<QString, QPair<KPluginInfo, KPluginMetaData>> it(sorted);
QMapIterator<QString, QPair<KPluginMetaData, KPluginMetaData>> it(sorted);
KPackage::Package package = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Plasma/LayoutTemplate"));
while (it.hasNext()) {
it.next();
QPair<KPluginInfo, KPluginMetaData> pair = it.value();
QPair<KPluginMetaData, KPluginMetaData> pair = it.value();
if (pair.first.isValid()) {
KPluginInfo plugin = pair.first;
KPluginMetaData plugin = pair.first;
QAction *action = m_addPanelsMenu->addAction(i18n("Empty %1", plugin.name()));
if (!plugin.icon().isEmpty()) {
action->setIcon(QIcon::fromTheme(plugin.icon()));
if (!plugin.iconName().isEmpty()) {
action->setIcon(QIcon::fromTheme(plugin.iconName()));
}
action->setData(plugin.pluginName());
action->setData(plugin.pluginId());
} else {
KPluginInfo info(pair.second);
package.setPath(info.pluginName());
KPluginMetaData plugin(pair.second);
package.setPath(plugin.pluginId());
const QString scriptFile = package.filePath("mainscript");
if (!scriptFile.isEmpty()) {
QAction *action = m_addPanelsMenu->addAction(info.name());
action->setData(QStringLiteral("plasma-desktop-template:%1").arg(info.pluginName()));
QAction *action = m_addPanelsMenu->addAction(plugin.name());
action->setData(QStringLiteral("plasma-desktop-template:%1").arg(plugin.pluginId()));
}
}
}
......@@ -1814,10 +1814,10 @@ void ShellCorona::populateAddPanelsMenu()
void ShellCorona::addPanel()
{
KPluginInfo::List panelPlugins = Plasma::PluginLoader::listContainmentsOfType(QStringLiteral("Panel"));
const QList<KPluginMetaData> panelPlugins = Plasma::PluginLoader::listContainmentsMetaDataOfType(QStringLiteral("Panel"));
if (!panelPlugins.isEmpty()) {
addPanel(panelPlugins.first().pluginName());
addPanel(panelPlugins.first().pluginId());
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment