Skip to content

Commit 639b1ee

Browse files
authored
Fix poor performance with Qt 6: Replace QFileSystemModel with QFileIconProvider (flameshot-org#3989)
1 parent 128b583 commit 639b1ee

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

src/utils/winlnkfileparse.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "winlnkfileparse.h"
55
#include <QDir>
66
#include <QDirIterator>
7-
#include <QFileSystemModel>
7+
#include <QFileIconProvider>
88
#include <QImageWriter>
99
#include <QRegularExpression>
1010
#include <QSettings>
@@ -36,11 +36,8 @@ DesktopAppData WinLnkFileParser::parseLnkFile(const QFileInfo& fiLnk,
3636

3737
res.name = fiLnk.baseName();
3838
res.exec = fiSymlink.absoluteFilePath();
39-
40-
// Get icon from exe
41-
QFileSystemModel* model = new QFileSystemModel;
42-
model->setRootPath(fiSymlink.path());
43-
res.icon = model->fileIcon(model->index(fiSymlink.filePath()));
39+
static QFileIconProvider provider;
40+
res.icon = provider.icon(QFileInfo(fiSymlink.filePath()));
4441

4542
if (m_GraphicAppsList.contains(fiSymlink.fileName())) {
4643
res.categories = QStringList() << "Graphics";

src/utils/winlnkfileparse.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct WinLnkFileParser
2525
WinLnkFileParser();
2626
DesktopAppData parseLnkFile(const QFileInfo& fiLnk, bool& ok) const;
2727
int processDirectory(const QDir& dir);
28-
QString getAllUsersStartMenuPath();
28+
static QString getAllUsersStartMenuPath();
2929

3030
QVector<DesktopAppData> getAppsByCategory(const QString& category);
3131
QMap<QString, QVector<DesktopAppData>> getAppsByCategory(

0 commit comments

Comments
 (0)