mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-12 12:49:10 +08:00
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)
|
bool load_3mf(const char* path, DynamicPrintConfig& config, ConfigSubstitutionContext& config_substitutions, Model* model, bool check_version)
|
||||||
{
|
{
|
||||||
if (path == nullptr || model == nullptr)
|
if (path == nullptr || model == nullptr)
|
||||||
|
@ -29,6 +29,9 @@ namespace Slic3r {
|
|||||||
class DynamicPrintConfig;
|
class DynamicPrintConfig;
|
||||||
struct ThumbnailData;
|
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.
|
// 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);
|
extern bool load_3mf(const char* path, DynamicPrintConfig& config, ConfigSubstitutionContext& config_substitutions, Model* model, bool check_version);
|
||||||
|
|
||||||
|
@ -5386,6 +5386,10 @@ bool Plater::load_files(const wxArrayString& filenames)
|
|||||||
if (boost::algorithm::iends_with(filename, ".3mf") || boost::algorithm::iends_with(filename, ".amf")) {
|
if (boost::algorithm::iends_with(filename, ".3mf") || boost::algorithm::iends_with(filename, ".amf")) {
|
||||||
LoadType load_type = LoadType::Unknown;
|
LoadType load_type = LoadType::Unknown;
|
||||||
if (!model().objects.empty()) {
|
if (!model().objects.empty()) {
|
||||||
|
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") {
|
if (wxGetApp().app_config->get("show_drop_project_dialog") == "1") {
|
||||||
ProjectDropDialog dlg(filename);
|
ProjectDropDialog dlg(filename);
|
||||||
if (dlg.ShowModal() == wxID_OK) {
|
if (dlg.ShowModal() == wxID_OK) {
|
||||||
@ -5398,6 +5402,7 @@ bool Plater::load_files(const wxArrayString& filenames)
|
|||||||
load_type = static_cast<LoadType>(std::clamp(std::stoi(wxGetApp().app_config->get("drop_project_action")),
|
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)));
|
static_cast<int>(LoadType::OpenProject), static_cast<int>(LoadType::LoadConfig)));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
load_type = LoadType::OpenProject;
|
load_type = LoadType::OpenProject;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user