Do not show ProjectDropDialog when drag and dropping a 3mf file produced by other softwares and the plater is not empty
This commit is contained in:
parent
fab6619641
commit
f970741dd4
@ -3110,6 +3110,36 @@ static void handle_legacy_project_loaded(unsigned int version_project_file, Dyna
|
||||
}
|
||||
}
|
||||
|
||||
bool is_project_3mf(const std::string& filename)
|
||||
{
|
||||
mz_zip_archive archive;
|
||||
mz_zip_zero_struct(&archive);
|
||||
|
||||
if (!open_zip_reader(&archive, filename))
|
||||
return false;
|
||||
|
||||
mz_uint num_entries = mz_zip_reader_get_num_files(&archive);
|
||||
|
||||
// loop the entries to search for config
|
||||
mz_zip_archive_file_stat stat;
|
||||
bool config_found = false;
|
||||
for (mz_uint i = 0; i < num_entries; ++i) {
|
||||
if (mz_zip_reader_file_stat(&archive, i, &stat)) {
|
||||
std::string name(stat.m_filename);
|
||||
std::replace(name.begin(), name.end(), '\\', '/');
|
||||
|
||||
if (boost::algorithm::iequals(name, PRINT_CONFIG_FILE)) {
|
||||
config_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close_zip_reader(&archive);
|
||||
|
||||
return config_found;
|
||||
}
|
||||
|
||||
bool load_3mf(const char* path, DynamicPrintConfig& config, ConfigSubstitutionContext& config_substitutions, Model* model, bool check_version)
|
||||
{
|
||||
if (path == nullptr || model == nullptr)
|
||||
|
@ -29,6 +29,9 @@ namespace Slic3r {
|
||||
class DynamicPrintConfig;
|
||||
struct ThumbnailData;
|
||||
|
||||
// Returns true if the 3mf file with the given filename is a PrusaSlicer project file (i.e. if it contains a config).
|
||||
extern bool is_project_3mf(const std::string& filename);
|
||||
|
||||
// Load the content of a 3mf file into the given model and preset bundle.
|
||||
extern bool load_3mf(const char* path, DynamicPrintConfig& config, ConfigSubstitutionContext& config_substitutions, Model* model, bool check_version);
|
||||
|
||||
|
@ -5386,17 +5386,22 @@ bool Plater::load_files(const wxArrayString& filenames)
|
||||
if (boost::algorithm::iends_with(filename, ".3mf") || boost::algorithm::iends_with(filename, ".amf")) {
|
||||
LoadType load_type = LoadType::Unknown;
|
||||
if (!model().objects.empty()) {
|
||||
if (wxGetApp().app_config->get("show_drop_project_dialog") == "1") {
|
||||
ProjectDropDialog dlg(filename);
|
||||
if (dlg.ShowModal() == wxID_OK) {
|
||||
int choice = dlg.get_action();
|
||||
load_type = static_cast<LoadType>(choice);
|
||||
wxGetApp().app_config->set("drop_project_action", std::to_string(choice));
|
||||
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 = LoadType::OpenProject;
|
||||
else {
|
||||
if (wxGetApp().app_config->get("show_drop_project_dialog") == "1") {
|
||||
ProjectDropDialog dlg(filename);
|
||||
if (dlg.ShowModal() == wxID_OK) {
|
||||
int choice = dlg.get_action();
|
||||
load_type = static_cast<LoadType>(choice);
|
||||
wxGetApp().app_config->set("drop_project_action", std::to_string(choice));
|
||||
}
|
||||
}
|
||||
else
|
||||
load_type = static_cast<LoadType>(std::clamp(std::stoi(wxGetApp().app_config->get("drop_project_action")),
|
||||
static_cast<int>(LoadType::OpenProject), static_cast<int>(LoadType::LoadConfig)));
|
||||
}
|
||||
else
|
||||
load_type = static_cast<LoadType>(std::clamp(std::stoi(wxGetApp().app_config->get("drop_project_action")),
|
||||
static_cast<int>(LoadType::OpenProject), static_cast<int>(LoadType::LoadConfig)));
|
||||
}
|
||||
else
|
||||
load_type = LoadType::OpenProject;
|
||||
|
Loading…
Reference in New Issue
Block a user