NEW:add network test entry when has network error

Change-Id: Ie315191e26148e520d3e8e3e4323fd619efb982a
This commit is contained in:
tao wang 2023-03-31 19:34:08 +08:00 committed by Lane.Wei
parent 00e1c50947
commit cb2f6dd772
13 changed files with 82 additions and 16 deletions

View File

@ -128,6 +128,11 @@ void BBLStatusBar::clear_percent()
}
void BBLStatusBar::show_networking_test()
{
}
void BBLStatusBar::show_progress(bool show)
{
if (show) {

View File

@ -45,6 +45,7 @@ public:
int get_range() const override;
void set_range(int = 100) override;
void clear_percent() override;
void show_networking_test() override;
void show_progress(bool);
void start_busy(int = 100);
void stop_busy();

View File

@ -97,6 +97,11 @@ void BBLStatusBarBind::clear_percent()
}
void BBLStatusBarBind::show_networking_test()
{
}
void BBLStatusBarBind::show_progress(bool show)
{
if (show) {

View File

@ -48,6 +48,7 @@ public:
int get_range() const override;
void set_range(int = 100) override;
void clear_percent() override;
void show_networking_test() override;
void show_progress(bool);
void start_busy(int = 100);
void stop_busy();

View File

@ -29,23 +29,16 @@ BBLStatusBarSend::BBLStatusBarSend(wxWindow *parent, int id)
m_status_text = new wxStaticText(m_self, wxID_ANY, wxEmptyString);
m_status_text->SetForegroundColour(wxColour(107, 107, 107));
m_status_text->SetFont(::Label::Body_13);
m_status_text->SetSize(wxSize(m_self->FromDIP(280), m_self->FromDIP(46)));
m_status_text->SetMaxSize(wxSize(m_self->FromDIP(280), m_self->FromDIP(46)));
m_status_text->SetSize(wxSize(m_self->FromDIP(300), m_self->FromDIP(46)));
m_status_text->SetMaxSize(wxSize(m_self->FromDIP(300), m_self->FromDIP(46)));
m_prog = new wxGauge(m_self, wxID_ANY, 100, wxDefaultPosition, wxSize(-1, m_self->FromDIP(6)), wxGA_HORIZONTAL);
m_prog->SetValue(0);
/* block_left = new wxWindow(m_prog, wxID_ANY, wxPoint(0, 0), wxSize(2, m_prog->GetSize().GetHeight() * 2));
block_left->SetBackgroundColour(wxColour(255, 255, 255));
block_right = new wxWindow(m_prog, wxID_ANY, wxPoint(m_prog->GetSize().GetWidth() - 2, 0), wxSize(2, m_prog->GetSize().GetHeight() * 2));
block_right->SetBackgroundColour(wxColour(255, 255, 255));*/
m_sizer_bottom->Add(m_prog, 1, wxALIGN_CENTER, 0);
StateColor btn_bd_white(std::pair<wxColour, int>(*wxWHITE, StateColor::Disabled), std::pair<wxColour, int>(wxColour(38, 46, 48), StateColor::Enabled));
StateColor btn_bd_white(std::pair<wxColour, int>(*wxWHITE, StateColor::Disabled), std::pair<wxColour, int>(wxColour(38, 46, 48), StateColor::Enabled));
m_cancelbutton = new Button(m_self, _L("Cancel"));
m_cancelbutton->SetMinSize(wxSize(m_self->FromDIP(64), m_self->FromDIP(24)));
m_cancelbutton->SetMinSize(wxSize(m_self->FromDIP(58), m_self->FromDIP(22)));
m_cancelbutton->SetBackgroundColor(wxColour(255, 255, 255));
m_cancelbutton->SetBorderColor(btn_bd_white);
m_cancelbutton->SetCornerRadius(m_self->FromDIP(12));
@ -60,10 +53,17 @@ BBLStatusBarSend::BBLStatusBarSend(wxWindow *parent, int id)
m_stext_percent->SetForegroundColour(wxColour(107, 107, 107));
m_stext_percent->SetFont(::Label::Body_13);
m_stext_percent->Wrap(-1);
m_sizer_bottom->Add(m_stext_percent, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, 10);
m_hyperlink = new wxHyperlinkCtrl(m_self, wxID_ANY, _L("Check the status of current system services"), wxT("https://status.bambulab.com/"), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
m_hyperlink->SetFont(::Label::Body_12);
m_hyperlink->Hide();
m_sizer_bottom->Add(m_prog, 1, wxALIGN_CENTER, 0);
m_sizer_bottom->Add(m_stext_percent, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, 10);
m_sizer_bottom->Add(m_hyperlink, 0, wxALIGN_CENTER, 10);
m_sizer_bottom->Add(0, 0, 1, wxEXPAND, 0);
m_sizer_bottom->Add(m_cancelbutton, 0, wxALIGN_CENTER, 0);
m_sizer_body->Add(m_status_text, 0, 0, 0);
m_sizer_body->Add(0, 0, 0, wxTOP, 1);
m_sizer_body->Add(m_sizer_bottom, 1, wxEXPAND, 0);
@ -123,6 +123,38 @@ void BBLStatusBarSend::clear_percent()
m_cancelbutton->Hide();
}
void BBLStatusBarSend::show_networking_test()
{
m_prog->Hide();
m_stext_percent->Hide();
m_hyperlink->Show();
std::string url;
std::string country_code = Slic3r::GUI::wxGetApp().app_config->get_country_code();
if (country_code == "US") {
url = "https://status.bambulab.com";
}
else if (country_code == "CN") {
url = "https://status.bambulab.cn";
}
else if (country_code == "ENV_CN_DEV") {
url = "https://status.bambu-lab.com";
}
else if (country_code == "ENV_CN_QA") {
url = "https://status.bambu-lab.com";
}
else if (country_code == "ENV_CN_PRE") {
url = "https://status.bambu-lab.com";
}
else {
url = "https://status.bambu-lab.com";
}
m_hyperlink->SetURL(url);
}
void BBLStatusBarSend::show_progress(bool show)
{
if (show) {
@ -234,7 +266,7 @@ void BBLStatusBarSend::set_status_text(const wxString& txt)
//auto txtss = "The printing project is being uploaded... 25%%";
//m_status_text->SetLabelText(txtss);
wxString str;
format_text(m_status_text, m_self->FromDIP(280), txt, str);
format_text(m_status_text, m_self->FromDIP(300), txt, str);
m_status_text->SetLabelText(str);
m_self->Layout();
//if (is_english_text(str)) m_status_text->Wrap(m_self->FromDIP(280));
@ -281,9 +313,13 @@ bool BBLStatusBarSend::update_status(wxString &msg, bool &was_cancel, int percen
void BBLStatusBarSend::reset()
{
m_hyperlink->Hide();
m_prog->Show();
m_stext_percent->Show();
m_cancelbutton->Show();
set_status_text("");
m_was_cancelled = false;
set_status_text("");
set_progress(0);
set_percent_text(wxString::Format("%d%%", 0));
}

View File

@ -8,6 +8,7 @@
#include <string>
#include <functional>
#include <string>
#include <wx/hyperlink.h>
#include "Jobs/ProgressIndicator.hpp"
#include "Widgets/Label.hpp"
@ -29,6 +30,7 @@ class BBLStatusBarSend : public ProgressIndicator
{
wxPanel * m_self; // we cheat! It should be the base class but: perl!
wxGauge * m_prog;
wxHyperlinkCtrl * m_hyperlink;
Button * m_cancelbutton;
wxStaticText *m_status_text;
wxStaticText *m_stext_percent;
@ -49,6 +51,7 @@ public:
int get_range() const override;
void set_range(int = 100) override;
void clear_percent() override;
void show_networking_test() override;
void show_progress(bool);
void start_busy(int = 100);
void stop_busy();

View File

@ -35,6 +35,11 @@ void GUI::Job::update_percent_finish()
m_progress->clear_percent();
}
void GUI::Job::show_networking_test()
{
m_progress->show_networking_test();
}
GUI::Job::Job(std::shared_ptr<ProgressIndicator> pri)
: m_progress(std::move(pri))
{

View File

@ -47,6 +47,8 @@ protected:
void update_percent_finish();
void show_networking_test();
bool was_canceled() const { return m_canceled.load(); }
// Launched just before start(), a job can use it to prepare internals

View File

@ -10,6 +10,11 @@ void NotificationProgressIndicator::clear_percent()
}
void NotificationProgressIndicator::show_networking_test()
{
}
void NotificationProgressIndicator::set_range(int range)
{
m_nm->progress_indicator_set_range(range);

View File

@ -15,6 +15,7 @@ public:
explicit NotificationProgressIndicator(NotificationManager *nm);
void clear_percent() override;
void show_networking_test() override;
void set_range(int range) override;
void set_cancel_callback(CancelFn = CancelFn()) override;
void set_progress(int pr) override;

View File

@ -384,7 +384,8 @@ void PrintJob::process()
} else if (result == BAMBU_NETWORK_ERR_TIMEOUT) {
msg_text = timeout_to_upload_str;
} else if (result == BAMBU_NETWORK_ERR_INVALID_RESULT) {
msg_text = _L("Failed to send the print job. Please try again.");
msg_text = _L("Failed to send the print job. Please try again.");
this->show_networking_test();
} else if (result == BAMBU_NETWORK_ERR_FTP_UPLOAD_FAILED) {
msg_text = _L("Failed to send the print job. Please try again.");
} else {

View File

@ -18,6 +18,7 @@ public:
virtual ~ProgressIndicator() = default;
virtual void clear_percent() = 0;
virtual void show_networking_test() = 0;
virtual void set_range(int range) = 0;
virtual void set_cancel_callback(CancelFn = CancelFn()) = 0;
virtual void set_progress(int pr) = 0;

View File

@ -230,7 +230,7 @@ private:
};
#define SELECT_MACHINE_DIALOG_BUTTON_SIZE wxSize(FromDIP(68), FromDIP(24))
#define SELECT_MACHINE_DIALOG_SIMBOOK_SIZE wxSize(FromDIP(350), FromDIP(70))
#define SELECT_MACHINE_DIALOG_SIMBOOK_SIZE wxSize(FromDIP(360), FromDIP(70))
enum PrintDialogStatus {