From d14f37b00fcd74deaca1024db19ff1d2deddee90 Mon Sep 17 00:00:00 2001 From: tao wang Date: Wed, 10 Apr 2024 15:07:38 +0800 Subject: [PATCH] NEW:Update data only on device pages jira:[STUDIO-6776] Change-Id: I33b0c9f35c1dc6df2db3b6bd4f446f46b31ecf6c --- src/slic3r/GUI/Monitor.cpp | 20 +++++++++++++------- src/slic3r/GUI/Monitor.hpp | 4 ++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/slic3r/GUI/Monitor.cpp b/src/slic3r/GUI/Monitor.cpp index e56644825..527088288 100644 --- a/src/slic3r/GUI/Monitor.cpp +++ b/src/slic3r/GUI/Monitor.cpp @@ -284,17 +284,20 @@ void MonitorPanel::select_machine(std::string machine_sn) void MonitorPanel::on_update_all(wxMouseEvent &event) { - update_all(); - Layout(); - Refresh(); + if (update_flag) { + update_all(); + Layout(); + Refresh(); + } } void MonitorPanel::on_timer(wxTimerEvent& event) { - update_all(); - - Layout(); - Refresh(); + if (update_flag) { + update_all(); + Layout(); + Refresh(); + } } void MonitorPanel::on_select_printer(wxCommandEvent& event) @@ -453,6 +456,8 @@ bool MonitorPanel::Show(bool show) NetworkAgent* m_agent = wxGetApp().getAgent(); DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager(); if (show) { + start_update(); + m_refresh_timer->Stop(); m_refresh_timer->SetOwner(this); m_refresh_timer->Start(REFRESH_INTERVAL); @@ -471,6 +476,7 @@ bool MonitorPanel::Show(bool show) } } } else { + stop_update(); m_refresh_timer->Stop(); } return wxPanel::Show(show); diff --git a/src/slic3r/GUI/Monitor.hpp b/src/slic3r/GUI/Monitor.hpp index d44f400b7..2bdbff21b 100644 --- a/src/slic3r/GUI/Monitor.hpp +++ b/src/slic3r/GUI/Monitor.hpp @@ -104,6 +104,7 @@ private: int last_wifi_signal = -1; int last_status; bool m_initialized { false }; + bool update_flag{false}; wxTimer* m_refresh_timer = nullptr; public: @@ -151,6 +152,9 @@ public: MachineObject *obj { nullptr }; std::string last_conn_type = "undedefined"; + + void stop_update() {update_flag = false;}; + void start_update() {update_flag = true;}; };