Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional file extensions for HEIC/HEIF #723

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions src/qvapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -358,16 +362,25 @@ void QVApplication::defineFilterLists()
if (fileExtension == ".pdf")
continue;

filterList << "*" + fileExtension;
filterString += "*" + fileExtension + " ";
fileExtensionList << fileExtension;
addExtension(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";
addExtension(".jpe");
addExtension(".jfi");
#if QT_VERSION < QT_VERSION_CHECK(6, 8, 0)
addExtension(".jfif");
#endif
}
else if (fileExtension == ".heic")
{
addExtension(".heics");
}
else if (fileExtension == ".heif")
{
addExtension(".heifs");
addExtension(".hif");
}
}
filterString.chop(1);
Expand Down
3 changes: 0 additions & 3 deletions src/qvapplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand All @@ -87,7 +85,6 @@ class QVApplication : public QApplication

QMenuBar *menuBar;

QStringList filterList;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing was even using this 😋

QStringList nameFilterList;
QStringList fileExtensionList;
QStringList mimeTypeNameList;
Expand Down