Skip to content

Commit

Permalink
Add a GUI Preference option (Default: yes) to show the overwrite dial…
Browse files Browse the repository at this point in the history
…og for regular file output or not.
  • Loading branch information
lordofhyphens authored and supermerill committed Sep 6, 2021
1 parent b1361d4 commit 2795295
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/libslic3r/AppConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
2 changes: 2 additions & 0 deletions src/libslic3r/AppConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ class AppConfig
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.
Expand Down
6 changes: 3 additions & 3 deletions src/slic3r/GUI/MainFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions src/slic3r/GUI/Plater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
7 changes: 7 additions & 0 deletions src/slic3r/GUI/Preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,13 @@ void PreferencesDialog::build()
option = Option(def, "show_drop_project_dialog");
m_optgroup_general->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_optgroup_general->append_single_option_line(option);


#if __APPLE__
def.label = (boost::format(_u8L("Allow just a single %1% instance")) % SLIC3R_APP_NAME).str();
Expand Down

0 comments on commit 2795295

Please sign in to comment.