FIX: [5846] Custom Filament Page show System Filament

Simultaneously solve: When downloading Preset from the cloud, the filament_id of the preset in m_preset is null.

Jira: 5846

Change-Id: I6ba1b46fe92e345614b6a4af3fffa87d81fa2456
This commit is contained in:
maosheng.wei 2024-01-08 15:11:34 +08:00 committed by Lane.Wei
parent 4b91e78fb4
commit 9d0d0ccc4a
2 changed files with 12 additions and 5 deletions

View File

@ -1692,6 +1692,9 @@ bool PresetCollection::load_user_preset(std::string name, std::map<std::string,
const Preset& default_preset = this->default_preset_for(cloud_config);
if (inherit_preset) {
new_config = inherit_preset->config;
if (cloud_filament_id == "null") {
cloud_filament_id = inherit_preset->filament_id;
}
}
else {
// We support custom root preset now

View File

@ -53,15 +53,19 @@ static wxString update_custom_filaments()
need_delete_some_filament = true;
}
bool filament_with_base_id = false;
bool vendor_is_generic = false;
bool not_need_show = false;
std::string filament_name;
for (const Preset *preset : filament_id_to_presets.second) {
if (preset->is_system || preset->inherits() != "") continue;
if (preset->is_system) {
not_need_show = true;
break;
}
if (preset->inherits() != "") continue;
if (!preset->base_id.empty()) filament_with_base_id = true;
if (!vendor_is_generic) {
if (!not_need_show) {
auto filament_vendor = dynamic_cast<ConfigOptionStrings *>(const_cast<Preset *>(preset)->config.option("filament_vendor", false));
if (filament_vendor && filament_vendor->values.size() && filament_vendor->values[0] == "Generic") vendor_is_generic = true;
if (filament_vendor && filament_vendor->values.size() && filament_vendor->values[0] == "Generic") not_need_show = true;
}
if (filament_name.empty()) {
@ -71,7 +75,7 @@ static wxString update_custom_filaments()
filament_name = preset_name;
}
}
if (vendor_is_generic) continue;
if (not_need_show) continue;
if (!filament_name.empty()) {
if (filament_with_base_id) {
need_sort.push_back(std::make_pair("[Action Required] " + filament_name, filament_id));