From 6d9ad4412bacf24d83918a8d8cc070bc4db40137 Mon Sep 17 00:00:00 2001 From: hemai Date: Mon, 25 Aug 2025 15:07:46 +0800 Subject: [PATCH] FIX: delete old error code Jira: [STUDIO-14160] Change-Id: I70b2928ffcf84fa864e0906efb079857b3e69e81 (cherry picked from commit f2e5ed1a1aaaa6a1c17637377dd65e48e09591c8) --- src/slic3r/GUI/DeviceErrorDialog.cpp | 58 ++++++++++------------------ src/slic3r/GUI/DeviceErrorDialog.hpp | 1 + 2 files changed, 21 insertions(+), 38 deletions(-) diff --git a/src/slic3r/GUI/DeviceErrorDialog.cpp b/src/slic3r/GUI/DeviceErrorDialog.cpp index 654a91a71d..be7b0fa704 100644 --- a/src/slic3r/GUI/DeviceErrorDialog.cpp +++ b/src/slic3r/GUI/DeviceErrorDialog.cpp @@ -14,33 +14,14 @@ static std::unordered_set message_containing_retry{ "0701-8004", "0701-8005", "0701-8006", - "0701-8006", "0701-8007", - "0700-8012", "0701-8012", "0702-8012", "0703-8012", - "07FF-8003", - "07FF-8004", - "07FF-8005", - "07FF-8006", - "07FF-8007", - "07FF-8010", - "07FF-8011", "07FF-8012", "07FF-8013", - "12FF-8007", - "1200-8006" }; -static std::unordered_set message_containing_done{ - "07FF-8007", - "12FF-8007" -}; - -static std::unordered_set message_containing_resume{ - "0300-8013" -}; DeviceErrorDialog::DeviceErrorDialog(MachineObject* obj, wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) :DPIDialog(parent, id, title, pos, size, style), m_obj(obj) @@ -206,6 +187,17 @@ void DeviceErrorDialog::on_dpi_changed(const wxRect& suggested_rect) Refresh(); } +wxString DeviceErrorDialog::parse_error_level(int error_code) +{ + int level = (error_code & 0x0000F000) >> 12; + switch (level) { + case 0x4: return _L("Error"); + case 0x8: return _L("Warning"); + case 0xC: return _L("Info"); + default: return _L("Unknown"); + } +} + static const std::unordered_set s_jump_liveview_error_codes = { "0300-8003", "0300-8002", "0300-800A"}; wxString DeviceErrorDialog::show_error_code(int error_code) { @@ -219,13 +211,16 @@ wxString DeviceErrorDialog::show_error_code(int error_code) wxString error_msg = wxGetApp().get_hms_query()->query_print_error_msg(m_obj, error_code); if (error_msg.IsEmpty()) { error_msg = _L("Unknown error.");} + /* parse error level */ + wxString error_level = parse_error_level(error_code); + /* error_str is old error code*/ - if (message_containing_retry.count(error_str) || message_containing_done.count(error_str) || message_containing_resume.count(error_str)) { + if (message_containing_retry.count(error_str)) { /* convert old error code to pseudo buttons*/ std::vector pseudo_button = convert_to_pseudo_buttons(error_str); /* do update*/ - update_contents(_L("Warning"), error_msg, error_str, wxEmptyString, pseudo_button); + update_contents(error_level, error_msg, error_str, wxEmptyString, pseudo_button); } else { /* action buttons*/ std::vector used_button; @@ -233,7 +228,7 @@ wxString DeviceErrorDialog::show_error_code(int error_code) if (s_jump_liveview_error_codes.count(error_str)) { used_button.emplace_back(DeviceErrorDialog::JUMP_TO_LIVEVIEW); } // special case /* do update*/ - update_contents(_L("Error"), error_msg, error_str, error_image_url, used_button); + update_contents(error_level, error_msg, error_str, error_image_url, used_button); } wxGetApp().UpdateDlgDarkUI(this); @@ -248,22 +243,9 @@ wxString DeviceErrorDialog::show_error_code(int error_code) std::vector DeviceErrorDialog::convert_to_pseudo_buttons(std::string error_str) { std::vector pseudo_button; - if (message_containing_done.count(error_str) && message_containing_retry.count(error_str)) { - pseudo_button.emplace_back(DBL_CHECK_RETRY); - pseudo_button.emplace_back(DBL_CHECK_DONE); - pseudo_button.emplace_back(DBL_CHECK_OK); - } else if (message_containing_done.count(error_str)) { - pseudo_button.emplace_back(DBL_CHECK_DONE); - pseudo_button.emplace_back(DBL_CHECK_OK); - } else if (message_containing_retry.count(error_str)) { - pseudo_button.emplace_back(DBL_CHECK_RETRY); - pseudo_button.emplace_back(DBL_CHECK_OK); - } else if (message_containing_resume.count(error_str)) { - pseudo_button.emplace_back(DBL_CHECK_RESUME); - pseudo_button.emplace_back(DBL_CHECK_OK); - } else { - pseudo_button.emplace_back(DBL_CHECK_OK); - } + + pseudo_button.emplace_back(DBL_CHECK_RETRY); + pseudo_button.emplace_back(DBL_CHECK_OK); return pseudo_button; } diff --git a/src/slic3r/GUI/DeviceErrorDialog.hpp b/src/slic3r/GUI/DeviceErrorDialog.hpp index 6c172f906f..fb970c3209 100644 --- a/src/slic3r/GUI/DeviceErrorDialog.hpp +++ b/src/slic3r/GUI/DeviceErrorDialog.hpp @@ -71,6 +71,7 @@ protected: void init_button_list(); void init_button(ActionButton style, wxString buton_text); + wxString parse_error_level(int error_code); std::vector convert_to_pseudo_buttons(std::string error_str); void update_contents(const wxString& title, const wxString& text, const wxString& error_code,const wxString& image_url, const std::vector& btns);