| 33 | #include <cassert> |
| 34 | |
| 35 | ImageFileFilter::ImageFileFilter() |
| 36 | : FileIOFilter( { |
| 37 | "_Image Filter", |
| 38 | 17.0f, // priority |
| 39 | QStringList(), // set below |
| 40 | "png", |
| 41 | QStringList(), // set below |
| 42 | QStringList(), // set below |
| 43 | Import | Export | BuiltIn | DynamicInfo |
| 44 | } ) |
| 45 | { |
| 46 | //output filters |
| 47 | { |
| 48 | //we grab the list of supported image file formats (for writing) |
| 49 | QList<QByteArray> formats = QImageWriter::supportedImageFormats(); |
| 50 | |
| 51 | QStringList exportFilters; |
| 52 | |
| 53 | //we convert this list into a proper "filters" string |
| 54 | for (auto &format : formats) |
| 55 | { |
| 56 | exportFilters.append( QStringLiteral("%1 image (*.%2)") |
| 57 | .arg( QString( format.data() ).toUpper(), format.data() ) ); |
| 58 | } |
| 59 | |
| 60 | setExportFileFilterStrings(exportFilters); |
| 61 | } |
| 62 | |
| 63 | //input filters |
| 64 | { |
| 65 | //we grab the list of supported image file formats (for reading) |
| 66 | QList<QByteArray> formats = QImageReader::supportedImageFormats(); |
| 67 | |
| 68 | QStringList imageFilters; |
| 69 | QStringList importExtensions; |
| 70 | for (auto &format : formats) |
| 71 | { |
| 72 | imageFilters.append(QStringLiteral("*.%1").arg(format.data())); |
| 73 | importExtensions.append(QStringLiteral("%1").arg(format.data())); |
| 74 | } |
| 75 | setImportExtensions(importExtensions); |
| 76 | |
| 77 | //we convert this list into a proper "filters" string |
| 78 | if (!imageFilters.empty()) |
| 79 | { |
| 80 | QString imageFilter = QString("Image (%1)").arg(imageFilters.join(" ")); |
| 81 | setImportFileFilterStrings({ imageFilter }); |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | QString ImageFileFilter::GetSaveFilename(const QString& dialogTitle, const QString& baseName, const QString& imageSavePath, QWidget* parentWidget/*=nullptr*/) |
| 87 | { |
nothing calls this directly
no test coverage detected