Revise SaveAsDialog::okPressed()
(fixes #3737)
This commit is contained in:
parent
1593335485
commit
b84e570f50
@ -42,10 +42,20 @@
|
|||||||
// Special name for the Dynamic profile
|
// Special name for the Dynamic profile
|
||||||
#define DEFPROFILE_DYNAMIC "Dynamic"
|
#define DEFPROFILE_DYNAMIC "Dynamic"
|
||||||
|
|
||||||
class SaveFormat
|
struct SaveFormat
|
||||||
{
|
{
|
||||||
|
SaveFormat() :
|
||||||
|
format("jpg"),
|
||||||
|
pngBits(8),
|
||||||
|
pngCompression(6),
|
||||||
|
jpegQuality(90),
|
||||||
|
jpegSubSamp(2),
|
||||||
|
tiffBits(8),
|
||||||
|
tiffUncompressed(true),
|
||||||
|
saveParams(true)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
|
||||||
Glib::ustring format;
|
Glib::ustring format;
|
||||||
int pngBits;
|
int pngBits;
|
||||||
int pngCompression;
|
int pngCompression;
|
||||||
@ -54,7 +64,6 @@ public:
|
|||||||
int tiffBits;
|
int tiffBits;
|
||||||
bool tiffUncompressed;
|
bool tiffUncompressed;
|
||||||
bool saveParams;
|
bool saveParams;
|
||||||
SaveFormat () : format("jpg"), pngBits(8), pngCompression(6), jpegQuality(90), jpegSubSamp(2), tiffBits(8), tiffUncompressed(true), saveParams(true) {};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ThFileType {FT_Invalid = -1, FT_None = 0, FT_Raw = 1, FT_Jpeg = 2, FT_Tiff = 3, FT_Png = 4, FT_Custom = 5, FT_Tiff16 = 6, FT_Png16 = 7, FT_Custom16 = 8};
|
enum ThFileType {FT_Invalid = -1, FT_None = 0, FT_Raw = 1, FT_Jpeg = 2, FT_Tiff = 3, FT_Png = 4, FT_Custom = 5, FT_Tiff16 = 6, FT_Png16 = 7, FT_Custom16 = 8};
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
#include "guiutils.h"
|
#include "guiutils.h"
|
||||||
#include "rtimage.h"
|
#include "rtimage.h"
|
||||||
|
|
||||||
|
#include "../rtengine/utils.h"
|
||||||
|
|
||||||
extern Options options;
|
extern Options options;
|
||||||
|
|
||||||
SaveAsDialog::SaveAsDialog (const Glib::ustring &initialDir, Gtk::Window* parent)
|
SaveAsDialog::SaveAsDialog (const Glib::ustring &initialDir, Gtk::Window* parent)
|
||||||
@ -217,41 +219,57 @@ SaveFormat SaveAsDialog::getFormat ()
|
|||||||
|
|
||||||
void SaveAsDialog::okPressed ()
|
void SaveAsDialog::okPressed ()
|
||||||
{
|
{
|
||||||
|
|
||||||
fname = fchooser->get_filename();
|
fname = fchooser->get_filename();
|
||||||
|
|
||||||
// checking if the filename field is empty. The user have to click Cancel if he don't want to specify a filename
|
|
||||||
// NB: There seem to be a bug in Gtkmm2.22 / FileChooserWidget : if you suppress the filename entry and
|
// NB: There seem to be a bug in Gtkmm2.22 / FileChooserWidget : if you suppress the filename entry and
|
||||||
// click on a folder in the list, the filename field is empty but get_filename will return the folder's path :/
|
// click on a folder in the list, the filename field is empty but get_filename will return the folder's path :/
|
||||||
if (!fname.length() || Glib::file_test (fname, Glib::FILE_TEST_IS_DIR)) {
|
if (Glib::file_test(fname, Glib::FILE_TEST_IS_DIR)) {
|
||||||
Glib::ustring msg_ = Glib::ustring("<b>") + M("MAIN_MSG_EMPTYFILENAME") + "</b>";
|
fname = fchooser->get_current_name();
|
||||||
Gtk::MessageDialog msgd (*this, msg_, true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, true);
|
}
|
||||||
msgd.run ();
|
|
||||||
|
// Checking if the filename field is empty. The user have to click Cancel if he don't want to specify a filename
|
||||||
|
if (fname.empty()) {
|
||||||
|
Gtk::MessageDialog(
|
||||||
|
*this,
|
||||||
|
Glib::ustring("<b>")
|
||||||
|
+ M("MAIN_MSG_EMPTYFILENAME")
|
||||||
|
+ "</b>",
|
||||||
|
true,
|
||||||
|
Gtk::MESSAGE_WARNING,
|
||||||
|
Gtk::BUTTONS_OK,
|
||||||
|
true
|
||||||
|
).run();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// resolve extension ambiguities
|
if (getExtension(fname).empty()) {
|
||||||
SaveFormat sf = formatOpts->getFormat ();
|
// Extension is either empty or unfamiliar
|
||||||
Glib::ustring extLower = getExtension (fname).lowercase ();
|
fname += '.' + formatOpts->getFormat().format;
|
||||||
bool extIsEmpty = (extLower == "");
|
} else if (
|
||||||
bool extIsJpeg = (extLower == "jpg" || extLower == "jpeg" || extLower == "jpe");
|
!rtengine::hasJpegExtension(fname)
|
||||||
bool extIsTiff = (extLower == "tif" || extLower == "tiff");
|
&& !rtengine::hasTiffExtension(fname)
|
||||||
bool extIsPng = (extLower == "png");
|
&& !rtengine::hasPngExtension(fname)
|
||||||
|
) {
|
||||||
|
// Create dialog to warn user that the filename may have two extensions on the end
|
||||||
|
Gtk::MessageDialog msgd(
|
||||||
|
*this,
|
||||||
|
Glib::ustring("<b>")
|
||||||
|
+ M("GENERAL_WARNING")
|
||||||
|
+ ": "
|
||||||
|
+ M("SAVEDLG_WARNFILENAME")
|
||||||
|
+ " \""
|
||||||
|
+ Glib::path_get_basename (fname)
|
||||||
|
+ '.'
|
||||||
|
+ formatOpts->getFormat().format
|
||||||
|
+ "\"</b>",
|
||||||
|
true,
|
||||||
|
Gtk::MESSAGE_WARNING,
|
||||||
|
Gtk::BUTTONS_OK_CANCEL,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
if (extIsEmpty || !(extIsJpeg || extIsTiff || extIsPng)) {
|
if (msgd.run() == Gtk::RESPONSE_OK) {
|
||||||
// extension is either empty or unfamiliar.
|
fname += "." + formatOpts->getFormat().format;
|
||||||
fname += Glib::ustring (".") + sf.format;
|
|
||||||
} else if ( !(sf.format == "jpg" && extIsJpeg)
|
|
||||||
&& !(sf.format == "tif" && extIsTiff)
|
|
||||||
&& !(sf.format == "png" && extIsPng ) ) {
|
|
||||||
// create dialog to warn user that the filename may have two extensions on the end.
|
|
||||||
Glib::ustring msg_ = Glib::ustring ("<b>") + M("GENERAL_WARNING") + ": "
|
|
||||||
+ M("SAVEDLG_WARNFILENAME") + " \"" + Glib::path_get_basename (fname)
|
|
||||||
+ "." + sf.format + "\"</b>";
|
|
||||||
Gtk::MessageDialog msgd (*this, msg_, true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK_CANCEL, true);
|
|
||||||
|
|
||||||
if (msgd.run () == Gtk::RESPONSE_OK) {
|
|
||||||
fname += Glib::ustring (".") + sf.format;
|
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user