FIX: close edit preset paramsDialog, mac unresponsive

Change-Id: Ic816754a20b7f6a5cdb46475750eb301fec3ad3a
This commit is contained in:
maosheng.wei 2023-11-28 18:25:55 +08:00 committed by Lane.Wei
parent 2126999097
commit 8ecafa356f
7 changed files with 41 additions and 18 deletions

View File

@ -12,7 +12,6 @@
#include "MsgDialog.hpp"
#include "FileHelp.hpp"
#include "Tab.hpp"
#include "ParamsDialog.hpp"
#include "MainFrame.hpp"
#define NAME_OPTION_COMBOBOX_SIZE wxSize(FromDIP(200), FromDIP(24))
@ -4431,10 +4430,12 @@ void EditFilamentPresetDialog::edit_preset()
wxGetApp().get_tab(need_edit_preset->type)->select_preset(need_edit_preset_name);
// when some preset have modified, if the printer is not need_edit_preset_name compatible printer, the preset will jump to other preset, need select again
if (!need_edit_preset->is_compatible) wxGetApp().get_tab(need_edit_preset->type)->select_preset(need_edit_preset_name);
wxGetApp().params_dialog()->Popup(true);
m_selected_printer.clear();
m_need_edit_preset_index = -1;
wxGetApp().params_dialog()->set_editing_filament_id(m_filament_id);
EndModal(wxID_EDIT);
}
wxBoxSizer *EditFilamentPresetDialog::create_filament_basic_info()
@ -4917,7 +4918,7 @@ wxPanel *PresetTree::get_child_item(wxPanel *parent, std::shared_ptr<Preset> pre
edit_preset_btn->SetBackgroundColor(flush_bg_col);
edit_preset_btn->SetBorderColor(flush_bd_col);
edit_preset_btn->SetTextColor(flush_fg_col);
edit_preset_btn->Hide();
//edit_preset_btn->Hide();
sizer->Add(edit_preset_btn, 0, wxALL | wxALIGN_CENTER_VERTICAL, 0);
sizer->Add(0, 0, 0, wxLEFT, 5);

View File

@ -11,17 +11,11 @@
#include "Widgets/CheckBox.hpp"
#include "Widgets/ComboBox.hpp"
#include "miniz.h"
#include "ParamsDialog.hpp"
namespace Slic3r {
namespace GUI {
class FilamentInfomation : public wxObject
{
public:
std::string filament_id;
std::string filament_name;
};
class CreateFilamentPresetDialog : public DPIDialog
{
public:

View File

@ -52,6 +52,12 @@ ParamsDialog::ParamsDialog(wxWindow * parent)
}
#else
Hide();
if (!m_editing_filament_id.empty()) {
FilamentInfomation *filament_info = new FilamentInfomation();
filament_info->filament_id = m_editing_filament_id;
wxQueueEvent(wxGetApp().plater(), new SimpleEvent(EVT_MODIFY_FILAMENT, filament_info));
m_editing_filament_id.clear();
}
#endif
wxGetApp().sidebar().finish_param_edit();
});

View File

@ -11,6 +11,15 @@
namespace Slic3r {
namespace GUI {
wxDECLARE_EVENT(EVT_MODIFY_FILAMENT, SimpleEvent);
class FilamentInfomation : public wxObject
{
public:
std::string filament_id;
std::string filament_name;
};
class ParamsPanel;
class ParamsDialog : public DPIDialog
@ -22,10 +31,13 @@ public:
void Popup(bool just_edit = false);
void set_editing_filament_id(std::string id) { m_editing_filament_id = id; }
protected:
void on_dpi_changed(const wxRect& suggested_rect) override;
private:
std::string m_editing_filament_id;
ParamsPanel * m_panel;
wxWindowDisabler *m_winDisabler = nullptr;
};

View File

@ -7634,11 +7634,17 @@ void Plater::priv::on_create_filament(SimpleEvent &)
void Plater::priv::on_modify_filament(SimpleEvent &evt)
{
FilamentInfomation *filament_info = static_cast<FilamentInfomation *>(evt.GetEventObject());
int res;
{
EditFilamentPresetDialog dlg(wxGetApp().mainframe, filament_info);
int res = dlg.ShowModal();
res = dlg.ShowModal();
}
wxGetApp().mainframe->update_side_preset_ui();
update_ui_from_settings();
sidebar->update_all_preset_comboboxes();
if (wxID_EDIT == res) {
wxGetApp().params_dialog()->Popup(true);
}
}
void Plater::priv::enter_gizmos_stack()

View File

@ -367,11 +367,8 @@ void GuideFrame::OnScriptMessage(wxWebViewEvent &evt)
this->EndModal(wxID_OK);
wxQueueEvent(wxGetApp().plater(), new SimpleEvent(EVT_CREATE_FILAMENT));
} else if (strCmd == "modify_custom_filament") {
this->EndModal(wxID_OK);
FilamentInfomation *filament_info = new FilamentInfomation();
filament_info->filament_id = j["id"];
//filament_info->filament_name = j["name"];
wxQueueEvent(wxGetApp().plater(), new SimpleEvent(EVT_MODIFY_FILAMENT, filament_info));
m_editing_filament_id = j["id"];
this->EndModal(wxID_EDIT);
}
else if (strCmd == "save_userguide_models")
{
@ -917,6 +914,12 @@ bool GuideFrame::run()
}
else
return false;
} else if (result == wxID_EDIT) {
this->Close();
FilamentInfomation *filament_info = new FilamentInfomation();
filament_info->filament_id = m_editing_filament_id;
wxQueueEvent(wxGetApp().plater(), new SimpleEvent(EVT_MODIFY_FILAMENT, filament_info));
return false;
}
else
return false;

View File

@ -124,6 +124,7 @@ private:
wxString m_response_js;
wxString m_bbl_user_agent;
std::string m_editing_filament_id;
};
}} // namespace Slic3r::GUI