From b75e68059a6efd5141d9b295278ed510482b9729 Mon Sep 17 00:00:00 2001 From: "J.D. Purcell" Date: Mon, 14 Oct 2024 18:27:43 -0400 Subject: [PATCH 1/2] Add additional file extensions for HEIC/HEIF --- src/qvapplication.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/qvapplication.cpp b/src/qvapplication.cpp index 1767e2e7..8bec88dd 100644 --- a/src/qvapplication.cpp +++ b/src/qvapplication.cpp @@ -362,13 +362,25 @@ void QVApplication::defineFilterLists() filterString += "*" + fileExtension + " "; fileExtensionList << fileExtension; - // If we support jpg, we actually support the jfif, jfi, and jpe file extensions too almost certainly. + // Register additional file extensions that decoders support but don't advertise if (fileExtension == ".jpg") { filterList << "*.jpe" << "*.jfi" << "*.jfif"; filterString += "*.jpe *.jfi *.jfif "; fileExtensionList << ".jpe" << ".jfi" << ".jfif"; } + else if (fileExtension == ".heic") + { + filterList << "*.heics"; + filterString += "*.heics "; + fileExtensionList << ".heics"; + } + else if (fileExtension == ".heif") + { + filterList << "*.heifs" << "*.hif"; + filterString += "*.heifs *.hif "; + fileExtensionList << ".heifs" << ".hif"; + } } filterString.chop(1); filterString += ")"; From 1f4b5a57b93bc017dd36457c208459f222cdbcb3 Mon Sep 17 00:00:00 2001 From: "J.D. Purcell" Date: Tue, 15 Oct 2024 18:35:38 -0400 Subject: [PATCH 2/2] Supported file extension code cleanup --- src/qvapplication.cpp | 27 ++++++++++++++------------- src/qvapplication.h | 3 --- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/qvapplication.cpp b/src/qvapplication.cpp index 8bec88dd..b448fff8 100644 --- a/src/qvapplication.cpp +++ b/src/qvapplication.cpp @@ -347,9 +347,13 @@ void QVApplication::defineFilterLists() const auto &byteArrayFormats = QImageReader::supportedImageFormats(); auto filterString = tr("Supported Images") + " ("; - filterList.reserve(byteArrayFormats.size()-1); fileExtensionList.reserve(byteArrayFormats.size()-1); + const auto addExtension = [&](const QString &extension) { + filterString += "*" + extension + " "; + fileExtensionList << extension; + }; + // Build the filterlist, filterstring, and filterregexplist in one loop for (const auto &byteArray : byteArrayFormats) { @@ -358,28 +362,25 @@ void QVApplication::defineFilterLists() if (fileExtension == ".pdf") continue; - filterList << "*" + fileExtension; - filterString += "*" + fileExtension + " "; - fileExtensionList << fileExtension; + addExtension(fileExtension); // Register additional file extensions that decoders support but don't advertise if (fileExtension == ".jpg") { - filterList << "*.jpe" << "*.jfi" << "*.jfif"; - filterString += "*.jpe *.jfi *.jfif "; - fileExtensionList << ".jpe" << ".jfi" << ".jfif"; + addExtension(".jpe"); + addExtension(".jfi"); +#if QT_VERSION < QT_VERSION_CHECK(6, 8, 0) + addExtension(".jfif"); +#endif } else if (fileExtension == ".heic") { - filterList << "*.heics"; - filterString += "*.heics "; - fileExtensionList << ".heics"; + addExtension(".heics"); } else if (fileExtension == ".heif") { - filterList << "*.heifs" << "*.hif"; - filterString += "*.heifs *.hif "; - fileExtensionList << ".heifs" << ".hif"; + addExtension(".heifs"); + addExtension(".hif"); } } filterString.chop(1); diff --git a/src/qvapplication.h b/src/qvapplication.h index 4d19143a..9a7fcb3d 100644 --- a/src/qvapplication.h +++ b/src/qvapplication.h @@ -63,8 +63,6 @@ class QVApplication : public QApplication QMenuBar *getMenuBar() const { return menuBar; } - const QStringList &getFilterList() const { return filterList; } - const QStringList &getNameFilterList() const { return nameFilterList; } const QStringList &getFileExtensionList() const { return fileExtensionList; } @@ -87,7 +85,6 @@ class QVApplication : public QApplication QMenuBar *menuBar; - QStringList filterList; QStringList nameFilterList; QStringList fileExtensionList; QStringList mimeTypeNameList;