From 7dff6f26bc5cbc9470b2c5553e8fa72333ea9649 Mon Sep 17 00:00:00 2001 From: Iridias Date: Mon, 29 Aug 2022 22:39:56 +0200 Subject: [PATCH] FileView: Create new file icon provider if icons are missing --- src/widgets/fileview.cpp | 5 +++++ src/widgets/fileview.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/widgets/fileview.cpp b/src/widgets/fileview.cpp index 0b94fe6ec..a576a08f1 100644 --- a/src/widgets/fileview.cpp +++ b/src/widgets/fileview.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -266,6 +267,10 @@ void FileView::showEvent(QShowEvent *e) { if (model_) return; model_ = new QFileSystemModel(this); + if (!model_->iconProvider() || model_->iconProvider()->icon(QAbstractFileIconProvider::Folder).isNull()) { + file_icon_provider_ = std::make_unique(); + model_->setIconProvider(file_icon_provider_.get()); + } model_->setNameFilters(filter_list_); // if an item fails the filter, hide it diff --git a/src/widgets/fileview.h b/src/widgets/fileview.h index e81ada981..3374ae63e 100644 --- a/src/widgets/fileview.h +++ b/src/widgets/fileview.h @@ -36,6 +36,7 @@ class QMimeData; class QFileSystemModel; +class QFileIconProvider; class QUndoStack; class QKeyEvent; class QShowEvent; @@ -119,6 +120,8 @@ class FileView : public QWidget { QString lazy_set_path_; QStringList filter_list_; + + std::unique_ptr file_icon_provider_; }; #endif // FILEVIEW_H