From 88c1f7b6ffb1ff9c97127cc87f6b9a8895d073a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Wed, 14 Aug 2024 12:31:59 +0200 Subject: [PATCH] Render/UI: fix image sequence file extension We now check the codec and only use proper extensions for PNG, TIFF and JPEG. Ref: #219 --- .../RenderWidgets/renderinstancewidget.cpp | 46 ++++++++++++++++--- .../GUI/RenderWidgets/renderinstancewidget.h | 2 + 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/src/app/GUI/RenderWidgets/renderinstancewidget.cpp b/src/app/GUI/RenderWidgets/renderinstancewidget.cpp index ed4063dea..c799402d4 100644 --- a/src/app/GUI/RenderWidgets/renderinstancewidget.cpp +++ b/src/app/GUI/RenderWidgets/renderinstancewidget.cpp @@ -302,7 +302,13 @@ void RenderInstanceWidget::updateOutputDestinationFromCurrentFormat() { outputDst = Document::sInstance->projectDirectory() + "/untitled"; } const QString tmpStr = QString(format->extensions); - const QStringList supportedExt = tmpStr.split(","); + QStringList supportedExt = tmpStr.split(","); + if (isImgSeq) { + const auto exts = getExportImageExtensions(outputSettings); + if (!exts.second.isEmpty()) { + supportedExt = exts.second.join(" ").split("*.", Qt::SkipEmptyParts); + } + } const QString fileName = outputDst.split("/").last(); const QStringList dividedName = fileName.split("."); QString currExt; @@ -346,12 +352,18 @@ void RenderInstanceWidget::openOutputDestinationDialog() { QString selectedExt; const OutputSettings &outputSettings = mSettings.getOutputRenderSettings(); const auto format = outputSettings.fOutputFormat; - if(format) { + if (format) { QString tmpStr = QString(format->extensions); - const QStringList supportedExt = tmpStr.split(","); - selectedExt = "." + supportedExt.first(); - tmpStr.replace(",", " *."); - supportedExts = "Output File (*." + tmpStr + ")"; + const auto exts = getExportImageExtensions(outputSettings); + if (!exts.first.isEmpty() && !exts.second.isEmpty()) { + selectedExt = exts.first; + supportedExts = tr("Output File (%1)").arg(exts.second.join(" ")); + } else { + const QStringList supportedExt = tmpStr.split(","); + selectedExt = "." + supportedExt.first(); + tmpStr.replace(",", " *."); + supportedExts = "Output File (*." + tmpStr + ")"; + } } QString iniText = mSettings.getOutputDestination(); if(iniText.isEmpty()) { @@ -378,6 +390,28 @@ void RenderInstanceWidget::openRenderSettingsDialog() { delete dialog; } +const QPair RenderInstanceWidget::getExportImageExtensions(const OutputSettings &settings) +{ + const auto format = settings.fOutputFormat; + const auto codec = settings.fVideoCodec; + QPair ext; + if (!format) { return ext; } + if (QString(format->long_name).startsWith("image2") && codec) { + const auto codecName = QString(codec->name); + if (codecName == "png") { + ext.first = ".png"; + ext.second << "*.png"; + } else if (codecName == "tiff") { + ext.first = ".tif"; + ext.second << "*.tif" << "*.tiff"; + } else if (codecName.endsWith("jpeg")) { + ext.first = ".jpg"; + ext.second << "*.jpg" << "*.jpeg"; + } + } + return ext; +} + void RenderInstanceWidget::write(eWriteStream &dst) const { mSettings.write(dst); dst << isChecked(); diff --git a/src/app/GUI/RenderWidgets/renderinstancewidget.h b/src/app/GUI/RenderWidgets/renderinstancewidget.h index c6de37401..762d93be8 100644 --- a/src/app/GUI/RenderWidgets/renderinstancewidget.h +++ b/src/app/GUI/RenderWidgets/renderinstancewidget.h @@ -95,6 +95,8 @@ class RenderInstanceWidget : public ClosableContainer { void openOutputSettingsDialog(); void openOutputDestinationDialog(); void openRenderSettingsDialog(); + + const QPair getExportImageExtensions(const OutputSettings &settings); }; #endif // RENDERINSTANCEWIDGET_H