mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-11 11:07:40 +00:00
Allow saving preset without parent while it doesnt have parent profile (Detach from parent option for parentless profiles) (#15558)
* Update SavePresetDialog.cpp * correct variable name
This commit is contained in:
@@ -114,7 +114,7 @@ SavePresetDialog::Item::Item(Preset::Type type, const std::string &suffix, wxBox
|
|||||||
if (parent->m_mode == comDevelop) {
|
if (parent->m_mode == comDevelop) {
|
||||||
// A new user copy of a system preset inherits from the selected system preset.
|
// A new user copy of a system preset inherits from the selected system preset.
|
||||||
const std::string parent_name = sel_preset.is_system ? sel_preset.name : sel_preset.inherits();
|
const std::string parent_name = sel_preset.is_system ? sel_preset.name : sel_preset.inherits();
|
||||||
const bool can_detach = !parent_name.empty();
|
const bool has_parent = !parent_name.empty();
|
||||||
|
|
||||||
wxBoxSizer *detach_sizer = new wxBoxSizer(wxHORIZONTAL);
|
wxBoxSizer *detach_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
|
||||||
@@ -123,8 +123,9 @@ SavePresetDialog::Item::Item(Preset::Type type, const std::string &suffix, wxBox
|
|||||||
auto detach_checkbox = new ::CheckBox(parent);
|
auto detach_checkbox = new ::CheckBox(parent);
|
||||||
detach_checkbox->SetToolTip(detach_tooltip);
|
detach_checkbox->SetToolTip(detach_tooltip);
|
||||||
|
|
||||||
auto detach_label = new wxStaticText(parent, wxID_ANY, _L("Detach from parent"));
|
auto detach_label = new wxStaticText(parent, wxID_ANY, has_parent ? _L("Detach from parent") : _L("Save without parent"));
|
||||||
detach_label->SetFont(::Label::Body_14);
|
detach_label->SetFont(::Label::Body_14);
|
||||||
|
detach_label->SetForegroundColour(wxColour("#363636"));
|
||||||
detach_label->SetToolTip(detach_tooltip);
|
detach_label->SetToolTip(detach_tooltip);
|
||||||
|
|
||||||
detach_sizer->Add(detach_checkbox, 0, wxALIGN_LEFT | wxLEFT, BORDER_W);
|
detach_sizer->Add(detach_checkbox, 0, wxALIGN_LEFT | wxLEFT, BORDER_W);
|
||||||
@@ -132,20 +133,15 @@ SavePresetDialog::Item::Item(Preset::Type type, const std::string &suffix, wxBox
|
|||||||
sizer->Add(detach_sizer, 0, wxEXPAND | wxTOP, BORDER_W);
|
sizer->Add(detach_sizer, 0, wxEXPAND | wxTOP, BORDER_W);
|
||||||
sizer->AddSpacer(FromDIP(5));
|
sizer->AddSpacer(FromDIP(5));
|
||||||
|
|
||||||
const wxString parent_text = can_detach ? from_u8(parent_name) : _L("Unique preset");
|
const wxString parent_text = has_parent ? from_u8(parent_name) : _L("Unique preset");
|
||||||
auto parent_label = new wxStaticText(parent, wxID_ANY, parent_text);
|
auto parent_label = new wxStaticText(parent, wxID_ANY, parent_text);
|
||||||
parent_label->SetFont(::Label::Body_12);
|
parent_label->SetFont(::Label::Body_12);
|
||||||
parent_label->SetForegroundColour(wxColour("#6B6B6B"));
|
parent_label->SetForegroundColour(wxColour("#6B6B6B"));
|
||||||
parent_label->SetToolTip(can_detach ? _L("Parent preset") : _L("This preset does not inherit from another preset."));
|
parent_label->SetToolTip(has_parent ? _L("Parent preset") : _L("This preset does not inherit from another preset."));
|
||||||
sizer->Add(parent_label, 0, wxEXPAND | wxLEFT, BORDER_W + FromDIP(24));
|
sizer->Add(parent_label, 0, wxEXPAND | wxLEFT, BORDER_W + FromDIP(24));
|
||||||
|
|
||||||
sizer->AddSpacer(FromDIP(5));
|
sizer->AddSpacer(FromDIP(5));
|
||||||
|
|
||||||
if (!can_detach) {
|
|
||||||
detach_checkbox->Disable();
|
|
||||||
detach_label->SetForegroundColour(wxColour("#6B6B6B"));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Set initial state (unchecked by default)
|
// Set initial state (unchecked by default)
|
||||||
detach_checkbox->SetValue(m_detach);
|
detach_checkbox->SetValue(m_detach);
|
||||||
// Bind the checkbox event to update the detach state for this item
|
// Bind the checkbox event to update the detach state for this item
|
||||||
@@ -154,8 +150,6 @@ SavePresetDialog::Item::Item(Preset::Type type, const std::string &suffix, wxBox
|
|||||||
event.Skip(); // Let CheckBox update its bitmap for the new state.
|
event.Skip(); // Let CheckBox update its bitmap for the new state.
|
||||||
});
|
});
|
||||||
|
|
||||||
detach_label->SetForegroundColour(wxColour("#363636"));
|
|
||||||
|
|
||||||
auto on_toggle = [detach_checkbox]() {
|
auto on_toggle = [detach_checkbox]() {
|
||||||
detach_checkbox->SetValue(!detach_checkbox->GetValue());
|
detach_checkbox->SetValue(!detach_checkbox->GetValue());
|
||||||
wxCommandEvent ev(wxEVT_TOGGLEBUTTON, detach_checkbox->GetId());
|
wxCommandEvent ev(wxEVT_TOGGLEBUTTON, detach_checkbox->GetId());
|
||||||
@@ -165,7 +159,6 @@ SavePresetDialog::Item::Item(Preset::Type type, const std::string &suffix, wxBox
|
|||||||
detach_label->Bind(wxEVT_LEFT_DOWN, [on_toggle](wxMouseEvent& e) {if(!e.LeftDClick()) on_toggle();});
|
detach_label->Bind(wxEVT_LEFT_DOWN, [on_toggle](wxMouseEvent& e) {if(!e.LeftDClick()) on_toggle();});
|
||||||
detach_label->Bind(wxEVT_LEFT_DCLICK, [on_toggle](wxMouseEvent& e) {on_toggle();});
|
detach_label->Bind(wxEVT_LEFT_DCLICK, [on_toggle](wxMouseEvent& e) {on_toggle();});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
m_radio_group->Bind(wxEVT_COMMAND_RADIOBOX_SELECTED, [this](wxCommandEvent &e) {
|
m_radio_group->Bind(wxEVT_COMMAND_RADIOBOX_SELECTED, [this](wxCommandEvent &e) {
|
||||||
m_save_to_project = m_radio_group->GetSelection() == 1;
|
m_save_to_project = m_radio_group->GetSelection() == 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user