ENH: open new process on MacOS
Change-Id: I0bc4069f9ff14ac86d9edf800134f04a26a650f2
This commit is contained in:
parent
77e4599c4a
commit
0471c7d427
|
@ -130,13 +130,7 @@ void AppConfig::set_defaults()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (get("single_instance").empty())
|
if (get("single_instance").empty())
|
||||||
set_bool("single_instance",
|
set_bool("single_instance", false);
|
||||||
#ifdef __APPLE__
|
|
||||||
true
|
|
||||||
#else // __APPLE__
|
|
||||||
false
|
|
||||||
#endif // __APPLE__
|
|
||||||
);
|
|
||||||
|
|
||||||
#ifdef SUPPORT_REMEMBER_OUTPUT_PATH
|
#ifdef SUPPORT_REMEMBER_OUTPUT_PATH
|
||||||
if (get("remember_output_path").empty())
|
if (get("remember_output_path").empty())
|
||||||
|
|
|
@ -4483,6 +4483,12 @@ void GUI_App::OSXStoreOpenFiles(const wxArrayString &fileNames)
|
||||||
// wxWidgets override to get an event on open files.
|
// wxWidgets override to get an event on open files.
|
||||||
void GUI_App::MacOpenFiles(const wxArrayString &fileNames)
|
void GUI_App::MacOpenFiles(const wxArrayString &fileNames)
|
||||||
{
|
{
|
||||||
|
if (m_post_initialized) {
|
||||||
|
std::vector<wxString> names;
|
||||||
|
for (auto & n : fileNames) names.push_back(n);
|
||||||
|
start_new_slicer(names);
|
||||||
|
return;
|
||||||
|
}
|
||||||
std::vector<std::string> files;
|
std::vector<std::string> files;
|
||||||
std::vector<wxString> gcode_files;
|
std::vector<wxString> gcode_files;
|
||||||
std::vector<wxString> non_gcode_files;
|
std::vector<wxString> non_gcode_files;
|
||||||
|
|
|
@ -84,19 +84,18 @@ class BambuStudioTaskBarIcon : public wxTaskBarIcon
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BambuStudioTaskBarIcon(wxTaskBarIconType iconType = wxTBI_DEFAULT_TYPE) : wxTaskBarIcon(iconType) {}
|
BambuStudioTaskBarIcon(wxTaskBarIconType iconType = wxTBI_DEFAULT_TYPE) : wxTaskBarIcon(iconType) {}
|
||||||
//wxMenu *CreatePopupMenu() override {
|
wxMenu *CreatePopupMenu() override {
|
||||||
//wxMenu *menu = new wxMenu;
|
wxMenu *menu = new wxMenu;
|
||||||
//BBS do not support multi instances in mac
|
//if (wxGetApp().app_config->get("single_instance") == "false") {
|
||||||
//if(wxGetApp().app_config->get("single_instance") == "0") {
|
// Only allow opening a new PrusaSlicer instance on OSX if "single_instance" is disabled,
|
||||||
// // Only allow opening a new PrusaSlicer instance on OSX if "single_instance" is disabled,
|
// as starting new instances would interfere with the locking mechanism of "single_instance" support.
|
||||||
// // as starting new instances would interfere with the locking mechanism of "single_instance" support.
|
append_menu_item(menu, wxID_ANY, _L("New Window"), _L("Open a new window"),
|
||||||
// append_menu_item(menu, wxID_ANY, _L("Open new instance"), _L("Open a new PrusaSlicer instance"),
|
[](wxCommandEvent&) { start_new_slicer(); }, "", nullptr);
|
||||||
// [](wxCommandEvent&) { start_new_slicer(); }, "", nullptr);
|
|
||||||
//}
|
//}
|
||||||
//append_menu_item(menu, wxID_ANY, _L("G-code Viewer") + dots, _L("Open G-code Viewer"),
|
// append_menu_item(menu, wxID_ANY, _L("G-code Viewer") + dots, _L("Open G-code Viewer"),
|
||||||
// [](wxCommandEvent&) { start_new_gcodeviewer_open_file(); }, "", nullptr);
|
// [](wxCommandEvent&) { start_new_gcodeviewer_open_file(); }, "", nullptr);
|
||||||
//return menu;
|
return menu;
|
||||||
//}
|
}
|
||||||
};
|
};
|
||||||
/*class GCodeViewerTaskBarIcon : public wxTaskBarIcon
|
/*class GCodeViewerTaskBarIcon : public wxTaskBarIcon
|
||||||
{
|
{
|
||||||
|
@ -1680,6 +1679,12 @@ void MainFrame::init_menubar_as_editor()
|
||||||
// File menu
|
// File menu
|
||||||
wxMenu* fileMenu = new wxMenu;
|
wxMenu* fileMenu = new wxMenu;
|
||||||
{
|
{
|
||||||
|
#ifdef __APPLE__
|
||||||
|
// New Window
|
||||||
|
append_menu_item(fileMenu, wxID_ANY, _L("New Window") + "\tCtrl+N", _L("Start a new window"),
|
||||||
|
[](wxCommandEvent&) { start_new_slicer(); }, "", nullptr,
|
||||||
|
[]{ return true; }, this);
|
||||||
|
#endif
|
||||||
// New Project
|
// New Project
|
||||||
append_menu_item(fileMenu, wxID_ANY, _L("New Project") + "\tCtrl+N", _L("Start a new project"),
|
append_menu_item(fileMenu, wxID_ANY, _L("New Project") + "\tCtrl+N", _L("Start a new project"),
|
||||||
[this](wxCommandEvent&) { if (m_plater) m_plater->new_project(); }, "", nullptr,
|
[this](wxCommandEvent&) { if (m_plater) m_plater->new_project(); }, "", nullptr,
|
||||||
|
|
|
@ -286,7 +286,7 @@ namespace GUI {
|
||||||
|
|
||||||
void initGestures(void * view, wxEvtHandler * handler)
|
void initGestures(void * view, wxEvtHandler * handler)
|
||||||
{
|
{
|
||||||
NSOpenGLView * glView = (NSOpenGLView *) view;
|
wxNSCustomOpenGLView * glView = (wxNSCustomOpenGLView *) view;
|
||||||
[glView initGesturesWithHandler: handler];
|
[glView initGesturesWithHandler: handler];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,17 +60,19 @@ static void start_new_slicer_or_gcodeviewer(const NewSlicerInstanceType instance
|
||||||
boost::filesystem::path bin_path = into_path(wxStandardPaths::Get().GetExecutablePath());
|
boost::filesystem::path bin_path = into_path(wxStandardPaths::Get().GetExecutablePath());
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
{
|
{
|
||||||
bin_path = bin_path.parent_path() / "BambuStudio";
|
//bin_path = bin_path.parent_path() / "BambuStudio";
|
||||||
|
bin_path = "/usr/bin/open";
|
||||||
// On Apple the wxExecute fails, thus we use boost::process instead.
|
// On Apple the wxExecute fails, thus we use boost::process instead.
|
||||||
BOOST_LOG_TRIVIAL(info) << "Trying to spawn a new slicer \"" << bin_path.string() << "\"";
|
BOOST_LOG_TRIVIAL(info) << "Trying to spawn a new slicer \"" << bin_path.string() << "\"";
|
||||||
try {
|
try {
|
||||||
std::vector<std::string> args;
|
std::vector<std::string> args = { "-n", "-a", "BambuStudio"};
|
||||||
|
if (!paths_to_open.empty()) {
|
||||||
|
for (const auto& file : paths_to_open)
|
||||||
|
args.emplace_back(into_u8(file));
|
||||||
|
}
|
||||||
|
args.emplace_back("--args");
|
||||||
if (instance_type == NewSlicerInstanceType::GCodeViewer)
|
if (instance_type == NewSlicerInstanceType::GCodeViewer)
|
||||||
args.emplace_back("--gcodeviewer");
|
args.emplace_back("--gcodeviewer");
|
||||||
if (!paths_to_open.empty()) {
|
|
||||||
for (const auto& file : paths_to_open)
|
|
||||||
args.emplace_back(into_u8(file));
|
|
||||||
}
|
|
||||||
if (instance_type == NewSlicerInstanceType::Slicer && single_instance)
|
if (instance_type == NewSlicerInstanceType::Slicer && single_instance)
|
||||||
args.emplace_back("--single-instance");
|
args.emplace_back("--single-instance");
|
||||||
boost::process::spawn(bin_path, args);
|
boost::process::spawn(bin_path, args);
|
||||||
|
|
Loading…
Reference in New Issue