ENH: support login after downloading the plug-in

JIRA: STUDIO-8268

Change-Id: Ib0c200d79cd5b7e8d2272ce69f3ea6b797d33968
Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
Stone Li 2024-09-26 09:48:35 +08:00 committed by Lane.Wei
parent c4a68a74d7
commit fb8f801514
4 changed files with 19 additions and 19 deletions

View File

@ -16,7 +16,6 @@
#include "libslic3r/Utils.hpp" #include "libslic3r/Utils.hpp"
#include "GUI.hpp" #include "GUI.hpp"
#include "I18N.hpp" #include "I18N.hpp"
//#include "ConfigWizard.hpp"
#include "wxExtensions.hpp" #include "wxExtensions.hpp"
#include "slic3r/GUI/MainFrame.hpp" #include "slic3r/GUI/MainFrame.hpp"
#include "GUI_App.hpp" #include "GUI_App.hpp"
@ -26,10 +25,9 @@
namespace Slic3r { namespace Slic3r {
namespace GUI { namespace GUI {
DownloadProgressDialog::DownloadProgressDialog(wxString title, bool post_login)
DownloadProgressDialog::DownloadProgressDialog(wxString title)
: DPIDialog(static_cast<wxWindow *>(wxGetApp().mainframe), wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX) : DPIDialog(static_cast<wxWindow *>(wxGetApp().mainframe), wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
, m_post_login(post_login)
{ {
wxString download_failed_url = wxT("https://wiki.bambulab.com/en/software/bambu-studio/failed-to-get-network-plugin"); wxString download_failed_url = wxT("https://wiki.bambulab.com/en/software/bambu-studio/failed-to-get-network-plugin");
wxString install_failed_url = wxT("https://wiki.bambulab.com/en/software/bambu-studio/failed-to-get-network-plugin"); wxString install_failed_url = wxT("https://wiki.bambulab.com/en/software/bambu-studio/failed-to-get-network-plugin");
@ -148,19 +146,16 @@ bool DownloadProgressDialog::Show(bool show)
m_upgrade_job->set_event_handle(this); m_upgrade_job->set_event_handle(this);
m_status_bar->set_progress(0); m_status_bar->set_progress(0);
Bind(EVT_UPGRADE_NETWORK_SUCCESS, [this](wxCommandEvent& evt) { Bind(EVT_UPGRADE_NETWORK_SUCCESS, [this](wxCommandEvent& evt) {
if (wxGetApp().check_networking_version()) {
m_status_bar->change_button_label(_L("OK")); m_status_bar->change_button_label(_L("OK"));
on_finish(); on_finish();
if (m_post_login) {
m_status_bar->set_cancel_callback_fina( m_status_bar->set_cancel_callback_fina(
[this]() { [this]() {
this->Close(); this->Close();
wxGetApp().request_login(); wxGetApp().request_login();
} }
); );
} } else {
else {
on_finish();
m_status_bar->change_button_label(_L("Close"));
m_status_bar->set_cancel_callback_fina( m_status_bar->set_cancel_callback_fina(
[this]() { [this]() {
this->Close(); this->Close();

View File

@ -30,6 +30,7 @@ class wxStaticBitmap;
namespace Slic3r { namespace Slic3r {
namespace GUI { namespace GUI {
class DownloadProgressDialog : public DPIDialog class DownloadProgressDialog : public DPIDialog
{ {
protected: protected:
@ -37,7 +38,7 @@ protected:
void on_close(wxCloseEvent& event); void on_close(wxCloseEvent& event);
public: public:
DownloadProgressDialog(wxString title); DownloadProgressDialog(wxString title, bool post_login = false);
wxString format_text(wxStaticText* st, wxString str, int warp); wxString format_text(wxStaticText* st, wxString str, int warp);
~DownloadProgressDialog(); ~DownloadProgressDialog();
@ -53,6 +54,8 @@ public:
protected: protected:
virtual std::shared_ptr<UpgradeNetworkJob> make_job(std::shared_ptr<ProgressIndicator> pri); virtual std::shared_ptr<UpgradeNetworkJob> make_job(std::shared_ptr<ProgressIndicator> pri);
virtual void on_finish(); virtual void on_finish();
bool m_post_login { false };
}; };

View File

@ -3694,14 +3694,15 @@ void GUI_App::ShowUserGuide() {
} }
} }
void GUI_App::ShowDownNetPluginDlg() { void GUI_App::ShowDownNetPluginDlg(bool post_login)
{
try { try {
auto iter = std::find_if(dialogStack.begin(), dialogStack.end(), [](auto dialog) { auto iter = std::find_if(dialogStack.begin(), dialogStack.end(), [](auto dialog) {
return dynamic_cast<DownloadProgressDialog *>(dialog) != nullptr; return dynamic_cast<DownloadProgressDialog *>(dialog) != nullptr;
}); });
if (iter != dialogStack.end()) if (iter != dialogStack.end())
return; return;
DownloadProgressDialog dlg(_L("Downloading Bambu Network Plug-in")); DownloadProgressDialog dlg(_L("Downloading Bambu Network Plug-in"), post_login);
dlg.ShowModal(); dlg.ShowModal();
} catch (std::exception &e) { } catch (std::exception &e) {
; ;
@ -4235,6 +4236,7 @@ std::string GUI_App::handle_web_request(std::string cmd)
} }
} }
else if (command_str.compare("homepage_need_networkplugin") == 0) { else if (command_str.compare("homepage_need_networkplugin") == 0) {
bool post_login = true;
if (mainframe) { if (mainframe) {
if (mainframe->m_confirm_download_plugin_dlg == nullptr) { if (mainframe->m_confirm_download_plugin_dlg == nullptr) {
mainframe->m_confirm_download_plugin_dlg = new SecondaryCheckDialog(mainframe, wxID_ANY, _L("Install network plug-in"), SecondaryCheckDialog::ButtonStyle::ONLY_CONFIRM); mainframe->m_confirm_download_plugin_dlg = new SecondaryCheckDialog(mainframe, wxID_ANY, _L("Install network plug-in"), SecondaryCheckDialog::ButtonStyle::ONLY_CONFIRM);
@ -4242,9 +4244,9 @@ std::string GUI_App::handle_web_request(std::string cmd)
mainframe->m_confirm_download_plugin_dlg->update_text(_L("Please Install network plug-in before log in.")); mainframe->m_confirm_download_plugin_dlg->update_text(_L("Please Install network plug-in before log in."));
mainframe->m_confirm_download_plugin_dlg->update_btn_label(_L("Install Network Plug-in"), _L("")); mainframe->m_confirm_download_plugin_dlg->update_btn_label(_L("Install Network Plug-in"), _L(""));
mainframe->m_confirm_download_plugin_dlg->Bind(EVT_SECONDARY_CHECK_CONFIRM, [this](wxCommandEvent& e) { mainframe->m_confirm_download_plugin_dlg->Bind(EVT_SECONDARY_CHECK_CONFIRM, [this, post_login](wxCommandEvent& e) {
mainframe->m_confirm_download_plugin_dlg->Close(); mainframe->m_confirm_download_plugin_dlg->Close();
ShowDownNetPluginDlg(); ShowDownNetPluginDlg(post_login);
return; return;
}); });
} }

View File

@ -427,7 +427,7 @@ public:
wxString transition_tridid(int trid_id); wxString transition_tridid(int trid_id);
void ShowUserGuide(); void ShowUserGuide();
void ShowDownNetPluginDlg(); void ShowDownNetPluginDlg(bool post_login = false);
void ShowUserLogin(bool show = true); void ShowUserLogin(bool show = true);
void ShowOnlyFilament(); void ShowOnlyFilament();
//BBS //BBS