Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/slic3r/GUI/Downloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ void Downloader::on_complete(wxCommandEvent& event)
set_download_state(event.GetInt(), DownloadState::DownloadDone);
wxArrayString paths;
paths.Add(event.GetString());
wxGetApp().plater()->load_files(paths);
// from_url: the user clicked "Open in ..." on this specific project.
wxGetApp().plater()->load_files(paths, /* from_url */ true);
}
bool Downloader::user_action_callback(DownloaderUserAction action, int id)
{
Expand Down
22 changes: 17 additions & 5 deletions src/slic3r/GUI/Plater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19384,7 +19384,13 @@ ProjectDropDialog::ProjectDropDialog(const std::string &filename)
wxDefaultPosition,
wxDefaultSize,
wxCAPTION | wxCLOSE_BOX)
, m_action(2)
// Default to the action the user chose last time, which this dialog already records in
// "import_project_action" on OK. Falling back to LoadType::OpenProject rather than
// LoadGeometry: this dialog is shown for a *project* file, and importing geometry only
// silently discards the embedded printer, filament and process settings.
, m_action(std::max(1, std::min(2, wxGetApp().app_config->get("import_project_action").empty()
? 1
: std::atoi(wxGetApp().app_config->get("import_project_action").c_str()))))
{
// def setting
SetBackgroundColour(m_def_color);
Expand Down Expand Up @@ -19550,7 +19556,7 @@ void ProjectDropDialog::on_dpi_changed(const wxRect& suggested_rect)
}

//BBS: remove GCodeViewer as seperate APP logic
bool Plater::load_files(const wxArrayString& filenames)
bool Plater::load_files(const wxArrayString& filenames, bool from_url)
{
const std::regex pattern_drop(".*[.](stp|step|stl|oltp|obj|amf|3mf|svg|zip)", std::regex::icase);
const std::regex pattern_gcode_drop(".*[.](gcode|g)", std::regex::icase);
Expand Down Expand Up @@ -19659,7 +19665,7 @@ bool Plater::load_files(const wxArrayString& filenames)

switch (loadfiles_type) {
case LoadFilesType::Single3MF:
open_3mf_file(normal_paths[0]);
open_3mf_file(normal_paths[0], from_url);
break;

case LoadFilesType::SingleOther: {
Expand Down Expand Up @@ -19742,7 +19748,7 @@ LoadType determine_load_type(std::string filename, std::string override_setting)
}
}

bool Plater::open_3mf_file(const fs::path &file_path)
bool Plater::open_3mf_file(const fs::path &file_path, bool from_url)
{
std::string filename = encode_path(file_path.filename().string().c_str());
if (!boost::algorithm::iends_with(filename, ".3mf")) {
Expand All @@ -19751,7 +19757,13 @@ bool Plater::open_3mf_file(const fs::path &file_path)

bool not_empty_plate = !model().objects.empty();
bool load_setting_ask_when_relevant = wxGetApp().app_config->get(SETTING_PROJECT_LOAD_BEHAVIOUR) == OPTION_PROJECT_LOAD_BEHAVIOUR_ASK_WHEN_RELEVANT;
LoadType load_type = determine_load_type(filename, (not_empty_plate && load_setting_ask_when_relevant) ? OPTION_PROJECT_LOAD_BEHAVIOUR_ALWAYS_ASK : "");
// A project opened from a snapmaker-orca:// URL is not an ambiguous drop: the user
// clicked "Open in Snapmaker Orca" on that specific project, so do not escalate to the
// "Open as project / Import geometry only" prompt just because the plate is occupied.
// The global Load Behaviour setting is still honoured, and load_project() still asks
// about unsaved changes to the current project.
LoadType load_type = determine_load_type(filename,
(!from_url && not_empty_plate && load_setting_ask_when_relevant) ? OPTION_PROJECT_LOAD_BEHAVIOUR_ALWAYS_ASK : "");

if (load_type == LoadType::Unknown) return false;

Expand Down
8 changes: 5 additions & 3 deletions src/slic3r/GUI/Plater.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ class Plater: public wxPanel
// BBS: check snapshot
bool up_to_date(bool saved, bool backup);

bool open_3mf_file(const fs::path &file_path);
bool open_3mf_file(const fs::path &file_path, bool from_url = false);
int get_3mf_file_count(std::vector<fs::path> paths);
void add_file();
void add_model(bool imperial_units = false, std::string fname = "");
Expand Down Expand Up @@ -387,8 +387,10 @@ class Plater: public wxPanel
std::vector<size_t> load_files(const std::vector<boost::filesystem::path>& input_files, LoadStrategy strategy = LoadStrategy::LoadModel | LoadStrategy::LoadConfig, bool ask_multi = false);
// To be called when providing a list of files to the GUI slic3r on command line.
std::vector<size_t> load_files(const std::vector<std::string>& input_files, LoadStrategy strategy = LoadStrategy::LoadModel | LoadStrategy::LoadConfig, bool ask_multi = false);
// to be called on drag and drop
bool load_files(const wxArrayString& filenames);
// to be called on drag and drop, or for a project downloaded from a
// snapmaker-orca:// URL, in which case from_url is true: the user has already
// said which project to open, so do not ask them again.
bool load_files(const wxArrayString& filenames, bool from_url = false);

const wxString& get_last_loaded_gcode() const { return m_last_loaded_gcode; }

Expand Down