FIX:fixed the invisibility of the cancel button when sending fails

Change-Id: I32e9cf0c5846565a3bc9155c57289be9df148bde
This commit is contained in:
tao wang 2023-04-12 17:37:21 +08:00 committed by Lane.Wei
parent 40068156fe
commit d57931eacd
12 changed files with 46 additions and 22 deletions

View File

@ -128,7 +128,7 @@ void BBLStatusBar::clear_percent()
}
void BBLStatusBar::show_networking_test()
void BBLStatusBar::show_networking_test(wxString msg)
{
}

View File

@ -45,7 +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_networking_test(wxString msg) override;
void show_progress(bool);
void start_busy(int = 100);
void stop_busy();

View File

@ -97,7 +97,7 @@ void BBLStatusBarBind::clear_percent()
}
void BBLStatusBarBind::show_networking_test()
void BBLStatusBarBind::show_networking_test(wxString msg)
{
}

View File

@ -48,7 +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_networking_test(wxString msg) override;
void show_progress(bool);
void start_busy(int = 100);
void stop_busy();

View File

@ -40,6 +40,7 @@ BBLStatusBarSend::BBLStatusBarSend(wxWindow *parent, int id)
m_cancelbutton = new Button(m_self, _L("Cancel"));
m_cancelbutton->SetMinSize(wxSize(m_self->FromDIP(58), m_self->FromDIP(22)));
m_cancelbutton->SetMaxSize(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));
@ -55,7 +56,8 @@ BBLStatusBarSend::BBLStatusBarSend(wxWindow *parent, int id)
m_stext_percent->SetFont(::Label::Body_13);
m_stext_percent->Wrap(-1);
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 = new Label(m_self, _L("Check the status of current system services"));
m_hyperlink->SetForegroundColour(0x00AE42);
m_hyperlink->SetFont(::Label::Body_12);
m_hyperlink->Hide();
m_sizer_bottom->Add(m_prog, 1, wxALIGN_CENTER, 0);
@ -65,7 +67,7 @@ BBLStatusBarSend::BBLStatusBarSend(wxWindow *parent, int id)
m_sizer_bottom->Add(m_cancelbutton, 0, wxALIGN_CENTER, 0);
m_sizer_body->Add(m_status_text, 0, 0, 0);
m_sizer_body->Add(m_status_text, 0, wxALL, 0);
m_sizer_body->Add(0, 0, 0, wxTOP, 1);
m_sizer_body->Add(m_sizer_bottom, 1, wxEXPAND, 0);
@ -124,12 +126,8 @@ void BBLStatusBarSend::clear_percent()
m_cancelbutton->Hide();
}
void BBLStatusBarSend::show_networking_test()
void BBLStatusBarSend::show_networking_test(wxString msg)
{
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();
@ -153,7 +151,26 @@ void BBLStatusBarSend::show_networking_test()
url = "https://status.bambu-lab.com";
}
m_hyperlink->SetURL(url);
m_hyperlink->Bind(wxEVT_LEFT_DOWN, [this, url](auto& e) {
wxLaunchDefaultBrowser(url);
});
m_hyperlink->Bind(wxEVT_ENTER_WINDOW, [this, url](auto& e) {
m_hyperlink->SetCursor(wxCURSOR_HAND);
});
m_hyperlink->Bind(wxEVT_LEAVE_WINDOW, [this, url](auto& e) {
m_hyperlink->SetCursor(wxCURSOR_ARROW);
});
set_status_text(msg);
m_prog->Hide();
m_stext_percent->Hide();
m_hyperlink->Show();
m_cancelbutton->Show();
m_self->Layout();
m_sizer->Layout();
}
void BBLStatusBarSend::show_progress(bool show)

View File

@ -30,7 +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;
Label * m_hyperlink;
Button * m_cancelbutton;
wxStaticText *m_status_text;
wxStaticText *m_stext_percent;
@ -51,7 +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_networking_test(wxString msg) override;
void show_progress(bool);
void start_busy(int = 100);
void stop_busy();

View File

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

View File

@ -47,7 +47,7 @@ protected:
void update_percent_finish();
void show_networking_test();
void show_networking_test(wxString msg);
bool was_canceled() const { return m_canceled.load(); }

View File

@ -10,7 +10,7 @@ void NotificationProgressIndicator::clear_percent()
}
void NotificationProgressIndicator::show_networking_test()
void NotificationProgressIndicator::show_networking_test(wxString msg)
{
}

View File

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

View File

@ -401,7 +401,6 @@ void PrintJob::process()
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.");
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 {
@ -411,7 +410,15 @@ void PrintJob::process()
curr_percent = 0;
msg_text += wxString::Format("[%d][%s]", result, error_text);
}
update_status(curr_percent, msg_text);
if (result == BAMBU_NETWORK_ERR_INVALID_RESULT) {
this->show_networking_test(msg_text);
}
else {
update_status(curr_percent, msg_text);
}
BOOST_LOG_TRIVIAL(error) << "print_job: failed, result = " << result;
} else {
BOOST_LOG_TRIVIAL(error) << "print_job: send ok.";

View File

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