mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-16 18:12:10 +00:00
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 c1326c6dec.
* re-commiting the changes
* fixed conflicts with upstream
---------
Co-authored-by: SoftFever <softfeverever@gmail.com>
This commit is contained in:
@@ -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<Preset::Type>{type}, suffix);
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
}
|
||||
|
||||
SavePresetDialog::SavePresetDialog(wxWindow *parent, std::vector<Preset::Type> types, std::string suffix)
|
||||
: DPIDialog(parent, wxID_ANY, _L("Save preset"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
|
||||
SavePresetDialog::SavePresetDialog(wxWindow* parent, std::vector<Preset::Type> 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)
|
||||
|
||||
@@ -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<Preset::Type> types, std::string suffix = "");
|
||||
SavePresetDialog(wxWindow* parent, Preset::Type type, int mode = 0, std::string suffix = "");
|
||||
SavePresetDialog(wxWindow* parent, std::vector<Preset::Type> 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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user