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:
tao wang 2024-09-16 22:29:39 +08:00 committed by Noisyfox
parent 569d4e6307
commit 8bb7ea7cfc
7 changed files with 156 additions and 2 deletions

View file

@ -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