mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-23 14:44:19 -06:00
ENH:optimized the retry of requests
jira:[for network optimized] Change-Id: Iea43f4a97c7cd568171287278a07689e954d1093 (cherry picked from commit 35d3de8abe63a0cba30948581ed26a8bc7f94162) (cherry picked from commit 30bad38fb979f5c5a10e4b869ec2e41fa99857f8)
This commit is contained in:
parent
569d4e6307
commit
8bb7ea7cfc
7 changed files with 156 additions and 2 deletions
|
@ -1571,6 +1571,17 @@ void GUI_App::init_networking_callbacks()
|
|||
// GUI::wxGetApp().request_user_handle(online_login);
|
||||
// });
|
||||
|
||||
m_agent->set_server_callback([this](std::string url, int status) {
|
||||
if (!m_server_error_dialog) {
|
||||
m_server_error_dialog = new NetworkErrorDialog(mainframe);
|
||||
}
|
||||
|
||||
if (!m_server_error_dialog->IsShown()) {
|
||||
m_server_error_dialog->ShowModal();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
m_agent->set_on_server_connected_fn([this](int return_code, int reason_code) {
|
||||
if (m_is_closing) {
|
||||
return;
|
||||
|
@ -3227,6 +3238,23 @@ void GUI_App::link_to_network_check()
|
|||
wxLaunchDefaultBrowser(url);
|
||||
}
|
||||
|
||||
void GUI_App::link_to_lan_only_wiki()
|
||||
{
|
||||
std::string url;
|
||||
std::string country_code = app_config->get_country_code();
|
||||
|
||||
if (country_code == "US") {
|
||||
url = "https://wiki.bambulab.com/en/knowledge-sharing/enable-lan-mode";
|
||||
}
|
||||
else if (country_code == "CN") {
|
||||
url = "https://wiki.bambulab.com/zh/knowledge-sharing/enable-lan-mode";
|
||||
}
|
||||
else {
|
||||
url = "https://wiki.bambulab.com/en/knowledge-sharing/enable-lan-mode";
|
||||
}
|
||||
wxLaunchDefaultBrowser(url);
|
||||
}
|
||||
|
||||
bool GUI_App::tabs_as_menu() const
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -81,6 +81,7 @@ class ParamsDialog;
|
|||
class HMSQuery;
|
||||
class ModelMallDialog;
|
||||
class PingCodeBindDialog;
|
||||
class NetworkErrorDialog;
|
||||
|
||||
|
||||
enum FileType
|
||||
|
@ -393,9 +394,9 @@ private:
|
|||
bool get_side_menu_popup_status();
|
||||
void set_side_menu_popup_status(bool status);
|
||||
void link_to_network_check();
|
||||
|
||||
void link_to_lan_only_wiki();
|
||||
|
||||
const wxColour& get_label_clr_modified(){ return m_color_label_modified; }
|
||||
const wxColour& get_label_clr_modified() { return m_color_label_modified; }
|
||||
const wxColour& get_label_clr_sys() { return m_color_label_sys; }
|
||||
const wxColour& get_label_clr_default() { return m_color_label_default; }
|
||||
const wxColour& get_window_default_clr(){ return m_color_window_default; }
|
||||
|
@ -574,6 +575,8 @@ private:
|
|||
ModelMallDialog* m_mall_publish_dialog{ nullptr };
|
||||
PingCodeBindDialog* m_ping_code_binding_dialog{ nullptr };
|
||||
|
||||
NetworkErrorDialog* m_server_error_dialog { nullptr };
|
||||
|
||||
void set_download_model_url(std::string url) {m_mall_model_download_url = url;}
|
||||
void set_download_model_name(std::string name) {m_mall_model_download_name = name;}
|
||||
std::string get_download_model_url() {return m_mall_model_download_url;}
|
||||
|
|
|
@ -660,6 +660,93 @@ wxBoxSizer *Newer3mfVersionDialog::get_btn_sizer()
|
|||
return horizontal_sizer;
|
||||
}
|
||||
|
||||
NetworkErrorDialog::NetworkErrorDialog(wxWindow* parent)
|
||||
: DPIDialog(parent ? parent : nullptr, wxID_ANY, _L("Server Exception"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
|
||||
{
|
||||
this->SetBackgroundColour(*wxWHITE);
|
||||
std::string icon_path = (boost::format("%1%/images/BambuStudioTitle.ico") % resources_dir()).str();
|
||||
SetIcon(wxIcon(encode_path(icon_path.c_str()), wxBITMAP_TYPE_ICO));
|
||||
|
||||
wxBoxSizer* sizer_main = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
auto m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1), wxTAB_TRAVERSAL);
|
||||
m_line_top->SetBackgroundColour(wxColour(166, 169, 170));
|
||||
|
||||
wxBoxSizer* sizer_bacis_text = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
m_text_basic = new Label(this, _L("The server is unable to respond. Please click the link below to check the server status."));
|
||||
m_text_basic->SetForegroundColour(0x323A3C);
|
||||
m_text_basic->SetMinSize(wxSize(FromDIP(450), -1));
|
||||
m_text_basic->SetMaxSize(wxSize(FromDIP(450), -1));
|
||||
m_text_basic->Wrap(FromDIP(450));
|
||||
m_text_basic->SetFont(::Label::Body_14);
|
||||
sizer_bacis_text->Add(m_text_basic, 0, wxALL, 0);
|
||||
|
||||
|
||||
wxBoxSizer* sizer_link = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
m_link_server_state = new wxHyperlinkCtrl(this, wxID_ANY, _L("Check the status of current system services"), "");
|
||||
m_link_server_state->SetFont(::Label::Body_13);
|
||||
m_link_server_state->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {wxGetApp().link_to_network_check(); });
|
||||
m_link_server_state->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_HAND); });
|
||||
m_link_server_state->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_ARROW); });
|
||||
|
||||
sizer_link->Add(m_link_server_state, 0, wxALL, 0);
|
||||
|
||||
|
||||
wxBoxSizer* sizer_help = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
m_text_proposal = new Label(this, _L("If the server is in a fault state, you can temporarily use offline printing or local network printing."));
|
||||
m_text_proposal->SetMinSize(wxSize(FromDIP(450), -1));
|
||||
m_text_proposal->SetMaxSize(wxSize(FromDIP(450), -1));
|
||||
m_text_proposal->Wrap(FromDIP(450));
|
||||
m_text_proposal->SetFont(::Label::Body_14);
|
||||
m_text_proposal->SetForegroundColour(0x323A3C);
|
||||
|
||||
m_text_wiki = new wxHyperlinkCtrl(this, wxID_ANY, _L("How to use LAN only mode"), "");
|
||||
m_text_wiki->SetFont(::Label::Body_13);
|
||||
m_text_wiki->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {wxGetApp().link_to_lan_only_wiki(); });
|
||||
m_text_wiki->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_HAND); });
|
||||
m_text_wiki->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_ARROW); });
|
||||
|
||||
sizer_help->Add(m_text_proposal, 0, wxEXPAND, 0);
|
||||
sizer_main->Add(0, 0, 0, wxTOP, 6);
|
||||
sizer_help->Add(m_text_wiki, 0, wxALL, 0);
|
||||
|
||||
wxBoxSizer* sizer_button = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer_button->Add(0, 0, 1, wxEXPAND, 5);
|
||||
|
||||
auto bt_enable = StateColor(std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed), std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered),
|
||||
std::pair<wxColour, int>(wxColour(0, 174, 66), StateColor::Normal));
|
||||
|
||||
m_button_confirm = new Button(this, _L("Confirm"));
|
||||
m_button_confirm->SetBackgroundColor(bt_enable);
|
||||
m_button_confirm->SetBorderColor(bt_enable);
|
||||
m_button_confirm->SetTextColor(StateColor::darkModeColorFor("#FFFFFE"));
|
||||
m_button_confirm->SetMinSize(wxSize(FromDIP(68), FromDIP(23)));
|
||||
m_button_confirm->SetMinSize(wxSize(FromDIP(68), FromDIP(23)));
|
||||
m_button_confirm->SetCornerRadius(12);
|
||||
m_button_confirm->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {EndModal(wxCLOSE);});
|
||||
|
||||
sizer_button->Add(m_button_confirm, 0, wxALL, 5);
|
||||
|
||||
sizer_main->Add(m_line_top, 0, wxEXPAND, 0);
|
||||
sizer_main->Add(0, 0, 0, wxTOP, 20);
|
||||
sizer_main->Add(sizer_bacis_text, 0, wxEXPAND | wxLEFT | wxRIGHT, 15);
|
||||
sizer_main->Add(0, 0, 0, wxTOP, 6);
|
||||
sizer_main->Add(sizer_link, 0, wxLEFT | wxRIGHT, 15);
|
||||
sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, 8);
|
||||
sizer_main->Add(sizer_help, 1, wxLEFT | wxRIGHT, 15);
|
||||
sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, 8);
|
||||
sizer_main->Add(sizer_button, 1, wxEXPAND | wxLEFT | wxRIGHT, 15);
|
||||
sizer_main->Add(0, 0, 0, wxTOP, 18);
|
||||
|
||||
SetSizer(sizer_main);
|
||||
Layout();
|
||||
sizer_main->Fit(this);
|
||||
Centre(wxBOTH);
|
||||
}
|
||||
|
||||
} // namespace GUI
|
||||
|
||||
} // namespace Slic3r
|
||||
|
|
|
@ -410,6 +410,22 @@ private:
|
|||
wxStaticText *m_msg_text = nullptr;
|
||||
};
|
||||
|
||||
|
||||
class NetworkErrorDialog : public DPIDialog
|
||||
{
|
||||
public:
|
||||
NetworkErrorDialog(wxWindow* parent);
|
||||
~NetworkErrorDialog() {};
|
||||
virtual void on_dpi_changed(const wxRect& suggested_rect) {};
|
||||
|
||||
private:
|
||||
Label* m_text_basic;
|
||||
wxHyperlinkCtrl* m_link_server_state;
|
||||
Label* m_text_proposal;
|
||||
wxHyperlinkCtrl* m_text_wiki;
|
||||
Button* m_button_confirm;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue