diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 5312a0fce..3e63ee3fc 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1626,6 +1626,25 @@ bool GUI_App::OnExceptionInMainLoop() } #ifdef __APPLE__ +void GUI_App::OSXStoreOpenFiles(const wxArrayString &fileNames) +{ + wxArrayString other_files; + std::vector gcode_files; + const std::regex pattern_gcode_drop(".*[.](gcode|g)", std::regex::icase); + for (const auto& filename : fileNames) { + boost::filesystem::path path(into_path(filename)); + if (std::regex_match(path.string(), pattern_gcode_drop)) + gcode_files.emplace_back(filename); + else + other_files.Add(filename); + } + if (! gcode_files.empty()) { + // Drag & Dropping a G-code onto PrusaSlicer. Switch PrusaSlicer to G-code viewer mode. + //FIXME Switch application to G-code viewer mode? + wxMessageBox("PrusaSlicer on early startup", wxString::Format("Switching to G-code viewer for %s", gcode_files.front()), wxICON_INFORMATION); + } + wxApp::OSXStoreOpenFiles(other_files); +} void GUI_App::MacNewFile() { m_mac_initialized = true; diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index 53eef2518..836378d70 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -250,6 +250,7 @@ public: virtual bool OnExceptionInMainLoop() override; #ifdef __APPLE__ + void OSXStoreOpenFiles(const wxArrayString &files) override; // Called if there is no file to open. void MacNewFile(); // wxWidgets override to get an event on open files.