From d4a7548aa930730426b415f5352d1a0e1bf33c62 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 25 Oct 2023 15:48:14 +0200 Subject: [PATCH 1/4] Exporting ASCII G-code with binary G-code extension or vice versa is now an error #11498 --- src/slic3r/GUI/Plater.cpp | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 748412d770..d1d69e23da 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -6743,9 +6743,36 @@ void Plater::export_gcode(bool prefer_removable) ); if (dlg.ShowModal() == wxID_OK) { output_path = into_path(dlg.GetPath()); - while (has_illegal_filename_characters(output_path.filename().string())) { - show_error(this, _L("The provided file name is not valid.") + "\n" + - _L("The following characters are not allowed by a FAT file system:") + " <>:/\\|?*\""); + + auto check_for_error = [this](const boost::filesystem::path& path, wxString& err_out) -> bool { + const std::string filename = path.filename().string(); + const std::string ext = boost::algorithm::to_lower_copy(path.extension().string()); + if (has_illegal_filename_characters(filename)) { + err_out = _L("The provided file name is not valid.") + "\n" + + _L("The following characters are not allowed by a FAT file system:") + " <>:/\\|?*\""; + return true; + } + if (printer_technology() == ptFFF) { + const bool binary_output = wxGetApp().preset_bundle->prints.get_edited_preset().config.opt_bool("gcode_binary"); + const bool binary_extension = (ext == ".bgcode" || ext == ".bgc"); + const bool ascii_extension = (ext == ".gcode" || ext == ".g" || ext == ".gco"); + if (binary_output && ascii_extension) { + // TRN The placeholder is the file extension the user has selected. + err_out = format_wxstr(_L("Cannot save binary G-code with %1% extension.\n\nUse a different extension or disable binary G-code export in Print Settings."), ext); + return true; + } + if (! binary_output && binary_extension) { + // TRN The placeholder is the file extension the user has selected. + err_out = format_wxstr(_L("Cannot save ASCII G-code with %1% extension.\n\nUse a different extension or enable binary G-code export in Print Settings."), ext); + return true; + } + } + return false; + }; + + wxString error_str; + while (check_for_error(output_path, error_str)) { + show_error(this, error_str); dlg.SetFilename(from_path(output_path.filename())); if (dlg.ShowModal() == wxID_OK) output_path = into_path(dlg.GetPath()); From 34848f0fc0664614869274e14f455c4b2c6567df Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 1 Nov 2023 12:15:45 +0100 Subject: [PATCH 2/4] Improvement for error massage about binary/ascii G-code extension during saving G-code (Error massage contains links to related options in Settings Tabs now) + Suppress a showing a SaveFileDialog in loop while name isn't correct. + ErrorDialog is extended to use specified function to process a clicked link --- src/slic3r/GUI/MsgDialog.cpp | 69 ++++++++++++++++++++++-------------- src/slic3r/GUI/MsgDialog.hpp | 13 ++++++- src/slic3r/GUI/Plater.cpp | 42 +++++++++++++++++++--- src/slic3r/GUI/Plater.hpp | 2 ++ 4 files changed, 95 insertions(+), 31 deletions(-) diff --git a/src/slic3r/GUI/MsgDialog.cpp b/src/slic3r/GUI/MsgDialog.cpp index 0b8d609b94..2946a9c149 100644 --- a/src/slic3r/GUI/MsgDialog.cpp +++ b/src/slic3r/GUI/MsgDialog.cpp @@ -122,21 +122,20 @@ void MsgDialog::finalize() this->CenterOnParent(); } - // Text shown as HTML, so that mouse selection and Ctrl-V to copy will work. -static void add_msg_content(wxWindow* parent, wxBoxSizer* content_sizer, wxString msg, bool monospaced_font = false, bool is_marked_msg = false) +static void add_msg_content(MsgDialog* parent, wxBoxSizer* content_sizer, const HtmlContent& content) { wxHtmlWindow* html = new wxHtmlWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO); // count lines in the message int msg_lines = 0; - if (!monospaced_font) { + if (!content.is_monospaced_font) { int line_len = 55;// count of symbols in one line int start_line = 0; - for (auto i = msg.begin(); i != msg.end(); ++i) { + for (auto i = content.msg.begin(); i != content.msg.end(); ++i) { if (*i == '\n') { - int cur_line_len = i - msg.begin() - start_line; - start_line = i - msg.begin(); + int cur_line_len = i - content.msg.begin() - start_line; + start_line = i - content.msg.begin(); if (cur_line_len == 0 || line_len > cur_line_len) msg_lines++; else @@ -175,11 +174,11 @@ static void add_msg_content(wxWindow* parent, wxBoxSizer* content_sizer, wxStrin } // if message containes the table - if (msg.Contains("")) { - int lines = msg.Freq('\n') + 1; + if (content.msg.Contains("")) { + int lines = content.msg.Freq('\n') + 1; int pos = 0; - while (pos < (int)msg.Len() && pos != wxNOT_FOUND) { - pos = msg.find("", pos + 1); + while (pos < (int)content.msg.Len() && pos != wxNOT_FOUND) { + pos = content.msg.find("", pos + 1); lines += 2; } int page_height = std::min(int(font.GetPixelSize().y+2) * lines, 68 * em); @@ -187,16 +186,16 @@ static void add_msg_content(wxWindow* parent, wxBoxSizer* content_sizer, wxStrin } else { wxClientDC dc(parent); - wxSize msg_sz = dc.GetMultiLineTextExtent(msg); + wxSize msg_sz = dc.GetMultiLineTextExtent(content.msg); page_size = wxSize(std::min(msg_sz.GetX() + 2 * em, 68 * em), std::min(msg_sz.GetY() + 2 * em, 68 * em)); } html->SetMinSize(page_size); - std::string msg_escaped = xml_escape(into_u8(msg), is_marked_msg); + std::string msg_escaped = xml_escape(into_u8(content.msg), content.is_marked_msg || content.on_link_clicked); boost::replace_all(msg_escaped, "\r\n", "
"); boost::replace_all(msg_escaped, "\n", "
"); - if (monospaced_font) + if (content.is_monospaced_font) // Code formatting will be preserved. This is useful for reporting errors from the placeholder parser. msg_escaped = std::string("
") + msg_escaped + "
"; html->SetPage(format_wxstr("" @@ -208,8 +207,13 @@ static void add_msg_content(wxWindow* parent, wxBoxSizer* content_sizer, wxStrin "", bgr_clr_str, text_clr_str, from_u8(msg_escaped))); - html->Bind(wxEVT_HTML_LINK_CLICKED, [parent](wxHtmlLinkEvent& event) { - wxGetApp().open_browser_with_warning_dialog(event.GetLinkInfo().GetHref(), parent, false); + html->Bind(wxEVT_HTML_LINK_CLICKED, [parent, &content](wxHtmlLinkEvent& event) { + if (content.on_link_clicked) { + parent->EndModal(wxID_CLOSE); + content.on_link_clicked(into_u8(event.GetLinkInfo().GetHref())); + } + else + wxGetApp().open_browser_with_warning_dialog(event.GetLinkInfo().GetHref(), parent, false); event.Skip(false); }); @@ -219,21 +223,34 @@ static void add_msg_content(wxWindow* parent, wxBoxSizer* content_sizer, wxStrin // ErrorDialog -ErrorDialog::ErrorDialog(wxWindow *parent, const wxString &msg, bool monospaced_font) - : MsgDialog(parent, wxString::Format(_(L("%s error")), SLIC3R_APP_NAME), - wxString::Format(_(L("%s has encountered an error")), SLIC3R_APP_NAME), wxOK) - , msg(msg) +void ErrorDialog::create(const HtmlContent& content, int icon_width) { - add_msg_content(this, content_sizer, msg, monospaced_font); + add_msg_content(this, content_sizer, content); - // Use a small bitmap with monospaced font, as the error text will not be wrapped. - logo->SetBitmap(*get_bmp_bundle("PrusaSlicer_192px_grayscale.png", monospaced_font ? 48 : /*1*/84)); + // Use a small bitmap with monospaced font, as the error text will not be wrapped. + logo->SetBitmap(*get_bmp_bundle("PrusaSlicer_192px_grayscale.png", icon_width)); SetMaxSize(wxSize(-1, CONTENT_MAX_HEIGHT*wxGetApp().em_unit())); finalize(); } +ErrorDialog::ErrorDialog(wxWindow *parent, const wxString &msg, bool monospaced_font) + : MsgDialog(parent, wxString::Format(_L("%s error"), SLIC3R_APP_NAME), + wxString::Format(_L("%s has encountered an error"), SLIC3R_APP_NAME), wxOK) + , m_content(HtmlContent{ msg, monospaced_font, true }) +{ + create(m_content, monospaced_font ? 48 : 84); +} + +ErrorDialog::ErrorDialog(wxWindow *parent, const wxString &msg, const std::function &on_link_clicked) + : MsgDialog(parent, wxString::Format(_L("%s error"), SLIC3R_APP_NAME), + wxString::Format(_L("%s has encountered an error"), SLIC3R_APP_NAME), wxOK) + , m_content(HtmlContent{ msg, false, true, on_link_clicked }) +{ + create(m_content, 84); +} + // WarningDialog WarningDialog::WarningDialog(wxWindow *parent, @@ -243,7 +260,7 @@ WarningDialog::WarningDialog(wxWindow *parent, : MsgDialog(parent, caption.IsEmpty() ? wxString::Format(_L("%s warning"), SLIC3R_APP_NAME) : caption, wxString::Format(_L("%s has a warning")+":", SLIC3R_APP_NAME), style) { - add_msg_content(this, content_sizer, message); + add_msg_content(this, content_sizer, HtmlContent{ message }); finalize(); } @@ -256,7 +273,7 @@ MessageDialog::MessageDialog(wxWindow* parent, long style/* = wxOK*/) : MsgDialog(parent, caption.IsEmpty() ? wxString::Format(_L("%s info"), SLIC3R_APP_NAME) : caption, wxEmptyString, style) { - add_msg_content(this, content_sizer, get_wraped_wxString(message)); + add_msg_content(this, content_sizer, HtmlContent{ get_wraped_wxString(message) }); finalize(); } @@ -269,7 +286,7 @@ RichMessageDialog::RichMessageDialog(wxWindow* parent, long style/* = wxOK*/) : MsgDialog(parent, caption.IsEmpty() ? wxString::Format(_L("%s info"), SLIC3R_APP_NAME) : caption, wxEmptyString, style) { - add_msg_content(this, content_sizer, get_wraped_wxString(message)); + add_msg_content(this, content_sizer, HtmlContent{ get_wraped_wxString(message) }); m_checkBox = new ::CheckBox(this, m_checkBoxText); wxGetApp().UpdateDarkUI(m_checkBox); @@ -298,7 +315,7 @@ InfoDialog::InfoDialog(wxWindow* parent, const wxString &title, const wxString& : MsgDialog(parent, wxString::Format(_L("%s information"), SLIC3R_APP_NAME), title, style) , msg(msg) { - add_msg_content(this, content_sizer, msg, false, is_marked_msg); + add_msg_content(this, content_sizer, HtmlContent{ msg, false, is_marked_msg }); finalize(); } diff --git a/src/slic3r/GUI/MsgDialog.hpp b/src/slic3r/GUI/MsgDialog.hpp index 96c7703755..66ee97f911 100644 --- a/src/slic3r/GUI/MsgDialog.hpp +++ b/src/slic3r/GUI/MsgDialog.hpp @@ -24,6 +24,14 @@ namespace Slic3r { namespace GUI { +struct HtmlContent +{ + wxString msg{ wxEmptyString }; + bool is_monospaced_font{ false }; + bool is_marked_msg{ false }; + std::function on_link_clicked{ nullptr }; +}; + // A message / query dialog with a bitmap on the left and any content on the right // with buttons underneath. struct MsgDialog : wxDialog @@ -67,6 +75,7 @@ public: // If monospaced_font is true, the error message is displayed using html
tags, // so that the code formatting will be preserved. This is useful for reporting errors from the placeholder parser. ErrorDialog(wxWindow *parent, const wxString &msg, bool courier_font); + ErrorDialog(wxWindow *parent, const wxString &msg, const std::function& on_link_clicked); ErrorDialog(ErrorDialog &&) = delete; ErrorDialog(const ErrorDialog &) = delete; ErrorDialog &operator=(ErrorDialog &&) = delete; @@ -74,7 +83,9 @@ public: virtual ~ErrorDialog() = default; private: - wxString msg; + void create(const HtmlContent& content, int icon_width); + + HtmlContent m_content; }; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index d1d69e23da..6f16b389b7 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1243,6 +1243,29 @@ void Sidebar::search() p->searcher.search(); } +void Sidebar::jump_to_option(const std::string& composite_key) +{ + const auto separator_pos = composite_key.find(";"); + const std::string opt_key = composite_key.substr(0, separator_pos); + const std::string tab_name = composite_key.substr(separator_pos + 1, composite_key.length()); + + for (Tab* tab : wxGetApp().tabs_list) { + if (tab->name() == tab_name) { + check_and_update_searcher(true); + + // Regularly searcher is sorted in respect to the options labels, + // so resort searcher before get an option + p->searcher.sort_options_by_key(); + const Search::Option& opt = p->searcher.get_option(opt_key, tab->type()); + tab->activate_option(opt_key, boost::nowide::narrow(opt.category)); + + // Revert sort of searcher back + p->searcher.sort_options_by_label(); + break; + } + } +} + void Sidebar::jump_to_option(const std::string& opt_key, Preset::Type type, const std::wstring& category) { //const Search::Option& opt = p->searcher.get_option(opt_key, type); @@ -6757,13 +6780,17 @@ void Plater::export_gcode(bool prefer_removable) const bool binary_extension = (ext == ".bgcode" || ext == ".bgc"); const bool ascii_extension = (ext == ".gcode" || ext == ".g" || ext == ".gco"); if (binary_output && ascii_extension) { - // TRN The placeholder is the file extension the user has selected. - err_out = format_wxstr(_L("Cannot save binary G-code with %1% extension.\n\nUse a different extension or disable binary G-code export in Print Settings."), ext); + // TRN The placeholder %1% is the file extension the user has selected. + err_out = format_wxstr(_L("Cannot save binary G-code with %1% extension.\n\n" + "Use a different extension or disable binary G-code export " + "in Print Settings."), ext, "output_filename_format;print", "gcode_binary;print"); return true; } if (! binary_output && binary_extension) { - // TRN The placeholder is the file extension the user has selected. - err_out = format_wxstr(_L("Cannot save ASCII G-code with %1% extension.\n\nUse a different extension or enable binary G-code export in Print Settings."), ext); + // TRN The placeholder %1% is the file extension the user has selected. + err_out = format_wxstr(_L("Cannot save ASCII G-code with %1% extension.\n\n" + "Use a different extension or enable binary G-code export " + "in Print Settings."), ext, "output_filename_format;print", "gcode_binary;print"); return true; } } @@ -6771,6 +6798,12 @@ void Plater::export_gcode(bool prefer_removable) }; wxString error_str; +#if 1 // #ysFIXME > clear code after testing + if (check_for_error(output_path, error_str)) { + ErrorDialog(this, error_str, [this](const std::string& key) -> void { sidebar().jump_to_option(key); }).ShowModal(); + output_path.clear(); + } +#else while (check_for_error(output_path, error_str)) { show_error(this, error_str); dlg.SetFilename(from_path(output_path.filename())); @@ -6781,6 +6814,7 @@ void Plater::export_gcode(bool prefer_removable) break; } } +#endif } } diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 46ffcefbac..46d21cef69 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -102,6 +102,8 @@ public: void search(); void jump_to_option(size_t selected); void jump_to_option(const std::string& opt_key, Preset::Type type, const std::wstring& category); + // jump to option which is represented by composite key : "opt_key;tab_name" + void jump_to_option(const std::string& composite_key); ObjectManipulation* obj_manipul(); ObjectList* obj_list(); From 0504747f2641b24f1ef0705638e4500ca7240a67 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 1 Nov 2023 14:51:26 +0100 Subject: [PATCH 3/4] PrintHostSendDialog: Extended validation of the path extension in respect to "Export as binary G-code" value --- src/slic3r/GUI/PrintHostDialogs.cpp | 39 ++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/PrintHostDialogs.cpp b/src/slic3r/GUI/PrintHostDialogs.cpp index 968e1486ad..11b71878e3 100644 --- a/src/slic3r/GUI/PrintHostDialogs.cpp +++ b/src/slic3r/GUI/PrintHostDialogs.cpp @@ -25,6 +25,7 @@ #include "GUI.hpp" #include "GUI_App.hpp" +#include "Plater.hpp" #include "MsgDialog.hpp" #include "I18N.hpp" #include "MainFrame.hpp" @@ -105,11 +106,43 @@ PrintHostSendDialog::PrintHostSendDialog(const fs::path &path, PrintHostPostUplo m_valid_suffix = recent_path.substr(extension_start); // .gcode suffix control auto validate_path = [this](const wxString &path) -> bool { - if (! path.Lower().EndsWith(m_valid_suffix.Lower())) { - MessageDialog msg_wingow(this, wxString::Format(_L("Upload filename doesn't end with \"%s\". Do you wish to continue?"), m_valid_suffix), wxString(SLIC3R_APP_NAME), wxYES | wxNO); - if (msg_wingow.ShowModal() == wxID_NO) + + if (wxGetApp().plater()->printer_technology() == ptFFF) { + const std::string ext = boost::algorithm::to_lower_copy(into_path(path).extension().string()); + const bool binary_output = wxGetApp().preset_bundle->prints.get_edited_preset().config.opt_bool("gcode_binary"); + const bool binary_extension = (ext == ".bgcode" || ext == ".bgc"); + const bool ascii_extension = (ext == ".gcode" || ext == ".g" || ext == ".gco"); + wxString err_out; + if (binary_output && ascii_extension) { + // TRN The placeholder %1% is the file extension the user has selected. + err_out = format_wxstr(_L("Cannot upload binary G-code with %1% extension.\n\n" + "Use a different extension or disable binary G-code export " + "in Print Settings."), ext, "output_filename_format;print", "gcode_binary;print"); + } + if (!binary_output && binary_extension) { + // TRN The placeholder %1% is the file extension the user has selected. + err_out = format_wxstr(_L("Cannot upload ASCII G-code with %1% extension.\n\n" + "Use a different extension or enable binary G-code export " + "in Print Settings."), ext, "output_filename_format;print", "gcode_binary;print"); + } + if (!err_out.IsEmpty()) { + ErrorDialog(this, err_out, t_kill_focus([](const std::string& key) -> void { wxGetApp().sidebar().jump_to_option(key); })).ShowModal(); return false; + } + + if (!m_valid_suffix.IsEmpty()) { + if (binary_output && m_valid_suffix != ".bgcode" && m_valid_suffix != ".bgc") + m_valid_suffix = ".bgcode"; + else if (!binary_output && m_valid_suffix != ".gcode" && m_valid_suffix != ".gco") + m_valid_suffix = ".gcode"; + } } + + if (!path.Lower().EndsWith(m_valid_suffix.Lower())) { + MessageDialog msg_wingow(this, wxString::Format(_L("Upload filename doesn't end with \"%s\". Do you wish to continue?"), m_valid_suffix), wxString(SLIC3R_APP_NAME), wxYES | wxNO); + return msg_wingow.ShowModal() == wxID_YES; + } + return true; }; From f238f56b5b6366129dba3be1453bcd177b6fd36a Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Fri, 3 Nov 2023 14:08:22 +0100 Subject: [PATCH 4/4] Further polishing the gcode/bgcode error logic --- src/slic3r/GUI/Plater.cpp | 59 +++++++++++++++++++---------- src/slic3r/GUI/PrintHostDialogs.cpp | 33 ---------------- 2 files changed, 39 insertions(+), 53 deletions(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 6f16b389b7..71c7732bec 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -6711,6 +6711,32 @@ void Plater::apply_cut_object_to_model(size_t obj_idx, const ModelObjectPtrs& ne w.wait_for_idle(); } + + +wxString check_binary_vs_ascii_gcode_extension(PrinterTechnology pt, const std::string& ext, bool binary_output) +{ + wxString err_out; + if (pt == ptFFF) { + const bool binary_extension = (ext == ".bgcode" || ext == ".bgc"); + const bool ascii_extension = (ext == ".gcode" || ext == ".g" || ext == ".gco"); + if (binary_output && ascii_extension) { + // TRN The placeholder %1% is the file extension the user has selected. + err_out = format_wxstr(_L("Cannot save binary G-code with %1% extension.\n\n" + "Use a different extension or disable binary G-code export " + "in Print Settings."), ext, "output_filename_format;print", "gcode_binary;print"); + } + if (!binary_output && binary_extension) { + // TRN The placeholder %1% is the file extension the user has selected. + err_out = format_wxstr(_L("Cannot save ASCII G-code with %1% extension.\n\n" + "Use a different extension or enable binary G-code export " + "in Print Settings."), ext, "output_filename_format;print", "gcode_binary;print"); + } + } + return err_out; +} + + + void Plater::export_gcode(bool prefer_removable) { if (p->model.objects.empty()) @@ -6775,26 +6801,8 @@ void Plater::export_gcode(bool prefer_removable) _L("The following characters are not allowed by a FAT file system:") + " <>:/\\|?*\""; return true; } - if (printer_technology() == ptFFF) { - const bool binary_output = wxGetApp().preset_bundle->prints.get_edited_preset().config.opt_bool("gcode_binary"); - const bool binary_extension = (ext == ".bgcode" || ext == ".bgc"); - const bool ascii_extension = (ext == ".gcode" || ext == ".g" || ext == ".gco"); - if (binary_output && ascii_extension) { - // TRN The placeholder %1% is the file extension the user has selected. - err_out = format_wxstr(_L("Cannot save binary G-code with %1% extension.\n\n" - "Use a different extension or disable binary G-code export " - "in Print Settings."), ext, "output_filename_format;print", "gcode_binary;print"); - return true; - } - if (! binary_output && binary_extension) { - // TRN The placeholder %1% is the file extension the user has selected. - err_out = format_wxstr(_L("Cannot save ASCII G-code with %1% extension.\n\n" - "Use a different extension or enable binary G-code export " - "in Print Settings."), ext, "output_filename_format;print", "gcode_binary;print"); - return true; - } - } - return false; + err_out = check_binary_vs_ascii_gcode_extension(printer_technology(), ext, wxGetApp().preset_bundle->prints.get_edited_preset().config.opt_bool("gcode_binary")); + return !err_out.IsEmpty(); }; wxString error_str; @@ -7361,6 +7369,17 @@ void Plater::send_gcode() PrintHostSendDialog dlg(default_output_file, upload_job.printhost->get_post_upload_actions(), groups, storage_paths, storage_names); if (dlg.ShowModal() == wxID_OK) { + + { + const std::string ext = boost::algorithm::to_lower_copy(dlg.filename().extension().string()); + const bool binary_output = wxGetApp().preset_bundle->prints.get_edited_preset().config.opt_bool("gcode_binary"); + const wxString error_str = check_binary_vs_ascii_gcode_extension(printer_technology(), ext, binary_output); + if (! error_str.IsEmpty()) { + ErrorDialog(this, error_str, t_kill_focus([](const std::string& key) -> void { wxGetApp().sidebar().jump_to_option(key); })).ShowModal(); + return; + } + } + upload_job.upload_data.upload_path = dlg.filename(); upload_job.upload_data.post_action = dlg.post_action(); upload_job.upload_data.group = dlg.group(); diff --git a/src/slic3r/GUI/PrintHostDialogs.cpp b/src/slic3r/GUI/PrintHostDialogs.cpp index 11b71878e3..e885d3f724 100644 --- a/src/slic3r/GUI/PrintHostDialogs.cpp +++ b/src/slic3r/GUI/PrintHostDialogs.cpp @@ -106,43 +106,10 @@ PrintHostSendDialog::PrintHostSendDialog(const fs::path &path, PrintHostPostUplo m_valid_suffix = recent_path.substr(extension_start); // .gcode suffix control auto validate_path = [this](const wxString &path) -> bool { - - if (wxGetApp().plater()->printer_technology() == ptFFF) { - const std::string ext = boost::algorithm::to_lower_copy(into_path(path).extension().string()); - const bool binary_output = wxGetApp().preset_bundle->prints.get_edited_preset().config.opt_bool("gcode_binary"); - const bool binary_extension = (ext == ".bgcode" || ext == ".bgc"); - const bool ascii_extension = (ext == ".gcode" || ext == ".g" || ext == ".gco"); - wxString err_out; - if (binary_output && ascii_extension) { - // TRN The placeholder %1% is the file extension the user has selected. - err_out = format_wxstr(_L("Cannot upload binary G-code with %1% extension.\n\n" - "Use a different extension or disable binary G-code export " - "in Print Settings."), ext, "output_filename_format;print", "gcode_binary;print"); - } - if (!binary_output && binary_extension) { - // TRN The placeholder %1% is the file extension the user has selected. - err_out = format_wxstr(_L("Cannot upload ASCII G-code with %1% extension.\n\n" - "Use a different extension or enable binary G-code export " - "in Print Settings."), ext, "output_filename_format;print", "gcode_binary;print"); - } - if (!err_out.IsEmpty()) { - ErrorDialog(this, err_out, t_kill_focus([](const std::string& key) -> void { wxGetApp().sidebar().jump_to_option(key); })).ShowModal(); - return false; - } - - if (!m_valid_suffix.IsEmpty()) { - if (binary_output && m_valid_suffix != ".bgcode" && m_valid_suffix != ".bgc") - m_valid_suffix = ".bgcode"; - else if (!binary_output && m_valid_suffix != ".gcode" && m_valid_suffix != ".gco") - m_valid_suffix = ".gcode"; - } - } - if (!path.Lower().EndsWith(m_valid_suffix.Lower())) { MessageDialog msg_wingow(this, wxString::Format(_L("Upload filename doesn't end with \"%s\". Do you wish to continue?"), m_valid_suffix), wxString(SLIC3R_APP_NAME), wxYES | wxNO); return msg_wingow.ShowModal() == wxID_YES; } - return true; };