config wizard: enable finish button if only custom printer is selected

This commit is contained in:
David Kocik 2020-02-17 15:54:19 +01:00
parent 9b73ecdf02
commit e571181c54
2 changed files with 20 additions and 13 deletions

View File

@ -748,7 +748,8 @@ PageCustom::PageCustom(ConfigWizard *parent)
cb_custom->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent &event) { cb_custom->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent &event) {
tc_profile_name->Enable(custom_wanted()); tc_profile_name->Enable(custom_wanted());
wizard_p()->on_custom_setup(); wizard_p()->on_custom_setup(custom_wanted());
}); });
append(cb_custom); append(cb_custom);
@ -1396,7 +1397,7 @@ void ConfigWizard::priv::load_pages()
if (any_sla_selected) { index->add_page(page_sla_materials); } if (any_sla_selected) { index->add_page(page_sla_materials); }
// there should to be selected at least one printer // there should to be selected at least one printer
btn_finish->Enable(any_fff_selected || any_sla_selected); btn_finish->Enable(any_fff_selected || any_sla_selected || custom_printer_selected);
index->add_page(page_update); index->add_page(page_update);
index->add_page(page_reload_from_disk); index->add_page(page_reload_from_disk);
@ -1599,8 +1600,9 @@ void ConfigWizard::priv::update_materials(Technology technology)
} }
} }
void ConfigWizard::priv::on_custom_setup() void ConfigWizard::priv::on_custom_setup(const bool custom_wanted)
{ {
custom_printer_selected = custom_wanted;
load_pages(); load_pages();
} }
@ -1723,6 +1725,8 @@ bool ConfigWizard::priv::on_bnt_finish()
if (any_sla_selected) if (any_sla_selected)
page_sla_materials->reload_presets(); page_sla_materials->reload_presets();
// theres no need to check that filament is selected if we have only custom printer
if (custom_printer_selected && !any_fff_selected && !any_sla_selected) return true;
// check, that there is selected at least one filament/material // check, that there is selected at least one filament/material
return check_materials_in_config(T_ANY); return check_materials_in_config(T_ANY);
} }
@ -1751,13 +1755,13 @@ bool ConfigWizard::priv::check_materials_in_config(Technology technology, bool s
if (any_fff_selected && technology & T_FFF && !exist_preset(AppConfig::SECTION_FILAMENTS, filaments)) if (any_fff_selected && technology & T_FFF && !exist_preset(AppConfig::SECTION_FILAMENTS, filaments))
{ {
if (show_info_msg) if (show_info_msg)
{ {
wxString message = _(L("You have to select at least one filament for selected printers")) + "\n\n\t" + wxString message = _(L("You have to select at least one filament for selected printers")) + "\n\n\t" +
_(L("Do you want to automatic select default filaments?")); _(L("Do you want to automatic select default filaments?"));
ask_and_selected_default_materials(message, T_FFF); ask_and_selected_default_materials(message, T_FFF);
} }
return false; return false;
} }
if (any_sla_selected && technology & T_SLA && !exist_preset(AppConfig::SECTION_MATERIALS, sla_materials)) if (any_sla_selected && technology & T_SLA && !exist_preset(AppConfig::SECTION_MATERIALS, sla_materials))
@ -1875,6 +1879,7 @@ void ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese
if (bundle.second.is_prusa_bundle) { continue; } if (bundle.second.is_prusa_bundle) { continue; }
const auto config = enabled_vendors.find(bundle.first); const auto config = enabled_vendors.find(bundle.first);
if (config == enabled_vendors.end()) { continue; }
for (const auto &model : bundle.second.vendor_profile->models) { for (const auto &model : bundle.second.vendor_profile->models) {
const auto model_it = config->second.find(model.id); const auto model_it = config->second.find(model.id);
if (model_it != config->second.end() && model_it->second.size() > 0) { if (model_it != config->second.end() && model_it->second.size() > 0) {
@ -1925,7 +1930,6 @@ bool ConfigWizard::priv::check_fff_selected()
for (const auto& printer: pages_3rdparty) for (const auto& printer: pages_3rdparty)
if (printer.second.first) // FFF page if (printer.second.first) // FFF page
ret |= printer.second.first->any_selected(); ret |= printer.second.first->any_selected();
return ret; return ret;
} }
@ -1997,6 +2001,8 @@ ConfigWizard::ConfigWizard(wxWindow *parent)
// Pages for 3rd party vendors // Pages for 3rd party vendors
p->create_3rdparty_pages(); // Needs to be done _before_ creating PageVendors p->create_3rdparty_pages(); // Needs to be done _before_ creating PageVendors
p->add_page(p->page_vendors = new PageVendors(this)); p->add_page(p->page_vendors = new PageVendors(this));
p->add_page(p->page_custom = new PageCustom(this));
p->custom_printer_selected = p->page_custom->custom_wanted();
p->any_sla_selected = p->check_sla_selected(); p->any_sla_selected = p->check_sla_selected();
p->any_fff_selected = p->check_fff_selected(); p->any_fff_selected = p->check_fff_selected();
@ -2008,7 +2014,7 @@ ConfigWizard::ConfigWizard(wxWindow *parent)
p->add_page(p->page_sla_materials = new PageMaterials(this, &p->sla_materials, p->add_page(p->page_sla_materials = new PageMaterials(this, &p->sla_materials,
_(L("SLA Material Profiles Selection")) + " ", _(L("SLA Materials")), _(L("Layer height:")) )); _(L("SLA Material Profiles Selection")) + " ", _(L("SLA Materials")), _(L("Layer height:")) ));
p->add_page(p->page_custom = new PageCustom(this));
p->add_page(p->page_update = new PageUpdate(this)); p->add_page(p->page_update = new PageUpdate(this));
p->add_page(p->page_reload_from_disk = new PageReloadFromDisk(this)); p->add_page(p->page_reload_from_disk = new PageReloadFromDisk(this));
p->add_page(p->page_mode = new PageMode(this)); p->add_page(p->page_mode = new PageMode(this));

View File

@ -447,6 +447,7 @@ struct ConfigWizard::priv
std::unique_ptr<DynamicPrintConfig> custom_config; // Backing for custom printer definition std::unique_ptr<DynamicPrintConfig> custom_config; // Backing for custom printer definition
bool any_fff_selected; // Used to decide whether to display Filaments page bool any_fff_selected; // Used to decide whether to display Filaments page
bool any_sla_selected; // Used to decide whether to display SLA Materials page bool any_sla_selected; // Used to decide whether to display SLA Materials page
bool custom_printer_selected;
wxScrolledWindow *hscroll = nullptr; wxScrolledWindow *hscroll = nullptr;
wxBoxSizer *hscroll_sizer = nullptr; wxBoxSizer *hscroll_sizer = nullptr;
@ -497,7 +498,7 @@ struct ConfigWizard::priv
void set_run_reason(RunReason run_reason); void set_run_reason(RunReason run_reason);
void update_materials(Technology technology); void update_materials(Technology technology);
void on_custom_setup(); void on_custom_setup(const bool custom_wanted);
void on_printer_pick(PagePrinters *page, const PrinterPickerEvent &evt); void on_printer_pick(PagePrinters *page, const PrinterPickerEvent &evt);
void select_default_materials_for_printer_model(const std::vector<VendorProfile::PrinterModel> &models, void select_default_materials_for_printer_model(const std::vector<VendorProfile::PrinterModel> &models,
Technology technology, Technology technology,