ensure file extensions are present at saving

fix for issue #68
master
Andreas Stallinger 2020-07-16 23:12:25 +02:00 committed by Jeremy HU
parent c1de02f7dd
commit b4ff6710c1
1 changed files with 12 additions and 0 deletions

View File

@ -65,6 +65,12 @@ void outputMessage(QtMsgType type, const QMessageLogContext &context, const QStr
g_logBrowser->outputMessage(type, msg, context.file, context.line); g_logBrowser->outputMessage(type, msg, context.file, context.line);
} }
void ensureFileExtension(QString* filename, const QString extension) {
if (!filename->endsWith(extension)) {
filename->append(extension);
}
}
const std::map<DocumentWindow *, QUuid> &DocumentWindow::documentWindows() const std::map<DocumentWindow *, QUuid> &DocumentWindow::documentWindows()
{ {
return g_documentWindows; return g_documentWindows;
@ -1371,6 +1377,7 @@ void DocumentWindow::saveAs()
if (filename.isEmpty()) { if (filename.isEmpty()) {
return; return;
} }
ensureFileExtension(&filename, ".ds3");
saveTo(filename); saveTo(filename);
} }
@ -1517,6 +1524,7 @@ void DocumentWindow::saveTo(const QString &saveAsFilename)
if (filename.isEmpty()) { if (filename.isEmpty()) {
return; return;
} }
ensureFileExtension(&filename, ".ds3");
} }
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
@ -1780,6 +1788,7 @@ void DocumentWindow::exportRenderedResult()
if (filename.isEmpty()) { if (filename.isEmpty()) {
return; return;
} }
ensureFileExtension(&filename, ".png");
exportImageToFilename(filename); exportImageToFilename(filename);
} }
@ -1790,6 +1799,7 @@ void DocumentWindow::exportObjResult()
if (filename.isEmpty()) { if (filename.isEmpty()) {
return; return;
} }
ensureFileExtension(&filename, ".obj");
exportObjToFilename(filename); exportObjToFilename(filename);
} }
@ -1828,6 +1838,7 @@ void DocumentWindow::exportFbxResult()
if (filename.isEmpty()) { if (filename.isEmpty()) {
return; return;
} }
ensureFileExtension(&filename, ".fbx");
exportFbxToFilename(filename); exportFbxToFilename(filename);
} }
@ -1864,6 +1875,7 @@ void DocumentWindow::exportGlbResult()
if (filename.isEmpty()) { if (filename.isEmpty()) {
return; return;
} }
ensureFileExtension(&filename, ".glb");
exportGlbToFilename(filename); exportGlbToFilename(filename);
} }