From daaa9669e9c6d559ffd4d190d0442bd61f57c686 Mon Sep 17 00:00:00 2001 From: David Kocik Date: Tue, 21 Feb 2023 14:00:52 +0100 Subject: [PATCH] File -> Import -> Import Zip Archive --- src/slic3r/GUI/GUI_App.cpp | 13 +++++++++++++ src/slic3r/GUI/GUI_App.hpp | 3 +++ src/slic3r/GUI/MainFrame.cpp | 4 ++++ src/slic3r/GUI/Plater.cpp | 11 +++++++++++ src/slic3r/GUI/Plater.hpp | 1 + 5 files changed, 32 insertions(+) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 520f67aed..f189aeb47 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -480,6 +480,8 @@ static const FileWildcards file_wildcards_by_type[FT_SIZE] = { /* FT_TEX */ { "Texture"sv, { ".png"sv, ".svg"sv } }, /* FT_SL1 */ { "Masked SLA files"sv, { ".sl1"sv, ".sl1s"sv, ".pwmx"sv } }, + + /* FT_ZIP */ { "Zip files"sv, { ".zip"sv } }, }; #if ENABLE_ALTERNATIVE_FILE_WILDCARDS_GENERATOR @@ -1977,6 +1979,17 @@ void GUI_App::import_model(wxWindow *parent, wxArrayString& input_files) const dialog.GetPaths(input_files); } +void GUI_App::import_zip(wxWindow* parent, wxString& input_file) const +{ + wxFileDialog dialog(parent ? parent : GetTopWindow(), + _L("Choose ZIP file:"), + from_u8(app_config->get_last_dir()), "", + file_wildcards(FT_ZIP), wxFD_OPEN | wxFD_FILE_MUST_EXIST); + + if (dialog.ShowModal() == wxID_OK) + input_file = dialog.GetPath(); +} + void GUI_App::load_gcode(wxWindow* parent, wxString& input_file) const { input_file.Clear(); diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index 3f8d47fd7..da231bae6 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -73,6 +73,8 @@ enum FileType FT_SL1, + FT_ZIP, + FT_SIZE, }; @@ -252,6 +254,7 @@ public: void keyboard_shortcuts(); void load_project(wxWindow *parent, wxString& input_file) const; void import_model(wxWindow *parent, wxArrayString& input_files) const; + void import_zip(wxWindow* parent, wxString& input_file) const; void load_gcode(wxWindow* parent, wxString& input_file) const; static bool catch_error(std::function cb, const std::string& err); diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index b656f056a..ab82c1033 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -1293,6 +1293,10 @@ void MainFrame::init_menubar_as_editor() [this](wxCommandEvent&) { if (m_plater) m_plater->import_sl1_archive(); }, "import_plater", nullptr, [this](){return m_plater != nullptr && m_plater->get_ui_job_worker().is_idle(); }, this); + append_menu_item(import_menu, wxID_ANY, _L("Import ZIP Achive") + dots, _L("Load a zip achive"), + [this](wxCommandEvent&) { if (m_plater) m_plater->import_zip_archive(); }, "import_plater", nullptr, + [this]() {return m_plater != nullptr; }, this); + import_menu->AppendSeparator(); append_menu_item(import_menu, wxID_ANY, _L("Import &Config") + dots + "\tCtrl+L", _L("Load exported configuration file"), [this](wxCommandEvent&) { load_config_file(); }, "import_config", nullptr, diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index e04b05033..5a948f577 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -5479,6 +5479,17 @@ void Plater::add_model(bool imperial_units/* = false*/) wxGetApp().mainframe->update_title(); } +void Plater::import_zip_archive() +{ + wxString input_file; + wxGetApp().import_zip(this, input_file); + if (input_file.empty()) + return; + + fs::path path = into_path(input_file); + preview_zip_archive(path); +} + void Plater::import_sl1_archive() { auto &w = get_ui_job_worker(); diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 3dcca746d..db4349101 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -166,6 +166,7 @@ public: void load_project(); void load_project(const wxString& filename); void add_model(bool imperial_units = false); + void import_zip_archive(); void import_sl1_archive(); void extract_config_from_project(); void load_gcode();