From 2d215d75d216bd00ba9d7f57f2eda1d0ecfc636e Mon Sep 17 00:00:00 2001 From: "xin.zhang" Date: Fri, 11 Jul 2025 11:21:23 +0800 Subject: [PATCH] ENH: use response to support the message; update the panel if SD state changed jira: [STUDIO-12552] Change-Id: I68048c6fa358253664adbf8fe637c6c0c95e1eb9 (cherry picked from commit 65bb25d80435c28bdaa1fe4445f7fc790f5de22f) --- src/slic3r/GUI/MediaFilePanel.cpp | 25 +++++++++++++++---------- src/slic3r/GUI/MediaFilePanel.h | 2 +- src/slic3r/GUI/Monitor.cpp | 17 +++++++++-------- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/slic3r/GUI/MediaFilePanel.cpp b/src/slic3r/GUI/MediaFilePanel.cpp index c841597e34..c498221198 100644 --- a/src/slic3r/GUI/MediaFilePanel.cpp +++ b/src/slic3r/GUI/MediaFilePanel.cpp @@ -210,11 +210,12 @@ MediaFilePanel::MediaFilePanel(wxWindow * parent) MediaFilePanel::~MediaFilePanel() { - SetMachineObject(nullptr); + UpdateByObj(nullptr); } -void MediaFilePanel::SetMachineObject(MachineObject* obj) +void MediaFilePanel::UpdateByObj(MachineObject* obj) { + bool sdcard_state_changed = false; std::string machine = obj ? obj->dev_id : ""; if (obj) { m_lan_mode = obj->is_lan_mode_printer(); @@ -222,23 +223,32 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj) m_lan_passwd = obj->get_access_code(); m_dev_ver = obj->get_ota_version(); m_device_busy = obj->is_camera_busy_off(); - m_sdcard_exist = obj->sdcard_state == MachineObject::SdcardState::HAS_SDCARD_NORMAL; m_local_proto = obj->file_local; m_remote_proto = obj->get_file_remote(); m_model_download_support = obj->file_model_download; + + if (m_sdcard_exist != (obj->sdcard_state == MachineObject::SdcardState::HAS_SDCARD_NORMAL)) { + m_sdcard_exist = obj->sdcard_state == MachineObject::SdcardState::HAS_SDCARD_NORMAL; + sdcard_state_changed = true; + } } else { m_lan_mode = false; m_lan_ip.clear(); m_lan_passwd.clear(); m_dev_ver.clear(); - m_sdcard_exist = false; m_device_busy = false; m_local_proto = 0; m_remote_proto = 0; m_model_download_support = false; + + if (m_sdcard_exist) { + m_sdcard_exist = false; // reset sdcard state when no object + sdcard_state_changed = true; + } } + Enable(obj && obj->is_info_ready() && obj->m_push_count > 0); - if (machine == m_machine) { + if (machine == m_machine && !sdcard_state_changed) { if ((m_waiting_enable && IsEnabled()) || (m_waiting_support && (m_local_proto || m_remote_proto))) { auto fs = m_image_grid->GetFileSystem(); if (fs) fs->Retry(); @@ -446,11 +456,6 @@ void MediaFilePanel::fetchUrl(boost::weak_ptr wfs) fs->SetUrl("0"); return; } - if (!m_sdcard_exist) { - m_image_grid->SetStatus(m_bmp_failed, _L("Please check if the storage is inserted into the printer.\nIf it still cannot be read, you can try formatting the storage.")); - fs->SetUrl("0"); - return; - } if (m_device_busy) { m_image_grid->SetStatus(m_bmp_failed, _L("The printer is currently busy downloading. Please try again after it finishes.")); fs->SetUrl("0"); diff --git a/src/slic3r/GUI/MediaFilePanel.h b/src/slic3r/GUI/MediaFilePanel.h index 270542c5d9..92081d4271 100644 --- a/src/slic3r/GUI/MediaFilePanel.h +++ b/src/slic3r/GUI/MediaFilePanel.h @@ -36,7 +36,7 @@ public: ~MediaFilePanel(); - void SetMachineObject(MachineObject * obj); + void UpdateByObj(MachineObject * obj); void SwitchStorage(bool external); diff --git a/src/slic3r/GUI/Monitor.cpp b/src/slic3r/GUI/Monitor.cpp index f9d2e0c404..523648c610 100644 --- a/src/slic3r/GUI/Monitor.cpp +++ b/src/slic3r/GUI/Monitor.cpp @@ -335,12 +335,6 @@ void MonitorPanel::update_all() if (!dev) return; obj = dev->get_selected_machine(); - m_status_info_panel->obj = obj; - m_upgrade_panel->update(obj); - m_status_info_panel->m_media_play_ctrl->SetMachineObject(obj); - m_media_file_panel->SetMachineObject(obj); - m_side_tools->update_status(obj); - if (!obj) { show_status((int)MONITOR_NO_PRINTER); m_hms_panel->clear_hms_tag(); @@ -350,6 +344,9 @@ void MonitorPanel::update_all() } if (obj->connection_type() != last_conn_type) { last_conn_type = obj->connection_type(); } + + m_side_tools->update_status(obj); + if (obj->is_connecting()) { show_status(MONITOR_CONNECTING); return; @@ -367,9 +364,13 @@ void MonitorPanel::update_all() show_status(MONITOR_NORMAL); - - if (m_status_info_panel->IsShown()) { + auto current_page = m_tabpanel->GetCurrentPage(); + if (current_page == m_status_info_panel) { m_status_info_panel->update(obj); + } else if (current_page == m_upgrade_panel) { + m_upgrade_panel->update(obj); + } else if (current_page == m_media_file_panel) { + m_media_file_panel->UpdateByObj(obj); } if (m_hms_panel->IsShown() || (obj->hms_list.size() != m_hms_panel->temp_hms_list.size())) {