From d94c87879d25f97e36e46179e932bdafbae1b134 Mon Sep 17 00:00:00 2001 From: "zorro.zhang" Date: Tue, 4 Jun 2024 15:55:05 +0800 Subject: [PATCH] ENH: Open Login Dialog When Open Model in MW JIRA: none Change-Id: I962e93570bfdb137a01b2ec64f963b347765faf0 --- src/slic3r/GUI/GUI_App.cpp | 13 +++++++++++++ src/slic3r/GUI/WebViewDialog.cpp | 19 ++++++++++++++++--- src/slic3r/GUI/WebViewDialog.hpp | 1 + 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index f4e6f763e..9fca8fbf5 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -4030,6 +4030,19 @@ std::string GUI_App::handle_web_request(std::string cmd) }); } else if (command_str.compare("homepage_login_or_register") == 0) { + + if (root.get_child_optional("makerworld_model_id") != boost::none) { + boost::optional ModelID = root.get_optional("makerworld_model_id"); + if (ModelID.has_value()) { + if (mainframe) { + if (mainframe->m_webview) + { + mainframe->m_webview->SetMakerworldModelID(ModelID.value()); + } + } + } + } + CallAfter([this] { this->request_login(true); }); diff --git a/src/slic3r/GUI/WebViewDialog.cpp b/src/slic3r/GUI/WebViewDialog.cpp index aaa2fd38e..03e4532b8 100644 --- a/src/slic3r/GUI/WebViewDialog.cpp +++ b/src/slic3r/GUI/WebViewDialog.cpp @@ -802,9 +802,22 @@ void WebViewPanel::SetMakerworldPageLoginStatus(bool login ,wxString ticket) { if (m_browserMW == nullptr) return; - std::string h = wxGetApp().get_model_http_url(wxGetApp().app_config->get_country_code()); - wxString mw_currenturl = m_browserMW->GetCurrentURL(); - mw_currenturl.Replace("modelid=", ""); + wxString mw_currenturl; + if (m_online_spec_id != "") { + auto host = wxGetApp().get_model_http_url(wxGetApp().app_config->get_country_code()); + + wxString language_code = wxGetApp().current_language_code().BeforeFirst('_'); + language_code = language_code.ToStdString(); + + mw_currenturl = (boost::format("%1%%2%/studio/webview?modelid=%3%&from=%4%") % host % language_code.mb_str() % m_online_spec_id % m_online_type.mb_str()).str(); + + m_onlinefirst = true; + m_online_spec_id = ""; + } else { + mw_currenturl = m_browserMW->GetCurrentURL(); + } + + //mw_currenturl.Replace("modelid=", ""); wxString mw_jumpurl = ""; bool b = GetJumpUrl(login, ticket, mw_currenturl, mw_jumpurl); diff --git a/src/slic3r/GUI/WebViewDialog.hpp b/src/slic3r/GUI/WebViewDialog.hpp index 195280e5d..d30a36847 100644 --- a/src/slic3r/GUI/WebViewDialog.hpp +++ b/src/slic3r/GUI/WebViewDialog.hpp @@ -96,6 +96,7 @@ public: public: void ResetWholePage(); + void SetMakerworldModelID(std::string ModelID) { m_online_spec_id = ModelID; } void SwitchWebContent(std::string modelname, int refresh=0); void SwitchLeftMenu(std::string strMenu); void OpenOneMakerlab(std::string url);