From c7783a58911e68fab46986b842d7d4ca5cb20040 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Mon, 23 Jan 2023 16:06:00 +0100 Subject: [PATCH] Fix for #6377 - Prevent 3mf files from overwriting filament/printer settings + Ask about action on load of project even if print bed isn't empty --- src/slic3r/GUI/GUI_App.cpp | 7 +++++++ src/slic3r/GUI/Plater.cpp | 8 ++++++-- src/slic3r/GUI/Preferences.cpp | 6 ++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index e9c912da21..e75f8836d2 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -772,8 +772,15 @@ void GUI_App::post_init() this->mainframe->load_config_file(this->init_params->load_configs.back()); // If loading a 3MF file, the config is loaded from the last one. if (!this->init_params->input_files.empty()) { +#if 1 // #ysFIXME_delete_after_test_of + wxArrayString fns; + for (const std::string& name : this->init_params->input_files) + fns.Add(from_u8(name)); + if (plater()->load_files(fns) && this->init_params->input_files.size() == 1) { +#else const std::vector res = this->plater()->load_files(this->init_params->input_files, true, true); if (!res.empty() && this->init_params->input_files.size() == 1) { +#endif // Update application titlebar when opening a project file const std::string& filename = this->init_params->input_files.front(); if (boost::algorithm::iends_with(filename, ".amf") || diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index af04d5865a..0aad65ba15 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -6010,7 +6010,9 @@ protected: ProjectDropDialog::ProjectDropDialog(const std::string& filename) : DPIDialog(static_cast(wxGetApp().mainframe), wxID_ANY, - from_u8((boost::format(_utf8(L("%s - Drop project file"))) % SLIC3R_APP_NAME).str()), wxDefaultPosition, +// #ysFIXME_delete_after_test_of_6377 +// from_u8((boost::format(_utf8(L("%s - Drop project file"))) % SLIC3R_APP_NAME).str()), wxDefaultPosition, + from_u8((boost::format(_utf8(L("%s - Load project file"))) % SLIC3R_APP_NAME).str()), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE) { SetFont(wxGetApp().normal_font()); @@ -6118,7 +6120,7 @@ bool Plater::load_files(const wxArrayString& filenames, bool delete_after_load/* std::string filename = (*it).filename().string(); if (boost::algorithm::iends_with(filename, ".3mf") || boost::algorithm::iends_with(filename, ".amf")) { ProjectDropDialog::LoadType load_type = ProjectDropDialog::LoadType::Unknown; - if (!model().objects.empty()) { +// if (!model().objects.empty()) { // #ysFIXME_delete_after_test_of_6377 if ((boost::algorithm::iends_with(filename, ".3mf") && !is_project_3mf(it->string())) || (boost::algorithm::iends_with(filename, ".amf") && !boost::algorithm::iends_with(filename, ".zip.amf"))) load_type = ProjectDropDialog::LoadType::LoadGeometry; @@ -6135,9 +6137,11 @@ bool Plater::load_files(const wxArrayString& filenames, bool delete_after_load/* load_type = static_cast(std::clamp(std::stoi(wxGetApp().app_config->get("drop_project_action")), static_cast(ProjectDropDialog::LoadType::OpenProject), static_cast(ProjectDropDialog::LoadType::LoadConfig))); } +/* // #ysFIXME_delete_after_test_of_6377 } else load_type = ProjectDropDialog::LoadType::OpenProject; +*/ if (load_type == ProjectDropDialog::LoadType::Unknown) return false; diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index fc9ea18670..3830ba75e3 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -322,8 +322,14 @@ void PreferencesDialog::build() m_optgroup_general->append_separator(); append_bool_option(m_optgroup_general, "show_drop_project_dialog", +#if 1 // #ysFIXME_delete_after_test_of_6377 + L("Show load project dialog"), + L("When checked, whenever dragging and dropping a project file on the application or open it from a browser, " + "shows a dialog asking to select the action to take on the file to load."), +#else L("Show drop project dialog"), L("When checked, whenever dragging and dropping a project file on the application, shows a dialog asking to select the action to take on the file to load."), +#endif app_config->get("show_drop_project_dialog") == "1"); append_bool_option(m_optgroup_general, "single_instance",