From c147d1769ca4fc997386b832680c6eb7c3024d16 Mon Sep 17 00:00:00 2001 From: David Kocik Date: Thu, 23 Jun 2022 16:04:34 +0200 Subject: [PATCH] start as downloader --- src/PrusaSlicer.cpp | 14 +++++++++++++- src/slic3r/GUI/GUI_App.cpp | 3 +++ src/slic3r/GUI/GUI_Init.hpp | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/PrusaSlicer.cpp b/src/PrusaSlicer.cpp index c79d088435..5e46060fc8 100644 --- a/src/PrusaSlicer.cpp +++ b/src/PrusaSlicer.cpp @@ -70,6 +70,11 @@ int CLI::run(int argc, char **argv) // Mark the main thread for the debugger and for runtime checks. set_current_thread_name("slic3r_main"); + for (int i = 0; i < argc; ++i) + { + printf("[%d] %s\n",i,argv[i]); + } + #ifdef __WXGTK__ // On Linux, wxGTK has no support for Wayland, and the app crashes on // startup if gtk3 is used. This env var has to be set explicitly to @@ -110,6 +115,7 @@ int CLI::run(int argc, char **argv) std::find(m_transforms.begin(), m_transforms.end(), "cut") == m_transforms.end() && std::find(m_transforms.begin(), m_transforms.end(), "cut_x") == m_transforms.end() && std::find(m_transforms.begin(), m_transforms.end(), "cut_y") == m_transforms.end(); + bool start_as_downloader = false; bool start_as_gcodeviewer = #ifdef _WIN32 false; @@ -171,7 +177,12 @@ int CLI::run(int argc, char **argv) start_as_gcodeviewer = true; break; } - if (!start_as_gcodeviewer) { + for (const std::string& file : m_input_files) + if (boost::starts_with(file, "open?file=")) { + start_as_downloader = true; + break; + } + if (!start_as_gcodeviewer && !start_as_downloader) { for (const std::string& file : m_input_files) { if (!boost::filesystem::exists(file)) { boost::nowide::cerr << "No such file: " << file << std::endl; @@ -613,6 +624,7 @@ int CLI::run(int argc, char **argv) params.extra_config = std::move(m_extra_config); params.input_files = std::move(m_input_files); params.start_as_gcodeviewer = start_as_gcodeviewer; + params.start_as_downloader = start_as_downloader; return Slic3r::GUI::GUI_Run(params); #else // SLIC3R_GUI // No GUI support. Just print out a help. diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index af9b63acd4..efa4aa6752 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -741,6 +741,9 @@ void GUI_App::post_init() if (! this->init_params->input_files.empty()) this->plater()->load_gcode(wxString::FromUTF8(this->init_params->input_files[0].c_str())); } + if (this->init_params->start_as_downloader) { + show_error(nullptr, "Got url msg."); + } else { if (! this->init_params->preset_substitutions.empty()) show_substitutions_info(this->init_params->preset_substitutions); diff --git a/src/slic3r/GUI/GUI_Init.hpp b/src/slic3r/GUI/GUI_Init.hpp index 2adf618a47..cf150ac7d2 100644 --- a/src/slic3r/GUI/GUI_Init.hpp +++ b/src/slic3r/GUI/GUI_Init.hpp @@ -21,6 +21,7 @@ struct GUI_InitParams std::vector input_files; bool start_as_gcodeviewer; + bool start_as_downloader; }; int GUI_Run(GUI_InitParams ¶ms);