From e025860b2c11476a353c7441571852c8b3a54b18 Mon Sep 17 00:00:00 2001 From: Azi Date: Fri, 6 Feb 2026 07:02:48 -0800 Subject: [PATCH] feature:added option to save a profile as detached(no inheritance) (#7071) * added option to save a profile as detached(no inheritance) * Revert "added option to save a profile as detached(no inheritance)" This reverts commit c1326c6decd7bae49d2e8e811ae2f477a3b1186a. * re-commiting the changes * fixed conflicts with upstream --------- Co-authored-by: SoftFever --- src/slic3r/GUI/SavePresetDialog.cpp | 25 +++++++++++++++++++++---- src/slic3r/GUI/SavePresetDialog.hpp | 12 ++++++++++-- src/slic3r/GUI/Tab.cpp | 6 ++++-- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/slic3r/GUI/SavePresetDialog.cpp b/src/slic3r/GUI/SavePresetDialog.cpp index 2a7b29d7c5..e185ad7e34 100644 --- a/src/slic3r/GUI/SavePresetDialog.cpp +++ b/src/slic3r/GUI/SavePresetDialog.cpp @@ -111,6 +111,15 @@ SavePresetDialog::Item::Item(Preset::Type type, const std::string &suffix, wxBox sizer->Add(m_radio_group, 0, wxEXPAND | wxTOP | wxLEFT, BORDER_W); + if (parent->m_mode == comDevelop) { + m_detach_checkbox = new wxCheckBox(parent, wxID_ANY, _L("Detach from parent")); + sizer->Add(m_detach_checkbox, 0, wxALIGN_LEFT | wxALL, BORDER_W); + // Set initial state (unchecked by default) + m_detach_checkbox->SetValue(m_detach); + // Bind the checkbox event to update the detach state for this item + m_detach_checkbox->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent&) { m_detach = m_detach_checkbox->GetValue(); }); + } + m_radio_group->Bind(wxEVT_COMMAND_RADIOBOX_SELECTED, [this](wxCommandEvent &e) { m_save_to_project = m_radio_group->GetSelection() == 1; }); @@ -242,15 +251,15 @@ void SavePresetDialog::Item::DoSetSize(int x, int y, int width, int height, int // SavePresetDialog //----------------------------------------------- -SavePresetDialog::SavePresetDialog(wxWindow *parent, Preset::Type type, std::string suffix) - : DPIDialog(parent, wxID_ANY, _L("Save preset"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX) +SavePresetDialog::SavePresetDialog(wxWindow* parent, Preset::Type type, int mode, std::string suffix) + : DPIDialog(parent, wxID_ANY, _L("Save preset"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX), m_mode(mode) { build(std::vector{type}, suffix); wxGetApp().UpdateDlgDarkUI(this); } -SavePresetDialog::SavePresetDialog(wxWindow *parent, std::vector types, std::string suffix) - : DPIDialog(parent, wxID_ANY, _L("Save preset"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX) +SavePresetDialog::SavePresetDialog(wxWindow* parent, std::vector types, int mode, std::string suffix) + : DPIDialog(parent, wxID_ANY, _L("Save preset"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX), m_mode(mode) { build(types, suffix); wxGetApp().UpdateDlgDarkUI(this); @@ -328,6 +337,14 @@ bool SavePresetDialog::get_save_to_project_selection(Preset::Type type) return false; } +bool SavePresetDialog::get_detach_value(Preset::Type type) +{ + for (const Item* item : m_items) + if (item->type() == type) + return item->is_detached(); + return false; +} + bool SavePresetDialog::enable_ok_btn() const { for (const Item *item : m_items) diff --git a/src/slic3r/GUI/SavePresetDialog.hpp b/src/slic3r/GUI/SavePresetDialog.hpp index 618bfb49c8..0b71325927 100644 --- a/src/slic3r/GUI/SavePresetDialog.hpp +++ b/src/slic3r/GUI/SavePresetDialog.hpp @@ -56,6 +56,9 @@ class SavePresetDialog : public DPIDialog //BBS: add project embedded preset relate logic bool save_to_project() const { return m_save_to_project; } + // Method to get detach state + bool is_detached() const { return m_detach; } + Preset::Type m_type; ValidationType m_valid_type; std::string m_preset_name; @@ -71,6 +74,8 @@ class SavePresetDialog : public DPIDialog //BBS: add project embedded preset relate logic bool m_save_to_project {false}; RadioGroup* m_radio_group; // ORCA + bool m_detach{false}; + wxCheckBox* m_detach_checkbox{nullptr}; void update(); }; @@ -81,13 +86,14 @@ class SavePresetDialog : public DPIDialog wxStaticText* m_label {nullptr}; wxBoxSizer* m_radio_sizer {nullptr}; ActionType m_action {UndefAction}; + int m_mode; std::string m_ph_printer_name; std::string m_old_preset_name; public: - SavePresetDialog(wxWindow *parent, Preset::Type type, std::string suffix = ""); - SavePresetDialog(wxWindow* parent, std::vector types, std::string suffix = ""); + SavePresetDialog(wxWindow* parent, Preset::Type type, int mode = 0, std::string suffix = ""); + SavePresetDialog(wxWindow* parent, std::vector types, int mode = 0, std::string suffix = ""); ~SavePresetDialog(); void AddItem(Preset::Type type, const std::string& suffix); @@ -103,6 +109,8 @@ public: void layout(); //BBS: add project embedded preset relate logic bool get_save_to_project_selection(Preset::Type type); + // Method to get the detach state + bool get_detach_value(Preset::Type type); protected: void on_dpi_changed(const wxRect& suggested_rect) override; diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index c33b72471c..2ef5c7ba12 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -6340,17 +6340,18 @@ void Tab::save_preset(std::string name /*= ""*/, bool detach, bool save_to_proje // focus currently.is there anything better than this ? //! m_tabctrl->OnSetFocus(); if (from_input) { - SavePresetDialog dlg(m_parent, m_type, detach ? _u8L("Detached") : ""); + SavePresetDialog dlg(m_parent, m_type, m_mode, detach ? _u8L("Detached") : ""); dlg.Show(false); dlg.input_name_from_other(input_name); wxCommandEvent evt(wxEVT_TEXT, GetId()); dlg.GetEventHandler()->ProcessEvent(evt); dlg.confirm_from_other(); name = input_name; + detach = dlg.get_detach_value(m_type); } if (name.empty()) { - SavePresetDialog dlg(m_parent, m_type, detach ? _u8L("Detached") : ""); + SavePresetDialog dlg(m_parent, m_type, m_mode, detach ? _u8L("Detached") : ""); if (!m_just_edit) { if (dlg.ShowModal() != wxID_OK) return; @@ -6358,6 +6359,7 @@ void Tab::save_preset(std::string name /*= ""*/, bool detach, bool save_to_proje name = dlg.get_name(); //BBS: add project embedded preset relate logic save_to_project = dlg.get_save_to_project_selection(m_type); + detach = dlg.get_detach_value(m_type); } //BBS record current preset name