FIX: show message while enable multi-machine

jira: [STUDIO-11980]
Change-Id: I140d2d3f07c217465a2a5b6a0cec09f96135093c
(cherry picked from commit be241bcdcc5ca66d231b646b33dfa87a5ee129f3)
This commit is contained in:
xin.zhang
2025-05-06 15:07:42 +08:00
committed by Noisyfox
parent 32061b6772
commit 5d476c3e3d
3 changed files with 27 additions and 17 deletions

View File

@@ -3615,7 +3615,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
if (jj["errno"].get<int>() == -2) { if (jj["errno"].get<int>() == -2) {
wxString text = _L("The current chamber temperature or the target chamber temperature exceeds 45\u2103. " /* 45°C */ wxString text = _L("The current chamber temperature or the target chamber temperature exceeds 45\u2103. " /* 45°C */
"In order to avoid extruder clogging, low temperature filament (PLA/PETG/TPU) is not allowed to be loaded."); "In order to avoid extruder clogging, low temperature filament (PLA/PETG/TPU) is not allowed to be loaded.");
GUI::wxGetApp().push_notification(text); GUI::wxGetApp().push_notification(this, text);
} }
} }
} }
@@ -3636,7 +3636,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
#if __WXOSX__ #if __WXOSX__
set_ctt_dlg(text); set_ctt_dlg(text);
#else #else
GUI::wxGetApp().push_notification(text); GUI::wxGetApp().push_notification(this, text);
#endif #endif
} }
} }
@@ -4841,7 +4841,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
result = jj["result"].get<std::string>(); result = jj["result"].get<std::string>();
if (result == "FAIL") { if (result == "FAIL") {
wxString text = _L("Failed to start print job"); wxString text = _L("Failed to start print job");
GUI::wxGetApp().push_notification(text); GUI::wxGetApp().push_notification(this, text);
} }
} }
} else if (jj["command"].get<std::string>() == "ams_filament_setting" && !key_field_only) { } else if (jj["command"].get<std::string>() == "ams_filament_setting" && !key_field_only) {
@@ -4991,7 +4991,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
else { else {
info = reason; info = reason;
} }
GUI::wxGetApp().push_notification(info, _L("Calibration error"), UserNotificationStyle::UNS_WARNING_CONFIRM); GUI::wxGetApp().push_notification(this, info, _L("Calibration error"), UserNotificationStyle::UNS_WARNING_CONFIRM);
BOOST_LOG_TRIVIAL(info) << cali_mode << " result fail, reason = " << reason; BOOST_LOG_TRIVIAL(info) << cali_mode << " result fail, reason = " << reason;
} }
} }

View File

@@ -4832,25 +4832,35 @@ void GUI_App::show_dialog(wxString msg)
} }
} }
void GUI_App::push_notification(wxString msg, wxString title, UserNotificationStyle style) void GUI_App::push_notification(const MachineObject* obj, wxString msg, wxString title, UserNotificationStyle style)
{
if (this->is_enable_multi_machine())
{
if (m_device_manager && (obj != m_device_manager->get_selected_machine()))
{
return;
}
}
if (style == UserNotificationStyle::UNS_NORMAL)
{
if (m_info_dialog_content.empty())
{ {
if (!this->is_enable_multi_machine()) {
if (style == UserNotificationStyle::UNS_NORMAL) {
if (m_info_dialog_content.empty()) {
wxCommandEvent* evt = new wxCommandEvent(EVT_SHOW_DIALOG); wxCommandEvent* evt = new wxCommandEvent(EVT_SHOW_DIALOG);
evt->SetString(msg); evt->SetString(msg);
GUI::wxGetApp().QueueEvent(evt); GUI::wxGetApp().QueueEvent(evt);
m_info_dialog_content = msg; m_info_dialog_content = msg;
} }
} }
else if (style == UserNotificationStyle::UNS_WARNING_CONFIRM) { else if (style == UserNotificationStyle::UNS_WARNING_CONFIRM)
GUI::wxGetApp().CallAfter([msg, title] { {
GUI::wxGetApp().CallAfter([msg, title]
{
GUI::MessageDialog msg_dlg(nullptr, msg, title, wxICON_WARNING | wxOK); GUI::MessageDialog msg_dlg(nullptr, msg, title, wxICON_WARNING | wxOK);
msg_dlg.ShowModal(); msg_dlg.ShowModal();
}); });
} }
} }
}
void GUI_App::reload_settings() void GUI_App::reload_settings()
{ {

View File

@@ -491,7 +491,7 @@ public:
static std::string format_display_version(); static std::string format_display_version();
std::string format_IP(const std::string& ip); std::string format_IP(const std::string& ip);
void show_dialog(wxString msg); void show_dialog(wxString msg);
void push_notification(wxString msg, wxString title = wxEmptyString, UserNotificationStyle style = UserNotificationStyle::UNS_NORMAL); void push_notification(const MachineObject* obj, wxString msg, wxString title = wxEmptyString, UserNotificationStyle style = UserNotificationStyle::UNS_NORMAL);
void reload_settings(); void reload_settings();
void remove_user_presets(); void remove_user_presets();
void sync_preset(Preset* preset); void sync_preset(Preset* preset);