WIP: Opening a G-code in PrusaSlicer at Drag & Drop onto
the application icon in Finder.
This commit is contained in:
parent
e16fe96cc6
commit
6acc1fc112
2 changed files with 25 additions and 2 deletions
|
@ -1620,20 +1620,38 @@ bool GUI_App::OnExceptionInMainLoop()
|
|||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
void GUI_App::MacNewFile()
|
||||
{
|
||||
wxDocManager::GetDocumentManager()->CreateNewDocument();
|
||||
m_mac_initialized = true;
|
||||
}
|
||||
// wxWidgets override to get an event on open files.
|
||||
void GUI_App::MacOpenFiles(const wxArrayString &fileNames)
|
||||
{
|
||||
std::vector<std::string> files;
|
||||
std::vector<wxString> 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))
|
||||
start_new_gcodeviewer(&filename);
|
||||
gcode_files.emplace_back(filename);
|
||||
else
|
||||
files.emplace_back(path.string());
|
||||
}
|
||||
if (! files.empty())
|
||||
this->plater()->load_files(files, true, true);
|
||||
if (! files.empty() || m_mac_initialized) {
|
||||
// Opening a G-code after the PrusaSlicer application was initalized.
|
||||
// Start a new G-code viewer instance for each G-code file.
|
||||
for (const wxString &filename : gcode_files)
|
||||
start_new_gcodeviewer(&filename);
|
||||
} else if (! gcode_files.empty()) {
|
||||
assert(! m_mac_initialized);
|
||||
// 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 startup", wxString::Format("Switching to G-code viewer for %s", gcode_files.front()), wxICON_INFORMATION);
|
||||
}
|
||||
m_mac_initialized = true;
|
||||
}
|
||||
#endif /* __APPLE */
|
||||
|
||||
|
|
|
@ -106,6 +106,9 @@ private:
|
|||
#endif // ENABLE_GCODE_VIEWER
|
||||
|
||||
bool m_initialized { false };
|
||||
#ifdef __APPLE__
|
||||
bool m_mac_initialized { false };
|
||||
#endif // __APPLE__
|
||||
bool app_conf_exists{ false };
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
EAppMode m_app_mode{ EAppMode::Editor };
|
||||
|
@ -119,7 +122,7 @@ private:
|
|||
wxFont m_bold_font;
|
||||
wxFont m_normal_font;
|
||||
|
||||
int m_em_unit; // width of a "m"-symbol in pixels for current system font
|
||||
int m_em_unit; // width of a "m"-symbol in pixels for current system font
|
||||
// Note: for 100% Scale m_em_unit = 10 -> it's a good enough coefficient for a size setting of controls
|
||||
|
||||
std::unique_ptr<wxLocale> m_wxLocale;
|
||||
|
@ -247,6 +250,8 @@ public:
|
|||
virtual bool OnExceptionInMainLoop() override;
|
||||
|
||||
#ifdef __APPLE__
|
||||
// Called if there is no file to open.
|
||||
void MacNewFile();
|
||||
// wxWidgets override to get an event on open files.
|
||||
void MacOpenFiles(const wxArrayString &fileNames) override;
|
||||
#endif /* __APPLE */
|
||||
|
|
Loading…
Reference in a new issue