diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2019-06-25 08:30:11 -0400 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2019-07-02 10:10:18 -0400 |
| commit | 24b9f050c10d039be13a266d41088ae0fcc068f4 (patch) | |
| tree | 672bbd07e579d5453c81dfabfaf5ff689201f81a /src/modinfodialogimages.cpp | |
| parent | 1ef0620f6e2d8a4e7d48b3b2b8eb96c3a8d3cd0d (diff) | |
check supported extensions instead of using QImageReader, less accurate but much faster
Diffstat (limited to 'src/modinfodialogimages.cpp')
| -rw-r--r-- | src/modinfodialogimages.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/modinfodialogimages.cpp b/src/modinfodialogimages.cpp index 1f5b258c..4acc7838 100644 --- a/src/modinfodialogimages.cpp +++ b/src/modinfodialogimages.cpp @@ -140,6 +140,18 @@ ImagesTab::ImagesTab( ui->imagesScrollArea->setWidgetResizable(false); ui->imagesScrollArea->setTab(this); ui->imagesThumbnails->setTab(this); + + const auto list = QImageReader::supportedImageFormats(); + for (const auto& entry : list) { + QString s(entry); + if (!s.isEmpty()) { + if (s[0] != ".") { + s = "." + s; + } + + m_supportedFormats.emplace_back(std::move(s)); + } + } } void ImagesTab::clear() @@ -151,10 +163,11 @@ void ImagesTab::clear() bool ImagesTab::feedFile(const QString& rootPath, const QString& fullPath) { - QImageReader reader(fullPath); - if (reader.canRead()) { - m_files.push_back({fullPath}); - return true; + for (const auto& ext : m_supportedFormats) { + if (fullPath.endsWith(ext, Qt::CaseInsensitive)) { + m_files.push_back({fullPath}); + return true; + } } return false; |
