Commit 78277138 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

Category decorations aren't a thing anymore

parent f310fdbc
......@@ -26,12 +26,10 @@ Category::Category(const QString &name,
const QVector<QPair<FilterType, QString>> &orFilters,
const QSet<QString> &pluginName,
const QVector<Category *> &subCategories,
const QUrl &decoration,
bool isAddons)
: QObject(nullptr)
, m_name(name)
, m_iconString(iconName)
, m_decoration(decoration)
, m_orFilters(orFilters)
, m_subCategories(subCategories)
, m_plugins(pluginName)
......@@ -58,14 +56,6 @@ void Category::parseData(const QString &path, const QDomNode &data)
} else if (tempElement.tagName() == QLatin1String("Menu")) {
m_subCategories << new Category(m_plugins, this);
m_subCategories.last()->parseData(path, node);
} else if (tempElement.tagName() == QLatin1String("Image")) {
m_decoration = QUrl(tempElement.text());
if (m_decoration.isRelative()) {
m_decoration =
QUrl::fromLocalFile(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("discover/") + tempElement.text()));
if (m_decoration.isEmpty())
qCWarning(LIBDISCOVER_LOG) << "couldn't find category decoration" << tempElement.text();
}
} else if (tempElement.tagName() == QLatin1String("Addons")) {
m_isAddons = true;
} else if (tempElement.tagName() == QLatin1String("Icon") && tempElement.hasChildNodes()) {
......@@ -247,17 +237,6 @@ bool Category::blacklistPlugins(const QSet<QString> &pluginNames)
return false;
}
QUrl Category::decoration() const
{
if (m_decoration.isEmpty()) {
Category *c = qobject_cast<Category *>(parent());
return c ? c->decoration() : QUrl();
} else {
Q_ASSERT(!m_decoration.isLocalFile() || QFile::exists(m_decoration.toLocalFile()));
return m_decoration;
}
}
QVariantList Category::subCategoriesVariant() const
{
return kTransform<QVariantList>(m_subCategories, [](Category *cat) {
......
......@@ -33,7 +33,6 @@ public:
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
Q_PROPERTY(QString icon READ icon CONSTANT)
Q_PROPERTY(QObject *parent READ parent CONSTANT)
Q_PROPERTY(QUrl decoration READ decoration CONSTANT)
Q_PROPERTY(QVariantList subcategories READ subCategoriesVariant NOTIFY subCategoriesChanged)
explicit Category(QSet<QString> pluginNames, QObject *parent = nullptr);
......@@ -42,7 +41,6 @@ public:
const QVector<QPair<FilterType, QString>> &orFilters,
const QSet<QString> &pluginName,
const QVector<Category *> &subCategories,
const QUrl &decoration,
bool isAddons);
~Category() override;
......@@ -72,7 +70,6 @@ public:
{
return m_isAddons;
}
QUrl decoration() const;
bool matchesCategoryName(const QString &name) const;
Q_SCRIPTABLE bool contains(Category *cat) const;
......@@ -88,7 +85,6 @@ Q_SIGNALS:
private:
QString m_name;
QString m_iconString;
QUrl m_decoration;
QVector<QPair<FilterType, QString>> m_andFilters;
QVector<QPair<FilterType, QString>> m_orFilters;
QVector<QPair<FilterType, QString>> m_notFilters;
......
......@@ -124,9 +124,9 @@ KNSBackend::KNSBackend(QObject *parent, const QString &iconName, const QString &
m_categories += cats;
for (const auto &cat : cats) {
if (m_hasApplications)
categories << new Category(cat, QStringLiteral("applications-other"), {{CategoryFilter, cat}}, backendName, {}, {}, true);
categories << new Category(cat, QStringLiteral("applications-other"), {{CategoryFilter, cat}}, backendName, {}, true);
else
categories << new Category(cat, QStringLiteral("plasma"), {{CategoryFilter, cat}}, backendName, {}, {}, true);
categories << new Category(cat, QStringLiteral("plasma"), {{CategoryFilter, cat}}, backendName, {}, true);
}
}
......@@ -165,13 +165,12 @@ KNSBackend::KNSBackend(QObject *parent, const QString &iconName, const QString &
m_engine->init(m_name);
if (m_hasApplications) {
auto actualCategory = new Category(m_displayName, QStringLiteral("applications-other"), filters, backendName, topCategories, QUrl(), false);
auto actualCategory = new Category(m_displayName, QStringLiteral("applications-other"), filters, backendName, topCategories, false);
auto applicationCategory = new Category(i18n("Applications"), //
QStringLiteral("applications-internet"),
filters,
backendName,
{actualCategory},
QUrl(),
false);
applicationCategory->setAndFilter({{CategoryFilter, QLatin1String("Application")}});
m_categories.append(applicationCategory->name());
......@@ -209,11 +208,11 @@ KNSBackend::KNSBackend(QObject *parent, const QString &iconName, const QString &
QStringLiteral("ksplash.knsrc"), QStringLiteral("window-decorations.knsrc"),
};
const auto iconName = knsrcPlasma.contains(fileName) ? QStringLiteral("plasma") : QStringLiteral("applications-other");
auto actualCategory = new Category(m_displayName, iconName, filters, backendName, categories, QUrl(), true);
auto actualCategory = new Category(m_displayName, iconName, filters, backendName, categories, true);
actualCategory->setParent(this);
const auto topLevelName = knsrcPlasma.contains(fileName) ? i18n("Plasma Addons") : i18n("Application Addons");
auto addonsCategory = new Category(topLevelName, iconName, filters, backendName, {actualCategory}, QUrl(), true);
auto addonsCategory = new Category(topLevelName, iconName, filters, backendName, {actualCategory}, true);
m_rootCategories = {addonsCategory};
}
......
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