From 8b82f68f57029fc1853edfbaa1b13396ff46dce9 Mon Sep 17 00:00:00 2001 From: "maosheng.wei" Date: Wed, 27 Dec 2023 10:27:38 +0800 Subject: [PATCH] FIX: edit preset dialog can't close on mac Jira: 5696 Change-Id: Ib33dfd07cc588ddd3805e3490a4d8c36dcd890ac --- src/slic3r/GUI/CreatePresetsDialog.cpp | 21 ++------------------- src/slic3r/GUI/CreatePresetsDialog.hpp | 2 ++ src/slic3r/GUI/Plater.cpp | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/slic3r/GUI/CreatePresetsDialog.cpp b/src/slic3r/GUI/CreatePresetsDialog.cpp index c7ad4b15b..14a6fedaf 100644 --- a/src/slic3r/GUI/CreatePresetsDialog.cpp +++ b/src/slic3r/GUI/CreatePresetsDialog.cpp @@ -4456,27 +4456,10 @@ void EditFilamentPresetDialog::edit_preset() } // edit preset - std::shared_ptr need_edit_preset = filament_presets[m_need_edit_preset_index]; - std::string need_edit_preset_name = need_edit_preset->name; - Tab * tab = wxGetApp().get_tab(need_edit_preset->type); - if (tab == nullptr) { - m_selected_printer.clear(); - m_need_edit_preset_index = -1; - return; - } + m_need_edit_preset = filament_presets[m_need_edit_preset_index]; + wxGetApp().params_dialog()->set_editing_filament_id(m_filament_id); EndModal(wxID_EDIT); - //Popup needs to be called before "restore_last_select_item", otherwise the page may not be updated - wxGetApp().params_dialog()->set_editing_filament_id(m_filament_id); - wxGetApp().params_dialog()->Popup(); - tab->restore_last_select_item(); - - tab->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) tab->select_preset(need_edit_preset_name); - - m_selected_printer.clear(); - m_need_edit_preset_index = -1; } wxBoxSizer *EditFilamentPresetDialog::create_filament_basic_info() diff --git a/src/slic3r/GUI/CreatePresetsDialog.hpp b/src/slic3r/GUI/CreatePresetsDialog.hpp index c23341761..ba603db32 100644 --- a/src/slic3r/GUI/CreatePresetsDialog.hpp +++ b/src/slic3r/GUI/CreatePresetsDialog.hpp @@ -356,6 +356,7 @@ public: ~EditFilamentPresetDialog(); wxPanel *get_preset_tree_panel() { return m_preset_tree_panel; } + std::shared_ptr get_need_edit_preset() { return m_need_edit_preset; } void set_printer_name(const std::string &printer_name) { m_selected_printer = printer_name; } void set_need_delete_preset_index(int need_delete_preset_index) { m_need_delete_preset_index = need_delete_preset_index; } void set_need_edit_preset_index(int need_edit_preset_index) { m_need_edit_preset_index = need_edit_preset_index; } @@ -388,6 +389,7 @@ private: wxStaticText * m_note_text = nullptr; int m_need_delete_preset_index = -1; int m_need_edit_preset_index = -1; + std::shared_ptr m_need_edit_preset; std::string m_selected_printer = ""; std::unordered_map>> m_printer_compatible_presets; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 7fa631e66..3dd279a50 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -7746,13 +7746,29 @@ void Plater::priv::on_modify_filament(SimpleEvent &evt) { FilamentInfomation *filament_info = static_cast(evt.GetEventObject()); int res; + std::shared_ptr need_edit_preset; { EditFilamentPresetDialog dlg(wxGetApp().mainframe, filament_info); res = dlg.ShowModal(); + need_edit_preset = dlg.get_need_edit_preset(); } wxGetApp().mainframe->update_side_preset_ui(); update_ui_from_settings(); sidebar->update_all_preset_comboboxes(); + if (wxID_EDIT == res) { + Tab *tab = wxGetApp().get_tab(Preset::Type::TYPE_FILAMENT); + //tab->restore_last_select_item(); + if (tab == nullptr) { return; } + // Popup needs to be called before "restore_last_select_item", otherwise the page may not be updated + wxGetApp().params_dialog()->Popup(); + tab->restore_last_select_item(); + // Opening Studio and directly accessing the Filament settings interface through the edit preset button will not take effect and requires manual settings. + tab->set_just_edit(true); + tab->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) tab->select_preset(need_edit_preset->name); + } + } void Plater::priv::enter_gizmos_stack()