diff --git a/app/src/actioncommands.cpp b/app/src/actioncommands.cpp index 30a42434e..d5478d458 100644 --- a/app/src/actioncommands.cpp +++ b/app/src/actioncommands.cpp @@ -535,6 +535,39 @@ Status ActionCommands::exportImage() QString exportFormat = dialog->getExportFormat(); bool useTranparency = dialog->getTransparency(); + QString extension = ""; + QString formatStr = exportFormat; + if (formatStr == "PNG" || formatStr == "png") + { + exportFormat = "PNG"; + extension = ".png"; + } + if (formatStr == "JPG" || formatStr == "jpg" || formatStr == "JPEG" || formatStr == "jpeg") + { + exportFormat = "JPG"; + extension = ".jpg"; + useTranparency = false; // JPG doesn't support transparency, so we have to include the background + } + if (formatStr == "TIFF" || formatStr == "tiff" || formatStr == "TIF" || formatStr == "tif") + { + exportFormat = "TIFF"; + extension = ".tiff"; + } + if (formatStr == "BMP" || formatStr == "bmp") + { + exportFormat = "BMP"; + extension = ".bmp"; + useTranparency = false; + } + if (formatStr == "WEBP" || formatStr == "webp") { + exportFormat = "WEBP"; + extension = ".webp"; + } + if (!filePath.endsWith(extension, Qt::CaseInsensitive)) + { + filePath += extension; + } + // Export QString sCameraLayerName = dialog->getCameraLayerName(); LayerCamera* cameraLayer = static_cast(mEditor->layers()->findLayerByName(sCameraLayerName, Layer::CAMERA)); diff --git a/app/src/filedialog.cpp b/app/src/filedialog.cpp index 42ee65db2..38425f8ce 100644 --- a/app/src/filedialog.cpp +++ b/app/src/filedialog.cpp @@ -226,6 +226,8 @@ QString FileDialog::saveFileFilters(FileType fileType) bool FileDialog::hasValidSuffix(const QString& filters, const QString& filePath) { + if (filters.isEmpty()) return true; + QString fileName = QFileInfo(filePath).fileName(); for (const QString& filter : filters.split(";;")) {