mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-19 04:37:52 -06:00
Override full config defs in non-preset categories
This commit is contained in:
parent
ecd20184f9
commit
4abca6a091
2 changed files with 45 additions and 20 deletions
|
@ -291,11 +291,6 @@ void EditGCodeDialog::selection_changed(wxDataViewEvent& evt)
|
|||
if (!opt_key.empty()) {
|
||||
const ConfigOptionDef* def { nullptr };
|
||||
|
||||
const auto& full_config = wxGetApp().preset_bundle->full_config();
|
||||
if (const ConfigDef* config_def = full_config.def(); config_def && config_def->has(opt_key)) {
|
||||
def = config_def->get(opt_key);
|
||||
}
|
||||
else {
|
||||
for (const ConfigDef* config: std::initializer_list<const ConfigDef*> {
|
||||
&custom_gcode_specific_config_def,
|
||||
&cgp_ro_slicing_states_config_def,
|
||||
|
@ -313,6 +308,14 @@ void EditGCodeDialog::selection_changed(wxDataViewEvent& evt)
|
|||
break;
|
||||
}
|
||||
}
|
||||
// Orca: move below checking for def in custom defined gcode placeholders
|
||||
// This allows custom placeholders to override the default ones for this dialog
|
||||
// Override custom def if selection is within the preset category
|
||||
if (!def || unbold(m_params_list->GetSelectedTopLevelCategory()) == "Presets") {
|
||||
const auto& full_config = wxGetApp().preset_bundle->full_config();
|
||||
if (const ConfigDef* config_def = full_config.def(); config_def && config_def->has(opt_key)) {
|
||||
def = config_def->get(opt_key);
|
||||
}
|
||||
}
|
||||
|
||||
if (def) {
|
||||
|
@ -590,6 +593,17 @@ std::string ParamsModel::GetParamKey(wxDataViewItem item)
|
|||
return std::string();
|
||||
}
|
||||
|
||||
std::string ParamsModel::GetTopLevelCategory(wxDataViewItem item)
|
||||
{
|
||||
if (item.IsOk()) {
|
||||
ParamsNode* node = static_cast<ParamsNode*>(item.GetID());
|
||||
while (!node->IsGroupNode())
|
||||
node = node->GetParent();
|
||||
return node->text.ToStdString();
|
||||
}
|
||||
return std::string();
|
||||
}
|
||||
|
||||
wxDataViewItem ParamsModel::Delete(const wxDataViewItem& item)
|
||||
{
|
||||
auto ret_item = wxDataViewItem(nullptr);
|
||||
|
@ -790,6 +804,11 @@ std::string ParamsViewCtrl::GetSelectedParamKey()
|
|||
return model->GetParamKey(this->GetSelection());
|
||||
}
|
||||
|
||||
std::string ParamsViewCtrl::GetSelectedTopLevelCategory()
|
||||
{
|
||||
return model->GetTopLevelCategory(this->GetSelection());
|
||||
}
|
||||
|
||||
void ParamsViewCtrl::CheckAndDeleteIfEmpty(wxDataViewItem item)
|
||||
{
|
||||
wxDataViewItemArray children;
|
||||
|
|
|
@ -174,6 +174,7 @@ public:
|
|||
|
||||
wxString GetParamName(wxDataViewItem item);
|
||||
std::string GetParamKey(wxDataViewItem item);
|
||||
std::string GetTopLevelCategory(wxDataViewItem item);
|
||||
|
||||
void Clear();
|
||||
|
||||
|
@ -225,6 +226,7 @@ public:
|
|||
wxString GetValue(wxDataViewItem item);
|
||||
wxString GetSelectedValue();
|
||||
std::string GetSelectedParamKey();
|
||||
std::string GetSelectedTopLevelCategory();
|
||||
|
||||
void CheckAndDeleteIfEmpty(wxDataViewItem item);
|
||||
|
||||
|
@ -234,6 +236,10 @@ public:
|
|||
void set_em_unit(int em) { m_em_unit = em; }
|
||||
};
|
||||
|
||||
static std::string unbold(const std::string& text) {
|
||||
return text.substr(text.find("<b>")+3, text.find("</b>")-3);
|
||||
}
|
||||
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue