mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-12 19:47:43 +00:00
QOL Add parent preset information next to detach preset checkbox and match checkbox style on Save Preset dialog (#15076)
init
This commit is contained in:
@@ -111,13 +111,46 @@ SavePresetDialog::Item::Item(Preset::Type type, const std::string &suffix, wxBox
|
|||||||
|
|
||||||
sizer->Add(m_radio_group, 0, wxEXPAND | wxTOP | wxLEFT, BORDER_W);
|
sizer->Add(m_radio_group, 0, wxEXPAND | wxTOP | wxLEFT, BORDER_W);
|
||||||
|
|
||||||
if (parent->m_mode == comDevelop) {
|
std::string inherits_str = sel_preset.inherits();
|
||||||
m_detach_checkbox = new wxCheckBox(parent, wxID_ANY, _L("Detach from parent"));
|
if (parent->m_mode == comDevelop && !inherits_str.empty()) {
|
||||||
sizer->Add(m_detach_checkbox, 0, wxALIGN_LEFT | wxALL, BORDER_W);
|
wxBoxSizer *detach_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
|
||||||
|
auto detach_tooltip = _L("Copies all inherited values from the parent preset into this preset and removes the connection with the parent preset.");
|
||||||
|
|
||||||
|
auto detach_checkbox = new ::CheckBox(parent);
|
||||||
|
detach_checkbox->SetToolTip(detach_tooltip);
|
||||||
|
|
||||||
|
auto detach_label = new wxStaticText(parent, wxID_ANY, _L("Detach from parent"));
|
||||||
|
detach_label->SetFont(::Label::Body_14);
|
||||||
|
detach_label->SetForegroundColour(wxColour("#363636"));
|
||||||
|
detach_label->SetToolTip(detach_tooltip);
|
||||||
|
|
||||||
|
detach_sizer->Add(detach_checkbox, 0, wxALIGN_LEFT | wxLEFT, BORDER_W);
|
||||||
|
detach_sizer->Add(detach_label , 0, wxALIGN_CENTRE_VERTICAL | wxLEFT, FromDIP(5));
|
||||||
|
sizer->Add(detach_sizer, 0, wxEXPAND | wxTOP, BORDER_W);
|
||||||
|
sizer->AddSpacer(FromDIP(5));
|
||||||
|
|
||||||
|
auto parent_label = new wxStaticText(parent, wxID_ANY, inherits_str);
|
||||||
|
parent_label->SetFont(::Label::Body_12);
|
||||||
|
parent_label->SetForegroundColour(wxColour("#6B6B6B"));
|
||||||
|
parent_label->SetToolTip(_L("Parent preset"));
|
||||||
|
sizer->Add(parent_label, 0, wxEXPAND | wxLEFT, BORDER_W + FromDIP(24));
|
||||||
|
|
||||||
|
sizer->AddSpacer(FromDIP(5));
|
||||||
|
|
||||||
// Set initial state (unchecked by default)
|
// Set initial state (unchecked by default)
|
||||||
m_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
|
||||||
m_detach_checkbox->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent&) { m_detach = m_detach_checkbox->GetValue(); });
|
detach_checkbox->Bind(wxEVT_TOGGLEBUTTON, [this, detach_checkbox](wxCommandEvent&) { m_detach = detach_checkbox->GetValue(); });
|
||||||
|
|
||||||
|
auto on_toggle = [this, detach_checkbox]() {
|
||||||
|
detach_checkbox->SetValue(!detach_checkbox->GetValue());
|
||||||
|
wxCommandEvent ev(wxEVT_TOGGLEBUTTON, detach_checkbox->GetId());
|
||||||
|
ev.SetEventObject(detach_checkbox);
|
||||||
|
detach_checkbox->GetEventHandler()->ProcessEvent(ev);
|
||||||
|
};
|
||||||
|
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();});
|
||||||
}
|
}
|
||||||
|
|
||||||
m_radio_group->Bind(wxEVT_COMMAND_RADIOBOX_SELECTED, [this](wxCommandEvent &e) {
|
m_radio_group->Bind(wxEVT_COMMAND_RADIOBOX_SELECTED, [this](wxCommandEvent &e) {
|
||||||
|
|||||||
@@ -75,7 +75,6 @@ class SavePresetDialog : public DPIDialog
|
|||||||
bool m_save_to_project {false};
|
bool m_save_to_project {false};
|
||||||
RadioGroup* m_radio_group; // ORCA
|
RadioGroup* m_radio_group; // ORCA
|
||||||
bool m_detach{false};
|
bool m_detach{false};
|
||||||
wxCheckBox* m_detach_checkbox{nullptr};
|
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user