Add a GUI Preference option (Default: yes) to show the overwrite dialog for regular file output or not.

This commit is contained in:
Joseph Lenox 2021-08-26 20:13:33 -05:00 committed by supermerill
parent eb65557479
commit 49c301e0c0
5 changed files with 21 additions and 8 deletions

View File

@ -69,6 +69,9 @@ void AppConfig::set_defaults()
if (get("freecad_path").empty())
set("freecad_path", ".");
if (get("show_overwrite_dialog").empty())
set("show_overwrite_dialog", "1");
if (get("tab_icon_size").empty())
set("tab_icon_size", "32");

View File

@ -123,6 +123,8 @@ public:
std::string get_last_output_dir(const std::string& alt, const bool removable = false) const;
void update_last_output_dir(const std::string &dir, const bool removable = false);
bool get_show_overwrite_dialog() const { return get("show_overwrite_dialog") != "0"; }
// reset the current print / filament / printer selections, so that
// the PresetBundle::load_selections(const AppConfig &config) call will select
// the first non-default preset when called.

View File

@ -1700,7 +1700,7 @@ void MainFrame::quick_slice(const int qs)
wxFileDialog dlg(this, from_u8((boost::format(_utf8(L("Save %s file as:"))) % ((qs & qsExportSVG) ? _L("SVG") : _L("G-code"))).str()),
wxGetApp().app_config->get_last_output_dir(get_dir_name(output_file)), get_base_name(input_file),
qs & qsExportSVG ? file_wildcards(FT_SVG) : file_wildcards(FT_GCODE),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
wxFD_SAVE | (wxGetApp().app_config->get_show_overwrite_dialog() ? wxFD_OVERWRITE_PROMPT : 0));
if (dlg.ShowModal() != wxID_OK)
return;
output_file = dlg.GetPath();
@ -1711,7 +1711,7 @@ void MainFrame::quick_slice(const int qs)
else if (qs & qsExportPNG) {
wxFileDialog dlg(this, _L("Save zip file as:"),
wxGetApp().app_config->get_last_output_dir(get_dir_name(output_file)),
get_base_name(output_file), "*.sl1", wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
get_base_name(output_file), "*.sl1", wxFD_SAVE | (wxGetApp().app_config->get_show_overwrite_dialog() ? wxFD_OVERWRITE_PROMPT : 0));
if (dlg.ShowModal() != wxID_OK)
return;
output_file = dlg.GetPath();
@ -1773,7 +1773,7 @@ void MainFrame::repair_stl()
{
wxFileDialog dlg( this, L("Save OBJ file (less prone to coordinate errors than STL) as:"),
get_dir_name(output_file), get_base_name(output_file, ".obj"),
file_wildcards(FT_OBJ), wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
file_wildcards(FT_OBJ), wxFD_SAVE | (wxGetApp().app_config->get_show_overwrite_dialog() ? wxFD_OVERWRITE_PROMPT : 0));
if (dlg.ShowModal() != wxID_OK)
return;
output_file = dlg.GetPath();

View File

@ -2750,7 +2750,7 @@ wxString Plater::priv::get_export_file(GUI::FileType file_type)
wxFileDialog dlg(q, dlg_title,
from_path(output_file.parent_path()), from_path(output_file.filename()),
wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
wildcard, wxFD_SAVE |(wxGetApp().app_config->get_show_overwrite_dialog() ? wxFD_OVERWRITE_PROMPT : 0) );
if (dlg.ShowModal() != wxID_OK)
return wxEmptyString;
@ -5532,12 +5532,12 @@ void Plater::export_gcode(bool prefer_removable)
fs::path output_path;
{
std::string ext = default_output_file.extension().string();
std::string ext = default_output_file.extension().string();
wxFileDialog dlg(this, (printer_technology() == ptFFF) ? _L("Save G-code file as:") : _L("Save SL1 / SL1S file as:"),
start_dir,
from_path(default_output_file.filename()),
GUI::file_wildcards((printer_technology() == ptFFF) ? FT_GCODE : boost::iequals(ext, ".sl1s") ? FT_SL1S : FT_SL1, ext),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT
wxFD_SAVE | (wxGetApp().app_config->get_show_overwrite_dialog() ? wxFD_OVERWRITE_PROMPT : 0)
);
if (dlg.ShowModal() == wxID_OK)
output_path = into_path(dlg.GetPath());

View File

@ -215,6 +215,13 @@ void PreferencesDialog::build()
option = Option(def, "show_drop_project_dialog");
m_optgroups_general.back()->append_single_option_line(option);
def.label = L("Show overwrite dialog.");
def.type = coBool;
def.tooltip = L("If this is enabled, Slic3r will prompt for when overwriting files from save dialogs.");
def.set_default_value(new ConfigOptionBool{ app_config->has("show_overwrite_dialog") ? app_config->get("show_overwrite_dialog") == "1" : true });
option = Option(def, "show_overwrite_dialog");
m_optgroups_general.back()->append_single_option_line(option);
#if __APPLE__
def.label = (boost::format(_u8L("Allow just a single %1% instance")) % SLIC3R_APP_NAME).str();
@ -550,8 +557,9 @@ void PreferencesDialog::build()
void PreferencesDialog::accept()
{
if (m_values.find("no_defaults") != m_values.end())
warning_catcher(this, wxString::Format(_L("You need to restart %s to make the changes effective."), SLIC3R_APP_NAME));
if (m_values.find("no_defaults") != m_values.end()) {
warning_catcher(this, wxString::Format(_L("You need to restart %s to make the changes effective."), SLIC3R_APP_NAME));
}
auto app_config = get_app_config();