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

flatpak: Ensure flatpak icons are found

parent 09304b1a
......@@ -27,6 +27,7 @@
#include <QDebug>
#include <QDesktopServices>
#include <QDir>
#include <QDirIterator>
#include <QFileInfo>
#include <QIcon>
#include <QNetworkAccessManager>
......@@ -205,9 +206,21 @@ QVariant FlatpakResource::icon() const
for (const AppStream::Icon &icon : icons) {
switch (icon.kind()) {
case AppStream::Icon::KindLocal:
case AppStream::Icon::KindCached:
ret.addFile(icon.url().toLocalFile(), icon.size());
break;
case AppStream::Icon::KindCached: {
const QString path = icon.url().toLocalFile();
if (QDir::isRelativePath(path)) {
const QString appstreamLocation = installationPath() + "/appstream/" + origin() + '/' + flatpak_get_default_arch() + "/active/icons/";
QDirIterator dit(appstreamLocation, QDirIterator::Subdirectories);
while (dit.hasNext()) {
const auto currentPath = dit.next();
if (dit.fileName() == path) {
ret.addFile(currentPath, icon.size());
}
}
} else {
ret.addFile(path, icon.size());
}
} break;
case AppStream::Icon::KindStock: {
const auto ret = QIcon::fromTheme(icon.name());
if (!ret.isNull())
......
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