Commit 50f9c3cf authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇
Browse files

[System Tray] Initially set correct category for plasmoids

The category was only used for proper Plasma::Applet instances but not unloaded plasmoids from pure metadata.

BUG: 416947
FIXED-IN: 5.18.0

Differential Revision: https://phabricator.kde.org/D27068
parent bb573b83
...@@ -29,6 +29,20 @@ ...@@ -29,6 +29,20 @@
#include <KLocalizedString> #include <KLocalizedString>
static QString plasmoidCategoryForMetadata(const KPluginMetaData &metadata)
{
QString category = QStringLiteral("UnknownCategory");
if (metadata.isValid()) {
const QString notificationAreaCategory = metadata.value(QStringLiteral("X-Plasma-NotificationAreaCategory"));
if (!notificationAreaCategory.isEmpty()) {
category = notificationAreaCategory;
}
}
return category;
}
PlasmoidModel::PlasmoidModel(QObject *parent) : QStandardItemModel(parent) PlasmoidModel::PlasmoidModel(QObject *parent) : QStandardItemModel(parent)
{ {
for (const auto &info : Plasma::PluginLoader::self()->listAppletMetaData(QString())) { for (const auto &info : Plasma::PluginLoader::self()->listAppletMetaData(QString())) {
...@@ -47,7 +61,7 @@ PlasmoidModel::PlasmoidModel(QObject *parent) : QStandardItemModel(parent) ...@@ -47,7 +61,7 @@ PlasmoidModel::PlasmoidModel(QObject *parent) : QStandardItemModel(parent)
item->setData(info.pluginId(), static_cast<int>(BaseRole::ItemId)); item->setData(info.pluginId(), static_cast<int>(BaseRole::ItemId));
item->setData(QStringLiteral("Plasmoid"), static_cast<int>(BaseRole::ItemType)); item->setData(QStringLiteral("Plasmoid"), static_cast<int>(BaseRole::ItemType));
item->setData(false, static_cast<int>(BaseRole::CanRender)); item->setData(false, static_cast<int>(BaseRole::CanRender));
item->setData(QStringLiteral("UnknownCategory"), static_cast<int>(BaseRole::Category)); item->setData(plasmoidCategoryForMetadata(info), static_cast<int>(BaseRole::Category));
item->setData(false, static_cast<int>(Role::HasApplet)); item->setData(false, static_cast<int>(Role::HasApplet));
appendRow(item); appendRow(item);
} }
...@@ -90,17 +104,7 @@ void PlasmoidModel::addApplet(Plasma::Applet *applet) ...@@ -90,17 +104,7 @@ void PlasmoidModel::addApplet(Plasma::Applet *applet)
dataItem->setData(applet->property("_plasma_graphicObject"), static_cast<int>(Role::Applet)); dataItem->setData(applet->property("_plasma_graphicObject"), static_cast<int>(Role::Applet));
dataItem->setData(true, static_cast<int>(Role::HasApplet)); dataItem->setData(true, static_cast<int>(Role::HasApplet));
dataItem->setData(true, static_cast<int>(BaseRole::CanRender)); dataItem->setData(true, static_cast<int>(BaseRole::CanRender));
dataItem->setData(plasmoidCategoryForMetadata(applet->pluginMetaData()), static_cast<int>(BaseRole::Category));
if (applet->pluginMetaData().isValid()) {
const QString category = applet->pluginMetaData().value(QStringLiteral("X-Plasma-NotificationAreaCategory"));
if (category.isEmpty()) {
dataItem->setData(QStringLiteral("UnknownCategory"), static_cast<int>(BaseRole::Category));
} else {
dataItem->setData(category, static_cast<int>(BaseRole::Category));
}
} else {
dataItem->setData(QStringLiteral("UnknownCategory"), static_cast<int>(BaseRole::Category));
}
} }
void PlasmoidModel::removeApplet(Plasma::Applet *applet) void PlasmoidModel::removeApplet(Plasma::Applet *applet)
......
Markdown is supported
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