From 146a4a15edabc1d727d58744b9ec7ff71432d021 Mon Sep 17 00:00:00 2001 From: wjyLearn <93930815+wjyLearn@users.noreply.github.com> Date: Mon, 29 Jul 2024 10:53:47 +0800 Subject: [PATCH] y2: fix some bug 1. Fixed a bug where the login window was not destroyed when switching languages; 2. Fixed the display issue when the model does not have the corresponding picture; 3. Fix button display problem when the local device has no IP address. --- src/slic3r/GUI/GUI_App.cpp | 10 ++++++++++ src/slic3r/GUI/GUI_App.hpp | 1 + src/slic3r/GUI/MainFrame.cpp | 2 ++ src/slic3r/GUI/PrintHostDialogs.cpp | 2 +- src/slic3r/GUI/PrinterWebView.cpp | 19 ++++++++++++++++++- src/slic3r/GUI/Widgets/DeviceButton.cpp | 12 ++++++++---- src/slic3r/GUI/Widgets/DeviceButton.hpp | 1 + src/slic3r/Utils/AstroBox.cpp | 2 +- src/slic3r/Utils/Moonraker.cpp | 6 +++--- 9 files changed, 45 insertions(+), 10 deletions(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 1e9c35e..d02ce14 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1957,6 +1957,16 @@ void GUI_App::ShowUserLogin(bool show) } } +// y2 +void GUI_App::shutdown() +{ + if (login_dlg != nullptr) { + BOOST_LOG_TRIVIAL(info) << __FUNCTION__<< boost::format(": destroy login dialog"); + delete login_dlg; + login_dlg = nullptr; + } +} + void GUI_App::SetOnlineLogin(bool status) { mainframe->m_printer_view->SetLoginStatus(status); diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index eac7ac4..246613d 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -201,6 +201,7 @@ public: // Process command line parameters cached in this->init_params, // load configs, STLs etc. void post_init(); + void shutdown(); // If formatted for github, plaintext with OpenGL extensions enclosed into
. // Otherwise HTML formatted for the system info dialog. static std::string get_gl_info(bool for_github); diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index a703582..fed11d0 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -677,6 +677,8 @@ void MainFrame::shutdown() // to avoid any manipulations with them from App->wxEVT_IDLE after of the mainframe closing wxGetApp().tabs_list.clear(); wxGetApp().plater_ = nullptr; + // y2 + wxGetApp().shutdown(); } GalleryDialog* MainFrame::gallery_dialog() diff --git a/src/slic3r/GUI/PrintHostDialogs.cpp b/src/slic3r/GUI/PrintHostDialogs.cpp index 5b54264..90f1e99 100644 --- a/src/slic3r/GUI/PrintHostDialogs.cpp +++ b/src/slic3r/GUI/PrintHostDialogs.cpp @@ -878,7 +878,7 @@ void PrintHostQueueDialog::on_error(Event &evt) if(isAws != std::string::npos) code_msg += _L("Unable to get required resources from AWS server, please check your network settings."); else - code_msg += _L("Unable to get required resources from ESC server, please check your network settings."); + code_msg += _L("Unable to get required resources from Aliyun server, please check your network settings."); } else code_msg = _L("Network connection times out. Please check the device network Settings."); diff --git a/src/slic3r/GUI/PrinterWebView.cpp b/src/slic3r/GUI/PrinterWebView.cpp index 5921d01..0382a8a 100644 --- a/src/slic3r/GUI/PrinterWebView.cpp +++ b/src/slic3r/GUI/PrinterWebView.cpp @@ -339,6 +339,10 @@ void PrinterWebView::SetPresetChanged(bool status) { model_id = "my_printer"; else model_id = preset->config.opt_string("printer_model"); + } + // y2 + else { + model_id = "my_printer"; } const DynamicPrintConfig *cfg_t = &(it->config); @@ -449,10 +453,23 @@ void PrinterWebView::AddButton(const wxString & device_name, #if QDT_RELEASE_TO_PUBLIC void PrinterWebView::AddNetButton(const Device device) { + // y2 + const Preset preset = wxGetApp().preset_bundle->prints.get_edited_preset(); + bool isQIDI = false; + auto models = preset.vendor->models; + for (auto model : models) { + std::string model_id = model.id; + if (device.device_name.find(model_id) != std::string::npos) { + isQIDI = true; + break; + } + } + std::size_t found = device.device_name.find('@'); wxString Machine_Name; wxString device_name; - if (found != std::string::npos) { + // y2 + if (found != std::string::npos && isQIDI) { std::string extracted = device.device_name.substr(found + 1); Machine_Name = Machine_Name.Format("%s%s", extracted, "_thumbnail"); device_name = device_name.Format("%s", device.device_name.substr(0, found)); diff --git a/src/slic3r/GUI/Widgets/DeviceButton.cpp b/src/slic3r/GUI/Widgets/DeviceButton.cpp index 81c4d6d..b56cc09 100644 --- a/src/slic3r/GUI/Widgets/DeviceButton.cpp +++ b/src/slic3r/GUI/Widgets/DeviceButton.cpp @@ -45,6 +45,7 @@ DeviceButton::DeviceButton(wxWindow *parent, wxString ip_text) : DeviceButton(name_text,ip_text) { + m_icon_text = icon; Create(parent, text, icon, style, iconSize); } @@ -250,7 +251,9 @@ void DeviceButton::render(wxDC &dc) if (GetLabel() == "") { dc.DrawBitmap(icon.get_bitmap(), rcContent.x/2+1, rcContent.y/2); - } else if (m_ip_text == "") { + } + // y2 + else if (m_ip_text == "" && m_name_text == "") { //dc.DrawBitmap(icon.get_bitmap(), 10, (GetSize().GetHeight() - icon.get_bitmap().GetHeight()) / 2); if (m_isSimpleMode) { dc.SetFont(wxFont(10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD)); @@ -327,7 +330,7 @@ void DeviceButton::messureSize() wxSize szContent = textSize; if (this->active_icon.bmp().IsOk()) { if (szContent.y > 0) { - //BBS norrow size between text and icon + //QDS norrow size between text and icon szContent.x += 5; } wxSize szIcon = this->active_icon.GetSize(); @@ -336,9 +339,10 @@ void DeviceButton::messureSize() szContent.y = szIcon.y; } wxSize size = szContent + paddingSize * 2; - if (m_isSimpleMode && m_ip_text != "") + // y2 + if (m_isSimpleMode && m_icon_text.find("_thumbnail") != std::string::npos) size.x = 180; - else if (m_ip_text != "") + else if (m_icon_text.find("_thumbnail") != std::string::npos) size.x = 290; if (minSize.GetHeight() > 0) size.SetHeight(minSize.GetHeight()); diff --git a/src/slic3r/GUI/Widgets/DeviceButton.hpp b/src/slic3r/GUI/Widgets/DeviceButton.hpp index f4966eb..4c53801 100644 --- a/src/slic3r/GUI/Widgets/DeviceButton.hpp +++ b/src/slic3r/GUI/Widgets/DeviceButton.hpp @@ -101,6 +101,7 @@ private: wxString m_name_text; wxString m_ip_text; + wxString m_icon_text; wxString m_state_text = "standby"; wxString m_progress_text = "(0%)"; bool m_isSimpleMode = true; diff --git a/src/slic3r/Utils/AstroBox.cpp b/src/slic3r/Utils/AstroBox.cpp index da12100..ef54bed 100644 --- a/src/slic3r/Utils/AstroBox.cpp +++ b/src/slic3r/Utils/AstroBox.cpp @@ -134,7 +134,7 @@ bool AstroBox::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, Error if(body.find("AWS") != std::string::npos) body += ("Unable to get required resources from AWS server, please check your network settings."); else - body += ("Unable to get required resources from ESC server, please check your network settings."); + body += ("Unable to get required resources from Aliyun server, please check your network settings."); } BOOST_LOG_TRIVIAL(error) << boost::format("%1%: Error uploading file: %2%, HTTP %3%, body: `%4%`") % name % error % status % body; error_fn(format_error(body, error, status)); diff --git a/src/slic3r/Utils/Moonraker.cpp b/src/slic3r/Utils/Moonraker.cpp index 33e9001..d3ca8a3 100644 --- a/src/slic3r/Utils/Moonraker.cpp +++ b/src/slic3r/Utils/Moonraker.cpp @@ -175,7 +175,7 @@ std::string Moonraker::get_status(wxString &msg) const if(body.find("AWS") != std::string::npos) body += ("Unable to get required resources from AWS server, please check your network settings."); else - body += ("Unable to get required resources from ESC server, please check your network settings."); + body += ("Unable to get required resources from Aliyun server, please check your network settings."); } BOOST_LOG_TRIVIAL(error) << boost::format("%1%: Error getting version: %2%, HTTP %3%, body: `%4%`") % name % error % status % body; @@ -245,7 +245,7 @@ float Moonraker::get_progress(wxString &msg) const if(body.find("AWS") != std::string::npos) body += ("Unable to get required resources from AWS server, please check your network settings."); else - body += ("Unable to get required resources from ESC server, please check your network settings."); + body += ("Unable to get required resources from Aliyun server, please check your network settings."); } BOOST_LOG_TRIVIAL(error) << boost::format("%1%: Error getting version: %2%, HTTP %3%, body: `%4%`") % name % error % status % body; @@ -369,7 +369,7 @@ bool Moonraker::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, Erro if(body.find("AWS") != std::string::npos) body += ("Unable to get required resources from AWS server, please check your network settings."); else - body += ("Unable to get required resources from ESC server, please check your network settings."); + body += ("Unable to get required resources from Aliyun server, please check your network settings."); } BOOST_LOG_TRIVIAL(error) << boost::format("%1%: Error uploading file: %2%, HTTP %3%, body: `%4%`") % name % error % status % body; error_fn(format_error(body, error, status));