mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-31 13:42:01 +08:00
ConfigWizard: Fixed a check of name for new custom printer
Note: This feature was broken by improvements from 61834d3f and de32cd70. (SPE-2469)
This commit is contained in:
parent
77312ec513
commit
444e5bdeec
@ -1503,7 +1503,7 @@ PageCustom::PageCustom(ConfigWizard *parent)
|
||||
auto *label = new wxStaticText(this, wxID_ANY, _L("Custom profile name:"));
|
||||
|
||||
wxBoxSizer* profile_name_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
profile_name_editor = new SavePresetDialog::Item{ this, profile_name_sizer, default_profile_name, &wxGetApp().preset_bundle->printers};
|
||||
profile_name_editor = new SavePresetDialog::Item{ this, profile_name_sizer, default_profile_name, wxGetApp().preset_bundle};
|
||||
profile_name_editor->Enable(false);
|
||||
|
||||
cb_custom->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent &) {
|
||||
|
@ -55,11 +55,30 @@ std::string SavePresetDialog::Item::get_init_preset_name(const std::string &suff
|
||||
void SavePresetDialog::Item::init_casei_preset_names()
|
||||
{
|
||||
m_casei_preset_names.clear();
|
||||
m_casei_preset_names.reserve(m_presets->size());
|
||||
|
||||
for (const Preset& preset : *m_presets)
|
||||
if (!preset.is_default)
|
||||
m_casei_preset_names.emplace_back(PresetName({ boost::to_lower_copy<std::string>(preset.name), preset.name }));
|
||||
auto add_names_from_collection = [this](const PresetCollection& presets) {
|
||||
for (const Preset& preset : presets)
|
||||
if (!preset.is_default)
|
||||
m_casei_preset_names.emplace_back(PresetName({ boost::to_lower_copy<std::string>(preset.name), preset.name }));
|
||||
};
|
||||
|
||||
if (m_presets) {
|
||||
// This item is a part of SavePresetDialog and will check names inside selected PresetCollection
|
||||
m_casei_preset_names.reserve(m_presets->size());
|
||||
add_names_from_collection(*m_presets);
|
||||
}
|
||||
else // This item is a part of ConfigWizard and will check names inside all PresetCollections in respect to the m_printer_technology
|
||||
if (m_preset_bundle) {
|
||||
auto types_list = PresetBundle::types_list(m_printer_technology);
|
||||
|
||||
size_t presets_cnt = 0;
|
||||
for (const Preset::Type& type : types_list)
|
||||
presets_cnt += m_preset_bundle->get_presets(type).size();
|
||||
m_casei_preset_names.reserve(presets_cnt);
|
||||
|
||||
for (const Preset::Type& type : types_list)
|
||||
add_names_from_collection(m_preset_bundle->get_presets(type));
|
||||
}
|
||||
|
||||
std::sort(m_casei_preset_names.begin(), m_casei_preset_names.end());
|
||||
}
|
||||
@ -139,9 +158,9 @@ SavePresetDialog::Item::Item(Preset::Type type, const std::string& suffix, wxBox
|
||||
update();
|
||||
}
|
||||
|
||||
SavePresetDialog::Item::Item(wxWindow* parent, wxBoxSizer* sizer, const std::string& def_name, PresetCollection* presets, PrinterTechnology pt /*= ptFFF*/):
|
||||
SavePresetDialog::Item::Item(wxWindow* parent, wxBoxSizer* sizer, const std::string& def_name, PresetBundle* preset_bundle, PrinterTechnology pt /*= ptFFF*/):
|
||||
m_preset_name(def_name),
|
||||
m_presets(presets),
|
||||
m_preset_bundle(preset_bundle),
|
||||
m_printer_technology(pt),
|
||||
m_parent(parent),
|
||||
m_valid_bmp(new wxStaticBitmap(m_parent, wxID_ANY, *get_bmp_bundle("tick_mark"))),
|
||||
@ -196,10 +215,12 @@ const Preset* SavePresetDialog::Item::get_existing_preset() const
|
||||
if (m_presets)
|
||||
return m_presets->find_preset(existed_preset_name, false);
|
||||
|
||||
for (const Preset::Type& type : PresetBundle::types_list(m_printer_technology)) {
|
||||
const PresetCollection& presets = wxGetApp().preset_bundle->get_presets(type);
|
||||
if (const Preset* preset = presets.find_preset(existed_preset_name, false))
|
||||
return preset;
|
||||
if (m_preset_bundle) {
|
||||
for (const Preset::Type& type : PresetBundle::types_list(m_printer_technology)) {
|
||||
const PresetCollection& presets = m_preset_bundle->get_presets(type);
|
||||
if (const Preset* preset = presets.find_preset(existed_preset_name, false))
|
||||
return preset;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
@ -40,8 +40,11 @@ public:
|
||||
Warning
|
||||
};
|
||||
|
||||
// Item as an item inside of the SavePresetDialog
|
||||
Item(Preset::Type type, const std::string& suffix, wxBoxSizer* sizer, SavePresetDialog* parent, bool is_for_multiple_save);
|
||||
Item(wxWindow* parent, wxBoxSizer* sizer, const std::string& def_name, PresetCollection* presets, PrinterTechnology pt = ptFFF);
|
||||
|
||||
// Item as a separate control(f.e. as a part of ConfigWizard to check name of the new custom priter)
|
||||
Item(wxWindow* parent, wxBoxSizer* sizer, const std::string& def_name, PresetBundle* preset_bundle, PrinterTechnology pt = ptFFF);
|
||||
|
||||
void update_valid_bmp();
|
||||
void accept();
|
||||
@ -72,6 +75,7 @@ public:
|
||||
wxStaticText* m_valid_label {nullptr};
|
||||
|
||||
PresetCollection* m_presets {nullptr};
|
||||
PresetBundle* m_preset_bundle {nullptr};
|
||||
|
||||
std::vector<PresetName> m_casei_preset_names;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user