FileView: Create new file icon provider if icons are missing

This commit is contained in:
Iridias 2022-08-29 22:39:56 +02:00 committed by Jonas Kvinge
parent 9e835a23fd
commit 7dff6f26bc
2 changed files with 8 additions and 0 deletions

View File

@ -21,6 +21,7 @@
#include <QWidget>
#include <QUndoStack>
#include <QDir>
#include <QFileIconProvider>
#include <QFileInfo>
#include <QFileSystemModel>
#include <QString>
@ -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<QFileIconProvider>();
model_->setIconProvider(file_icon_provider_.get());
}
model_->setNameFilters(filter_list_);
// if an item fails the filter, hide it

View File

@ -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<QFileIconProvider> file_icon_provider_;
};
#endif // FILEVIEW_H