mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 07:27:41 -06:00
ENH:rename model file after download finish
Change-Id: I3ae1c8ca4f53bf41c00688b6bb5b0c0e0a4f869b
This commit is contained in:
parent
2dbd2bcef9
commit
8ceb0e6b7b
3 changed files with 33 additions and 16 deletions
|
@ -977,7 +977,7 @@ static void generic_exception_handle()
|
||||||
//#endif
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::vector<std::string> split_str(const std::string& src, const std::string& separator)
|
std::vector<std::string> GUI_App::split_str(const std::string& src, const std::string& separator)
|
||||||
{
|
{
|
||||||
size_t pos;
|
size_t pos;
|
||||||
size_t start_pos = 0;
|
size_t start_pos = 0;
|
||||||
|
@ -997,6 +997,7 @@ 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()) {
|
||||||
|
|
||||||
|
@ -1004,21 +1005,19 @@ void GUI_App::post_init()
|
||||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", init with input files, size %1%, input_gcode %2%")
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", init with input files, size %1%, input_gcode %2%")
|
||||||
%this->init_params->input_files.size() %this->init_params->input_gcode;
|
%this->init_params->input_files.size() %this->init_params->input_gcode;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (this->init_params->input_files.size() == 1 &&
|
if (this->init_params->input_files.size() == 1 &&
|
||||||
boost::starts_with(this->init_params->input_files.front(), "bambustudio://open")) {
|
boost::starts_with(this->init_params->input_files.front(), "bambustudio://open")) {
|
||||||
auto input_str_arr = split_str(this->init_params->input_files.front(), "bambustudio://open/?file=");
|
|
||||||
|
|
||||||
std::string download_origin_url;
|
std::string download_params_url = url_decode(this->init_params->input_files.front());
|
||||||
for (auto input_str:input_str_arr) {
|
auto input_str_arr = split_str(download_params_url, "bambustudio://open?file=");
|
||||||
if (!input_str.empty()) download_origin_url = input_str;
|
|
||||||
|
std::string download_url;
|
||||||
|
for (auto input_str : input_str_arr) {
|
||||||
|
if (!input_str.empty()) download_url = input_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string download_file_url = url_decode(download_origin_url);
|
if (!download_url.empty() && ( boost::starts_with(download_url, "http://") || boost::starts_with(download_url, "https://")) ) {
|
||||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << download_file_url;
|
request_model_download(download_url);
|
||||||
if (!download_file_url.empty() && ( boost::starts_with(download_file_url, "http://") || boost::starts_with(download_file_url, "https://")) ) {
|
|
||||||
request_model_download(download_origin_url);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -314,6 +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);
|
||||||
// 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.
|
||||||
|
|
|
@ -7776,14 +7776,31 @@ int Plater::save_project(bool saveAs)
|
||||||
//BBS import model by model id
|
//BBS import model by model id
|
||||||
void Plater::import_model_id(const std::string& download_info)
|
void Plater::import_model_id(const std::string& download_info)
|
||||||
{
|
{
|
||||||
|
std::string download_origin_url = wxGetApp().url_decode(download_info);
|
||||||
|
|
||||||
std::string download_url;
|
std::string download_url;
|
||||||
std::string filename;
|
std::string filename;
|
||||||
|
|
||||||
std::string download_origin_url = wxGetApp().url_decode(download_info);
|
try
|
||||||
fs::path download_path = fs::path(download_origin_url);
|
{
|
||||||
download_url = download_origin_url;
|
std::vector<std::string> origin_array = wxGetApp().split_str(download_origin_url, "&name=");
|
||||||
filename = download_path.filename().string();
|
if (origin_array.size() >= 2) {
|
||||||
|
|
||||||
|
download_url = origin_array[0];
|
||||||
|
filename = origin_array[1];
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (!download_origin_url.empty()) {
|
||||||
|
|
||||||
|
fs::path download_path = fs::path(download_origin_url);
|
||||||
|
download_url = download_origin_url;
|
||||||
|
filename = download_path.filename().string();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const std::exception& error)
|
||||||
|
{
|
||||||
|
//wxString sError = error.what();
|
||||||
|
}
|
||||||
|
|
||||||
bool download_ok = false;
|
bool download_ok = false;
|
||||||
/* save to a file */
|
/* save to a file */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue