ENH:fixed info dialog popping up many times

Change-Id: I2016bc9b722601d153d35ddfbbc4c287bd37f9a1
This commit is contained in:
tao wang 2023-07-04 18:19:26 +08:00 committed by Lane.Wei
parent d6b11a676e
commit d446db4869
3 changed files with 27 additions and 8 deletions

View file

@ -2558,11 +2558,10 @@ bool GUI_App::on_init_inner()
Bind(EVT_SHOW_DIALOG, [this](const wxCommandEvent& evt) { Bind(EVT_SHOW_DIALOG, [this](const wxCommandEvent& evt) {
wxString msg = evt.GetString(); wxString msg = evt.GetString();
InfoDialog dlg(this->mainframe, _L("Info"), msg); InfoDialog dlg(this->mainframe, _L("Info"), msg);
dlg.Bind(wxEVT_DESTROY, [this](auto& e) {
m_info_dialog_content = wxEmptyString;
});
dlg.ShowModal(); dlg.ShowModal();
/*wxString text = evt.GetString();
Slic3r::GUI::MessageDialog msg_dlg(this->mainframe, text, "", wxAPPLY | wxOK);
msg_dlg.ShowModal();*/
}); });
} }
else { else {
@ -4489,9 +4488,12 @@ std::string GUI_App::format_display_version()
void GUI_App::show_dialog(wxString msg) void GUI_App::show_dialog(wxString msg)
{ {
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;
}
} }
void GUI_App::reload_settings() void GUI_App::reload_settings()

View file

@ -292,6 +292,7 @@ private:
bool m_is_dark_mode{ false }; bool m_is_dark_mode{ false };
bool m_adding_script_handler { false }; bool m_adding_script_handler { false };
bool m_side_popup_status{false}; bool m_side_popup_status{false};
wxString m_info_dialog_content;
HttpServer m_http_server; HttpServer m_http_server;
boost::thread m_check_network_thread; boost::thread m_check_network_thread;
@ -308,6 +309,7 @@ public:
//explicit GUI_App(EAppMode mode = EAppMode::Editor); //explicit GUI_App(EAppMode mode = EAppMode::Editor);
~GUI_App() override; ~GUI_App() override;
void show_message_box(std::string msg) { wxMessageBox(msg); } void show_message_box(std::string msg) { wxMessageBox(msg); }
EAppMode get_app_mode() const { return m_app_mode; } EAppMode get_app_mode() const { return m_app_mode; }
Slic3r::DeviceManager* getDeviceManager() { return m_device_manager; } Slic3r::DeviceManager* getDeviceManager() { return m_device_manager; }
@ -317,6 +319,7 @@ public:
bool is_gcode_viewer() const { return m_app_mode == EAppMode::GCodeViewer; } bool is_gcode_viewer() const { return m_app_mode == EAppMode::GCodeViewer; }
bool is_recreating_gui() const { return m_is_recreating_gui; } bool is_recreating_gui() const { return m_is_recreating_gui; }
std::string logo_name() const { return is_editor() ? "BambuStudio" : "BambuStudio-gcodeviewer"; } std::string logo_name() const { return is_editor() ? "BambuStudio" : "BambuStudio-gcodeviewer"; }
wxString get_inf_dialog_contect () {return m_info_dialog_content;};
std::vector<std::string> split_str(std::string src, std::string separator); std::vector<std::string> split_str(std::string src, std::string separator);
// To be called after the GUI is fully built up. // To be called after the GUI is fully built up.

View file

@ -1989,6 +1989,13 @@ struct Plater::priv
if (m_select_machine_dlg) if (m_select_machine_dlg)
m_select_machine_dlg->EndModal(wxID_OK); m_select_machine_dlg->EndModal(wxID_OK);
} }
void enter_prepare_mode()
{
if (m_select_machine_dlg)
m_select_machine_dlg->prepare_mode();
}
void hide_send_to_printer_dlg() { m_send_to_sdcard_dlg->EndModal(wxID_OK); } void hide_send_to_printer_dlg() { m_send_to_sdcard_dlg->EndModal(wxID_OK); }
void update_preview_bottom_toolbar(); void update_preview_bottom_toolbar();
@ -10854,7 +10861,14 @@ void Plater::send_calibration_job_finished(wxCommandEvent & evt)
void Plater::print_job_finished(wxCommandEvent &evt) void Plater::print_job_finished(wxCommandEvent &evt)
{ {
//start print failed
if (Slic3r::GUI::wxGetApp().get_inf_dialog_contect().empty()) {
p->hide_select_machine_dlg(); p->hide_select_machine_dlg();
}
else {
p->enter_prepare_mode();
}
Slic3r::DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager(); Slic3r::DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) return; if (!dev) return;