diff options
author | Vojtech Kral <vojtech@kral.hk> | 2018-04-11 14:12:08 +0300 |
---|---|---|
committer | Vojtech Kral <vojtech@kral.hk> | 2018-04-11 19:05:12 +0300 |
commit | 31ea03feb0af7376a35aa3b3428684b1e59d4a15 (patch) | |
tree | 0afae03857ba0b58f46c504c4e9b2fb8ce0bb484 /xs/src/slic3r/GUI/PresetBundle.cpp | |
parent | aaa8f133c00baba3ccff4e2115436254483a1fe0 (diff) |
ConfigWizard: Make bundle installation more intelligent, fixes
Diffstat (limited to 'xs/src/slic3r/GUI/PresetBundle.cpp')
-rw-r--r-- | xs/src/slic3r/GUI/PresetBundle.cpp | 43 |
1 files changed, 2 insertions, 41 deletions
diff --git a/xs/src/slic3r/GUI/PresetBundle.cpp b/xs/src/slic3r/GUI/PresetBundle.cpp index bd9e35ca8..ad27bf8c6 100644 --- a/xs/src/slic3r/GUI/PresetBundle.cpp +++ b/xs/src/slic3r/GUI/PresetBundle.cpp @@ -105,7 +105,7 @@ void PresetBundle::setup_directories() std::initializer_list<boost::filesystem::path> paths = { data_dir, data_dir / "vendor", - data_dir / "cache", // TODO: rename as vendor-cache? (Check usage elsewhere!) + data_dir / "cache", #ifdef SLIC3R_PROFILE_USE_PRESETS_SUBDIR // Store the print/filament/printer presets into a "presets" directory. data_dir / "presets", @@ -672,42 +672,6 @@ static void flatten_configbundle_hierarchy(boost::property_tree::ptree &tree) flatten_configbundle_hierarchy(tree, "printer"); } -static void load_vendor_profile(const boost::property_tree::ptree &tree, VendorProfile &vendor_profile) -{ - const std::string printer_model_key = "printer_model:"; - for (auto §ion : tree) { - if (section.first == "vendor") { - // Load the names of the active presets. - for (auto &kvp : section.second) { - if (kvp.first == "name") - vendor_profile.name = kvp.second.data(); - else if (kvp.first == "id") - vendor_profile.id = kvp.second.data(); - else if (kvp.first == "config_version") - vendor_profile.config_version = kvp.second.data(); - else if (kvp.first == "config_update_url") - vendor_profile.config_update_url = kvp.second.data(); - } - } else if (boost::starts_with(section.first, printer_model_key)) { - VendorProfile::PrinterModel model; - model.id = section.first.substr(printer_model_key.size()); - model.name = section.second.get<std::string>("name", model.id); - section.second.get<std::string>("variants", ""); - std::vector<std::string> variants; - if (Slic3r::unescape_strings_cstyle(section.second.get<std::string>("variants", ""), variants)) { - for (const std::string &variant_name : variants) { - if (model.variant(variant_name) == nullptr) - model.variants.emplace_back(VendorProfile::PrinterVariant(variant_name)); - } - } else { - // Log error? - } - if (! model.id.empty() && ! model.variants.empty()) - vendor_profile.models.push_back(std::move(model)); - } - } -} - // Load a config bundle file, into presets and store the loaded presets into separate files // of the local configuration directory. void PresetBundle::install_vendor_configbundle(const std::string &src_path0) @@ -738,10 +702,7 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla const VendorProfile *vendor_profile = nullptr; if (flags & (LOAD_CFGBNDLE_SYSTEM | LOAD_CFGBUNDLE_VENDOR_ONLY)) { boost::filesystem::path fspath(path); - VendorProfile vp(fspath.stem().string()); - load_vendor_profile(tree, vp); - if (vp.name.empty()) - throw std::runtime_error(std::string("Vendor Config Bundle is not valid: Missing vendor name key.")); + auto vp = VendorProfile::from_ini(tree, fspath.stem().string()); if (vp.num_variants() == 0) return 0; vendor_profile = &(*this->vendors.insert(vp).first); |