FIX:UI stuck due to pop-up window with wrong chamber temperature

JIRA: 5304
Change-Id: I1a49a7219b7a6f5700243704c348724e7930ce1a
This commit is contained in:
hu.wang 2023-11-22 18:30:14 +08:00 committed by Lane.Wei
parent 0b84dd5fd6
commit bbb5396738
2 changed files with 31 additions and 5 deletions

View File

@ -8,6 +8,7 @@
#include "MsgDialog.hpp"
#include "Plater.hpp"
#include "GUI_App.hpp"
#include "ReleaseNote.hpp"
#include <thread>
#include <mutex>
#include <codecvt>
@ -3009,14 +3010,18 @@ int MachineObject::parse_json(std::string payload)
if (jj["command"].get<std::string>() == "set_ctt") {
if (m_agent && is_studio_cmd(sequence_id)) {
if (jj["errno"].is_number()) {
wxString text;
if (jj["errno"].get<int>() == -2) {
wxString text = _L("Low temperature filament(PLA/PETG/TPU) is loaded in the extruder.In order to avoid extruder clogging,it is not allowed to set the chamber temperature above 45\u2103.");
GUI::wxGetApp().show_dialog(text);
text = _L("Low temperature filament(PLA/PETG/TPU) is loaded in the extruder.In order to avoid extruder clogging,it is not allowed to set the chamber temperature above 45\u2103.");
}
else if (jj["errno"].get<int>() == -4) {
wxString text = _L("When you set the chamber temperature below 40\u2103, the chamber temperature control will not be activated. And the target chamber temperature will automatically be set to 0\u2103.");
GUI::wxGetApp().show_dialog(text);
text = _L("When you set the chamber temperature below 40\u2103, the chamber temperature control will not be activated. And the target chamber temperature will automatically be set to 0\u2103.");
}
#if __WXOSX__
set_ctt_dlg(text);
#else
GUI::wxGetApp().show_dialog(text);
#endif
}
}
}
@ -4565,6 +4570,25 @@ int MachineObject::parse_json(std::string payload)
return 0;
}
void MachineObject::set_ctt_dlg( wxString text){
if (!m_set_ctt_dlg) {
m_set_ctt_dlg = true;
auto print_error_dlg = new GUI::SecondaryCheckDialog(nullptr, wxID_ANY, _L("Warning"), GUI::SecondaryCheckDialog::ButtonStyle::ONLY_CONFIRM);
print_error_dlg->update_text(text);
print_error_dlg->Bind(wxEVT_SHOW, [this](auto& e) {
if (!e.IsShown()) {
m_set_ctt_dlg = false;
}
});
print_error_dlg->Bind(wxEVT_CLOSE_WINDOW, [this](auto& e) {
e.Skip();
m_set_ctt_dlg = false;
});
print_error_dlg->on_show();
}
}
int MachineObject::publish_gcode(std::string gcode_str)
{
json j;

View File

@ -52,7 +52,7 @@ using namespace nlohmann;
namespace Slic3r {
class SecondaryCheckDialog;
enum PrinterArch {
ARCH_CORE_XY,
ARCH_I3,
@ -450,8 +450,10 @@ public:
time_t last_alive;
bool m_is_online;
bool m_lan_mode_connection_state{false};
bool m_set_ctt_dlg{ false };
void set_lan_mode_connection_state(bool state) {m_lan_mode_connection_state = state;};
bool get_lan_mode_connection_state() {return m_lan_mode_connection_state;};
void set_ctt_dlg( wxString text);
int parse_msg_count = 0;
int keep_alive_count = 0;
std::chrono::system_clock::time_point last_update_time; /* last received print data from machine */