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

Prefer the icon from the local theme to upstream's

Overrides the project's icon by the one in the icon theme, provided the
icon
name is offered in the metadata.

BUG: 388261
parent de4f351d
......@@ -183,8 +183,6 @@ QVariant FlatpakResource::icon() const
} else if (icons.isEmpty()) {
ret = QIcon::fromTheme(QStringLiteral("package-x-generic"));
} else foreach(const AppStream::Icon &icon, icons) {
QStringList stock;
switch (icon.kind()) {
case AppStream::Icon::KindLocal:
case AppStream::Icon::KindCached: {
......@@ -199,8 +197,7 @@ QVariant FlatpakResource::icon() const
}
} break;
case AppStream::Icon::KindStock:
stock += icon.name();
break;
return QIcon::fromTheme(icon.name(), QIcon::fromTheme(QStringLiteral("package-x-generic")));
case AppStream::Icon::KindRemote: {
const QString fileName = iconCachePath(icon);
if (QFileInfo::exists(fileName)) {
......@@ -211,11 +208,12 @@ QVariant FlatpakResource::icon() const
case AppStream::Icon::KindUnknown:
break;
}
}
if (ret.isNull()) {
ret = QIcon::fromTheme(stock.value(0), QIcon::fromTheme(QStringLiteral("package-x-generic")));
}
if (ret.isNull()) {
ret = QIcon::fromTheme(QStringLiteral("package-x-generic"));
}
return ret;
}
......
......@@ -56,10 +56,7 @@ QString AppPackageKitResource::longDescription()
static QIcon componentIcon(const AppStream::Component &comp)
{
QIcon ret;
const auto icons = comp.icons();
if (icons.isEmpty()) {
ret = QIcon::fromTheme(QStringLiteral("package-x-generic"));
} else foreach(const AppStream::Icon &icon, icons) {
foreach(const AppStream::Icon &icon, comp.icons()) {
QStringList stock;
switch(icon.kind()) {
case AppStream::Icon::KindLocal:
......@@ -69,14 +66,13 @@ static QIcon componentIcon(const AppStream::Component &comp)
ret.addFile(icon.url().toLocalFile(), icon.size());
break;
case AppStream::Icon::KindStock:
stock += icon.name();
break;
return QIcon::fromTheme(icon.name(), QIcon::fromTheme(QStringLiteral("package-x-generic")));
default:
break;
}
if (ret.isNull() && !stock.isEmpty()) {
ret = QIcon::fromTheme(stock.first());
}
}
if (ret.isNull()) {
ret = QIcon::fromTheme(QStringLiteral("package-x-generic"));
}
return ret;
}
......
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