3Dickulus / FragM

Derived from https://github.com/Syntopia/Fragmentarium/
GNU General Public License v3.0
349 stars 30 forks source link

image extensions are case sensitive #132

Closed claudeha closed 4 years ago

claudeha commented 4 years ago

Describe the bug Select file browser for texture. IMAGE.JPG does not appear in the image list, have to select show all files to see it.

Expected behavior For images to be seen in file browser image list regardless of CaPiTaLiZaTiOn of the file extension.

Desktop (please complete the following information):

3Dickulus commented 4 years ago

quote from https://stackoverflow.com/questions/34858220/qt-how-to-set-a-case-insensitive-filter-on-qfiledialog

The problem only occur with the nativ (Ubuntu) file dialog. Setting the following option solves the issue, but it would be nice if it would work with the nativ file dialog too.

dialog.setOption(QFileDialog::DontUseNativeDialog, true);

I see .jpg and .JPG without any changes, not a big deal to change over to mime-type filter but then you will only see files that have mime-types, you will not see files with .exr (and a few others) format/extensions.

the above quote is about mime-types filter, QDialog can only use 1 kind of filter, either mime-types or extension, not both.

currently FragM queries QImageReader::supportedImageFormats() and builds the name filter from that cuz it returns all valid file extensions

using name filter means all supported file types are shown

using mime-type filter means some extra ones are shown, like jpg variants but it doesn't display all Qt supported file types.

this should allow CAPS to be shown on your system

QFileDialog dialog(this);
dialog.setNameFilter(tr("Images (") + extensions.join(" *.") + tr(");;All (*.*)"));
dialog.setOption(QFileDialog::DontUseNativeDialog, true);
dialog.exec();
fileName = dialog.selectedFiles().at(0);

just spotted a bug... in the above scenario the first extension won't get " *." put in front of it, maybe causes problem for bmp? (first one) easy enough to fix that and add CAPs versions to the list if needed... or you could just type "*.JPG" in the filter input.

3Dickulus commented 4 years ago

update... seems more mime types are available than I initially found :)

"application/x-krita", "image/bmp", "image/gif", "image/jp2", "image/jpeg", "image/openraster", "image/png", "image/svg+xml", "image/svg+xml-compressed", "image/tiff", "image/vnd.adobe.photoshop", "image/vnd.microsoft.icon", "image/vnd.wap.wbmp", "image/webp", "image/x-exr", "image/x-icns", "image/x-mng", "image/x-pcx", "image/x-pic", "image/x-portable-bitmap", "image/x-portable-graymap", "image/x-portable-pixmap", "image/x-rgb", "image/x-sun-raster", "image/x-tga", "image/x-xbitmap", "image/x-xcf", "image/x-xpixmap"

I think that covers them all including exr, this is from QImageReader::supportedMimeTypes();

3Dickulus commented 4 years ago

cobbled together preferences option, list files by mimetypes or extension in sampler file dialog and added the setOption that should allow CAPS and lower...

will test and push over this weekend

3Dickulus commented 4 years ago

Latest commit d5574d6 on develop branch adds dialog.setOption(QFileDialog::DontUseNativeDialog, true); and a preferences option to to the dialog for using file extensions or mimetypes, both seem to work very nicely.

3Dickulus commented 4 years ago

Working? I haven't heard anything so closing for now.

claudeha commented 4 years ago

Yes it's working! Selecting *.jpg shows both .jpg and .JPG files