NEW:Update data only on device pages

jira:[STUDIO-6776]

Change-Id: I33b0c9f35c1dc6df2db3b6bd4f446f46b31ecf6c
This commit is contained in:
tao wang 2024-04-10 15:07:38 +08:00 committed by Lane.Wei
parent 7ee6e62ec4
commit d14f37b00f
2 changed files with 17 additions and 7 deletions

View File

@ -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);

View File

@ -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;};
};