mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-09 07:56:24 -06:00
ENH:support for model names containing spaces
Change-Id: I267d8b87cd2ae4ad8f90d47eab97305b88239771
This commit is contained in:
parent
b98ced1b13
commit
c4ad08f5fd
2 changed files with 27 additions and 16 deletions
|
@ -977,18 +977,24 @@ static void generic_exception_handle()
|
||||||
//#endif
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> GUI_App::split_str(const std::string& src, const std::string& separator)
|
std::vector<std::string> GUI_App::split_str(std::string src, std::string separator)
|
||||||
{
|
{
|
||||||
size_t pos;
|
std::string::size_type pos;
|
||||||
size_t start_pos = 0;
|
std::vector<std::string> result;
|
||||||
vector<string> result_str;
|
src += separator;
|
||||||
while ((pos = src.find(separator, start_pos)) != string::npos)
|
int size = src.size();
|
||||||
|
|
||||||
|
for (int i = 0; i < size; i++)
|
||||||
{
|
{
|
||||||
result_str.emplace_back(src.substr(start_pos, pos - start_pos));
|
pos = src.find(separator, i);
|
||||||
start_pos = pos + separator.size();
|
if (pos < size)
|
||||||
|
{
|
||||||
|
std::string s = src.substr(i, pos - i);
|
||||||
|
result.push_back(s);
|
||||||
|
i = pos + separator.size() - 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
result_str.emplace_back(src.substr(start_pos, src.size() - pos - separator.size()));
|
return result;
|
||||||
return result_str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI_App::post_init()
|
void GUI_App::post_init()
|
||||||
|
@ -997,7 +1003,6 @@ void GUI_App::post_init()
|
||||||
if (! this->initialized())
|
if (! this->initialized())
|
||||||
throw Slic3r::RuntimeError("Calling post_init() while not yet initialized");
|
throw Slic3r::RuntimeError("Calling post_init() while not yet initialized");
|
||||||
|
|
||||||
|
|
||||||
bool switch_to_3d = false;
|
bool switch_to_3d = false;
|
||||||
if (!this->init_params->input_files.empty()) {
|
if (!this->init_params->input_files.empty()) {
|
||||||
|
|
||||||
|
@ -1009,16 +1014,22 @@ void GUI_App::post_init()
|
||||||
boost::starts_with(this->init_params->input_files.front(), "bambustudio://open")) {
|
boost::starts_with(this->init_params->input_files.front(), "bambustudio://open")) {
|
||||||
|
|
||||||
std::string download_params_url = url_decode(this->init_params->input_files.front());
|
std::string download_params_url = url_decode(this->init_params->input_files.front());
|
||||||
auto input_str_arr = split_str(download_params_url, "bambustudio://open?file=");
|
auto input_str_arr = split_str(download_params_url, "file=");
|
||||||
|
|
||||||
std::string download_url;
|
std::string download_url;
|
||||||
for (auto input_str : input_str_arr) {
|
for (auto input_str : input_str_arr) {
|
||||||
if (!input_str.empty()) download_url = input_str;
|
if ( boost::starts_with(input_str, "http://") || boost::starts_with(input_str, "https://")) {
|
||||||
|
download_url = input_str;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!download_url.empty() && ( boost::starts_with(download_url, "http://") || boost::starts_with(download_url, "https://")) ) {
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format("download_url %1%") % download_url;
|
||||||
|
|
||||||
|
if (!download_url.empty()) {
|
||||||
request_model_download(download_url);
|
request_model_download(download_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
switch_to_3d = true;
|
switch_to_3d = true;
|
||||||
|
|
|
@ -314,7 +314,7 @@ public:
|
||||||
bool is_recreating_gui() const { return m_is_recreating_gui; }
|
bool is_recreating_gui() const { return m_is_recreating_gui; }
|
||||||
std::string logo_name() const { return is_editor() ? "BambuStudio" : "BambuStudio-gcodeviewer"; }
|
std::string logo_name() const { return is_editor() ? "BambuStudio" : "BambuStudio-gcodeviewer"; }
|
||||||
|
|
||||||
std::vector<std::string> split_str(const std::string& src, const std::string& separator);
|
std::vector<std::string> split_str(std::string src, std::string separator);
|
||||||
// To be called after the GUI is fully built up.
|
// To be called after the GUI is fully built up.
|
||||||
// Process command line parameters cached in this->init_params,
|
// Process command line parameters cached in this->init_params,
|
||||||
// load configs, STLs etc.
|
// load configs, STLs etc.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue