From cb2f6dd772e357a47cbef769f8ea92cadf859c82 Mon Sep 17 00:00:00 2001 From: tao wang Date: Fri, 31 Mar 2023 19:34:08 +0800 Subject: [PATCH] NEW:add network test entry when has network error Change-Id: Ie315191e26148e520d3e8e3e4323fd619efb982a --- src/slic3r/GUI/BBLStatusBar.cpp | 5 ++ src/slic3r/GUI/BBLStatusBar.hpp | 1 + src/slic3r/GUI/BBLStatusBarBind.cpp | 5 ++ src/slic3r/GUI/BBLStatusBarBind.hpp | 1 + src/slic3r/GUI/BBLStatusBarSend.cpp | 64 +++++++++++++++---- src/slic3r/GUI/BBLStatusBarSend.hpp | 3 + src/slic3r/GUI/Jobs/Job.cpp | 5 ++ src/slic3r/GUI/Jobs/Job.hpp | 2 + .../Jobs/NotificationProgressIndicator.cpp | 5 ++ .../Jobs/NotificationProgressIndicator.hpp | 1 + src/slic3r/GUI/Jobs/PrintJob.cpp | 3 +- src/slic3r/GUI/Jobs/ProgressIndicator.hpp | 1 + src/slic3r/GUI/SelectMachine.hpp | 2 +- 13 files changed, 82 insertions(+), 16 deletions(-) diff --git a/src/slic3r/GUI/BBLStatusBar.cpp b/src/slic3r/GUI/BBLStatusBar.cpp index 448b074aa..612fb887c 100644 --- a/src/slic3r/GUI/BBLStatusBar.cpp +++ b/src/slic3r/GUI/BBLStatusBar.cpp @@ -128,6 +128,11 @@ void BBLStatusBar::clear_percent() } +void BBLStatusBar::show_networking_test() +{ + +} + void BBLStatusBar::show_progress(bool show) { if (show) { diff --git a/src/slic3r/GUI/BBLStatusBar.hpp b/src/slic3r/GUI/BBLStatusBar.hpp index ec3864193..04168b896 100644 --- a/src/slic3r/GUI/BBLStatusBar.hpp +++ b/src/slic3r/GUI/BBLStatusBar.hpp @@ -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(); diff --git a/src/slic3r/GUI/BBLStatusBarBind.cpp b/src/slic3r/GUI/BBLStatusBarBind.cpp index 2117e6079..f2e1cbf46 100644 --- a/src/slic3r/GUI/BBLStatusBarBind.cpp +++ b/src/slic3r/GUI/BBLStatusBarBind.cpp @@ -97,6 +97,11 @@ void BBLStatusBarBind::clear_percent() } +void BBLStatusBarBind::show_networking_test() +{ + +} + void BBLStatusBarBind::show_progress(bool show) { if (show) { diff --git a/src/slic3r/GUI/BBLStatusBarBind.hpp b/src/slic3r/GUI/BBLStatusBarBind.hpp index e30fff085..17f5564f1 100644 --- a/src/slic3r/GUI/BBLStatusBarBind.hpp +++ b/src/slic3r/GUI/BBLStatusBarBind.hpp @@ -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(); diff --git a/src/slic3r/GUI/BBLStatusBarSend.cpp b/src/slic3r/GUI/BBLStatusBarSend.cpp index e3dd7f986..327b5d265 100644 --- a/src/slic3r/GUI/BBLStatusBarSend.cpp +++ b/src/slic3r/GUI/BBLStatusBarSend.cpp @@ -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(*wxWHITE, StateColor::Disabled), std::pair(wxColour(38, 46, 48), StateColor::Enabled)); + StateColor btn_bd_white(std::pair(*wxWHITE, StateColor::Disabled), std::pair(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)); } diff --git a/src/slic3r/GUI/BBLStatusBarSend.hpp b/src/slic3r/GUI/BBLStatusBarSend.hpp index 1abe97ee7..10159f436 100644 --- a/src/slic3r/GUI/BBLStatusBarSend.hpp +++ b/src/slic3r/GUI/BBLStatusBarSend.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #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(); diff --git a/src/slic3r/GUI/Jobs/Job.cpp b/src/slic3r/GUI/Jobs/Job.cpp index 8224285cf..bb8ec8c46 100644 --- a/src/slic3r/GUI/Jobs/Job.cpp +++ b/src/slic3r/GUI/Jobs/Job.cpp @@ -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 pri) : m_progress(std::move(pri)) { diff --git a/src/slic3r/GUI/Jobs/Job.hpp b/src/slic3r/GUI/Jobs/Job.hpp index 4041e498f..97926ba59 100644 --- a/src/slic3r/GUI/Jobs/Job.hpp +++ b/src/slic3r/GUI/Jobs/Job.hpp @@ -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 diff --git a/src/slic3r/GUI/Jobs/NotificationProgressIndicator.cpp b/src/slic3r/GUI/Jobs/NotificationProgressIndicator.cpp index e9f957e4f..197347490 100644 --- a/src/slic3r/GUI/Jobs/NotificationProgressIndicator.cpp +++ b/src/slic3r/GUI/Jobs/NotificationProgressIndicator.cpp @@ -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); diff --git a/src/slic3r/GUI/Jobs/NotificationProgressIndicator.hpp b/src/slic3r/GUI/Jobs/NotificationProgressIndicator.hpp index 388bfea93..03f88136a 100644 --- a/src/slic3r/GUI/Jobs/NotificationProgressIndicator.hpp +++ b/src/slic3r/GUI/Jobs/NotificationProgressIndicator.hpp @@ -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; diff --git a/src/slic3r/GUI/Jobs/PrintJob.cpp b/src/slic3r/GUI/Jobs/PrintJob.cpp index ea56483f3..c9a36c0ba 100644 --- a/src/slic3r/GUI/Jobs/PrintJob.cpp +++ b/src/slic3r/GUI/Jobs/PrintJob.cpp @@ -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 { diff --git a/src/slic3r/GUI/Jobs/ProgressIndicator.hpp b/src/slic3r/GUI/Jobs/ProgressIndicator.hpp index b029fa762..66a6db3c0 100644 --- a/src/slic3r/GUI/Jobs/ProgressIndicator.hpp +++ b/src/slic3r/GUI/Jobs/ProgressIndicator.hpp @@ -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; diff --git a/src/slic3r/GUI/SelectMachine.hpp b/src/slic3r/GUI/SelectMachine.hpp index 8326abc12..c94a653af 100644 --- a/src/slic3r/GUI/SelectMachine.hpp +++ b/src/slic3r/GUI/SelectMachine.hpp @@ -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 {