Skip to content

Commit

Permalink
Resolve symlinks and get absolute path
Browse files Browse the repository at this point in the history
  • Loading branch information
probonopd committed Nov 25, 2020
1 parent 51aa494 commit 8b24c5c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions libfm-qt/bundle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <QIcon>
#include <QIcon>
#include <QDebug>
#include <QDir>

using namespace Fm;

Expand Down Expand Up @@ -98,6 +99,8 @@ QString getLaunchableExecutable(FmFileInfo* _info)
QIcon getIconForBundle(FmFileInfo* _info)
{
QString path = QString(fm_path_to_str(fm_file_info_get_path(_info)));
QDir appDirPath(path);
path = appDirPath.canonicalPath(); // Resolve symlinks and get absolute path
QIcon icon = QIcon::fromTheme("do"); // probono: In the elementary theme, this is a folder with an executable icon inside it; TODO: Find more suitable one
QFileInfo fileInfo = QFileInfo(path);
QString nameWithoutSuffix = QFileInfo(fileInfo.completeBaseName()).fileName();
Expand All @@ -116,6 +119,11 @@ QIcon getIconForBundle(FmFileInfo* _info)
icon = QIcon(QFileInfo(tiffFile2).canonicalFilePath());
}
QFile pngFile1(path.toUtf8() + "/Resources/" + nameWithoutSuffix.toUtf8() + ".png");
QFile svgFile1(path.toUtf8() + "/Resources/" + nameWithoutSuffix.toUtf8() + ".svg");
if (svgFile1.exists()) {
// icon = QIcon(QFileInfo(svgFile1).canonicalFilePath());
qDebug() << "probono: FIXME: There is a svg but we are not using it yet";
}
if (pngFile1.exists()) {
icon = QIcon(QFileInfo(pngFile1).canonicalFilePath());
}
Expand Down

0 comments on commit 8b24c5c

Please sign in to comment.