diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index ede699645a..98e78b2437 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -288,49 +288,8 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S preferences_dialog = new PreferencesDialog(this); } - - // bind events from DiffDlg - - bind_diff_dialog(); } -void MainFrame::bind_diff_dialog() -{ - auto get_tab = [](Preset::Type type) { - Tab* null_tab = nullptr; - for (Tab* tab : wxGetApp().tabs_list) - if (tab->type() == type) - return tab; - return null_tab; - }; - - auto transfer = [this, get_tab](Preset::Type type) { - get_tab(type)->transfer_options(diff_dialog.get_left_preset_name(type), - diff_dialog.get_right_preset_name(type), - diff_dialog.get_selected_options(type)); - }; - - auto update_presets = [this, get_tab](Preset::Type type) { - get_tab(type)->update_preset_choice(); - m_plater->sidebar().update_presets(type); - }; - - auto process_options = [this](std::function process) { - const Preset::Type diff_dlg_type = diff_dialog.view_type(); - if (diff_dlg_type == Preset::TYPE_INVALID) { - for (const Preset::Type& type : diff_dialog.types_list() ) - process(type); - } - else - process(diff_dlg_type); - }; - - diff_dialog.Bind(EVT_DIFF_DIALOG_TRANSFER, [process_options, transfer](SimpleEvent&) { process_options(transfer); }); - - diff_dialog.Bind(EVT_DIFF_DIALOG_UPDATE_PRESETS,[process_options, update_presets](SimpleEvent&) { process_options(update_presets); }); -} - - #ifdef _MSW_DARK_MODE static wxString pref() { return " [ "; } static wxString suff() { return " ] "; } diff --git a/src/slic3r/GUI/MainFrame.hpp b/src/slic3r/GUI/MainFrame.hpp index e019d355f9..efde1bb832 100644 --- a/src/slic3r/GUI/MainFrame.hpp +++ b/src/slic3r/GUI/MainFrame.hpp @@ -117,7 +117,6 @@ class MainFrame : public DPIFrame bool can_delete() const; bool can_delete_all() const; bool can_reslice() const; - void bind_diff_dialog(); // MenuBar items changeable in respect to printer technology enum MenuItems diff --git a/src/slic3r/GUI/UnsavedChangesDialog.cpp b/src/slic3r/GUI/UnsavedChangesDialog.cpp index 723937aafa..93b8dbaf26 100644 --- a/src/slic3r/GUI/UnsavedChangesDialog.cpp +++ b/src/slic3r/GUI/UnsavedChangesDialog.cpp @@ -41,10 +41,6 @@ namespace Slic3r { namespace GUI { -wxDEFINE_EVENT(EVT_DIFF_DIALOG_TRANSFER, SimpleEvent); -wxDEFINE_EVENT(EVT_DIFF_DIALOG_UPDATE_PRESETS, SimpleEvent); - - // ---------------------------------------------------------------------------- // ModelNode: a node inside DiffModel // ---------------------------------------------------------------------------- @@ -2062,13 +2058,34 @@ void DiffPresetDialog::button_event(Action act) } else { Hide(); + if (act == Action::Transfer) - wxPostEvent(this, SimpleEvent(EVT_DIFF_DIALOG_TRANSFER)); + process_options([this](Preset::Type type) { + if (Tab* tab = wxGetApp().get_tab(type)) + tab->transfer_options(get_left_preset_name(type), + get_right_preset_name(type), + get_selected_options(type)); + }); else if (!presets_to_save.empty()) - wxPostEvent(this, SimpleEvent(EVT_DIFF_DIALOG_UPDATE_PRESETS)); + process_options([this](Preset::Type type) { + if (Tab* tab = wxGetApp().get_tab(type)) { + tab->update_preset_choice(); + wxGetApp().sidebar().update_presets(type); + } + }); } } +void DiffPresetDialog::process_options(std::function process) +{ + if (m_view_type == Preset::TYPE_INVALID) { + for (const Preset::Type& type : types_list()) + process(type); + } + else + process(m_view_type); +}; + std::string DiffPresetDialog::get_left_preset_name(Preset::Type type) { PresetComboBox* cb = m_preset_combos[int(type - Preset::TYPE_PRINT)].presets_left; diff --git a/src/slic3r/GUI/UnsavedChangesDialog.hpp b/src/slic3r/GUI/UnsavedChangesDialog.hpp index 423599be5e..e83d023d86 100644 --- a/src/slic3r/GUI/UnsavedChangesDialog.hpp +++ b/src/slic3r/GUI/UnsavedChangesDialog.hpp @@ -17,10 +17,7 @@ class ScalableButton; class wxStaticText; namespace Slic3r { -namespace GUI{ - -wxDECLARE_EVENT(EVT_DIFF_DIALOG_TRANSFER, SimpleEvent); -wxDECLARE_EVENT(EVT_DIFF_DIALOG_UPDATE_PRESETS, SimpleEvent); +namespace GUI { // ---------------------------------------------------------------------------- // ModelNode: a node inside DiffModel @@ -412,8 +409,7 @@ public: void show(Preset::Type type = Preset::TYPE_INVALID); void update_presets(Preset::Type type = Preset::TYPE_INVALID, bool update_preset_bundles_from_app = true); - Preset::Type view_type() const { return m_view_type; } - PrinterTechnology printer_technology() const { return m_pr_technology; } + void process_options(std::function process); std::string get_left_preset_name(Preset::Type type); std::string get_right_preset_name(Preset::Type type);