From d7f3e1afadbe27021aa9cced9953b0171618f69b Mon Sep 17 00:00:00 2001 From: Sebastian Jennen Date: Tue, 7 Feb 2017 18:58:14 +0100 Subject: [PATCH] GetImageFileNameSuggestion - suggests settings file name for image fixes issue #227 --- mandelbulber2/src/render_window_menu.cpp | 12 ++++++------ mandelbulber2/src/system.hpp | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/mandelbulber2/src/render_window_menu.cpp b/mandelbulber2/src/render_window_menu.cpp index 26d083562..4ba8f2463 100644 --- a/mandelbulber2/src/render_window_menu.cpp +++ b/mandelbulber2/src/render_window_menu.cpp @@ -305,7 +305,7 @@ void RenderWindow::slotMenuSaveImageJPEG() dialog.setNameFilter(tr("JPEG images (*.jpg *.jpeg)")); dialog.setDirectory(QDir::toNativeSeparators(QFileInfo(systemData.lastImageFile).absolutePath())); dialog.selectFile( - QDir::toNativeSeparators(QFileInfo(systemData.lastImageFile).completeBaseName())); + QDir::toNativeSeparators(systemData.GetImageFileNameSuggestion())); dialog.setAcceptMode(QFileDialog::AcceptSave); dialog.setWindowTitle(tr("Save image to %1 file...").arg("JPEG")); dialog.setDefaultSuffix("jpeg"); @@ -333,7 +333,7 @@ void RenderWindow::slotMenuSaveImagePNG() dialog.setNameFilter(tr("PNG images (*.png)")); dialog.setDirectory(QDir::toNativeSeparators(QFileInfo(systemData.lastImageFile).absolutePath())); dialog.selectFile( - QDir::toNativeSeparators(QFileInfo(systemData.lastImageFile).completeBaseName())); + QDir::toNativeSeparators(systemData.GetImageFileNameSuggestion())); dialog.setAcceptMode(QFileDialog::AcceptSave); dialog.setWindowTitle(tr("Save image to %1 file...").arg("8-bit PNG")); dialog.setDefaultSuffix("png"); @@ -358,7 +358,7 @@ void RenderWindow::slotMenuSaveImageEXR() dialog.setNameFilter(tr("EXR images (*.exr)")); dialog.setDirectory(QDir::toNativeSeparators(QFileInfo(systemData.lastImageFile).absolutePath())); dialog.selectFile( - QDir::toNativeSeparators(QFileInfo(systemData.lastImageFile).completeBaseName())); + QDir::toNativeSeparators(systemData.GetImageFileNameSuggestion())); dialog.setAcceptMode(QFileDialog::AcceptSave); dialog.setWindowTitle(tr("Save image to %1 file...").arg("EXR")); dialog.setDefaultSuffix("exr"); @@ -384,7 +384,7 @@ void RenderWindow::slotMenuSaveImageTIFF() dialog.setNameFilter(tr("TIFF images (*.tiff)")); dialog.setDirectory(QDir::toNativeSeparators(QFileInfo(systemData.lastImageFile).absolutePath())); dialog.selectFile( - QDir::toNativeSeparators(QFileInfo(systemData.lastImageFile).completeBaseName())); + QDir::toNativeSeparators(systemData.GetImageFileNameSuggestion())); dialog.setAcceptMode(QFileDialog::AcceptSave); dialog.setWindowTitle(tr("Save image to %1 file...").arg("TIFF")); dialog.setDefaultSuffix("tiff"); @@ -409,7 +409,7 @@ void RenderWindow::slotMenuSaveImagePNG16() dialog.setNameFilter(tr("PNG images (*.png)")); dialog.setDirectory(QDir::toNativeSeparators(QFileInfo(systemData.lastImageFile).absolutePath())); dialog.selectFile( - QDir::toNativeSeparators(QFileInfo(systemData.lastImageFile).completeBaseName())); + QDir::toNativeSeparators(systemData.GetImageFileNameSuggestion())); dialog.setAcceptMode(QFileDialog::AcceptSave); dialog.setWindowTitle(tr("Save image to %1 file...").arg("16-bit PNG")); dialog.setDefaultSuffix("png"); @@ -438,7 +438,7 @@ void RenderWindow::slotMenuSaveImagePNG16Alpha() dialog.setNameFilter(tr("PNG images (*.png)")); dialog.setDirectory(QDir::toNativeSeparators(QFileInfo(systemData.lastImageFile).absolutePath())); dialog.selectFile( - QDir::toNativeSeparators(QFileInfo(systemData.lastImageFile).completeBaseName())); + QDir::toNativeSeparators(systemData.GetImageFileNameSuggestion())); dialog.setAcceptMode(QFileDialog::AcceptSave); dialog.setWindowTitle(tr("Save image to %1 file...").arg("16-bit PNG + alpha channel")); dialog.setDefaultSuffix("png"); diff --git a/mandelbulber2/src/system.hpp b/mandelbulber2/src/system.hpp index c47d6ddfc..d14b86a6b 100644 --- a/mandelbulber2/src/system.hpp +++ b/mandelbulber2/src/system.hpp @@ -118,6 +118,20 @@ struct sSystem QString GetAutosaveFile() const { return dataDirectoryHidden + ".autosave.fract"; } QString GetIniFile() const { return dataDirectoryHidden + "mandelbulber.ini"; } + QString GetImageFileNameSuggestion() + { + QString imageBaseName = QFileInfo(lastImageFile).completeBaseName(); + + // if the last image file has been saved manually, this is the suggestion for the filename + if(!lastImageFile.endsWith("image.jpg")) return imageBaseName; + + // otherwise if the settings has been loaded from a proper .fract file, this fileName's basename is the suggestion + if(lastSettingsFile.endsWith(".fract")) return QFileInfo(lastSettingsFile).completeBaseName(); + + // maybe loaded by clipboard, no better suggestion, than the default lastImageFile's baseName + return imageBaseName; + } + QString homedir; QString sharedDir; QString logfileName;