Limit visibility of custom filament profiles based on OrcaFilamentLibrary to currently selected printer only (#8779)

Set compatible_printers when creating custom filament profiles so that this custom profile won't be visible automatically for all printers.
This commit is contained in:
SoftFever 2025-03-09 21:51:19 +08:00 committed by GitHub
parent c150bbf61c
commit 312ddaa8fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 4 deletions

View file

@ -2235,7 +2235,7 @@ std::map<std::string, std::vector<Preset const *>> PresetCollection::get_filamen
}
//BBS: add project embedded preset logic
void PresetCollection::save_current_preset(const std::string &new_name, bool detach, bool save_to_project, Preset* _curr_preset)
void PresetCollection::save_current_preset(const std::string &new_name, bool detach, bool save_to_project, Preset* _curr_preset, const Preset* _current_printer)
{
Preset curr_preset = _curr_preset ? *_curr_preset : m_edited_preset;
//BBS: add lock logic for sync preset in background
@ -2303,6 +2303,14 @@ void PresetCollection::save_current_preset(const std::string &new_name, bool det
} else if (is_base_preset(preset)) {
inherits = old_name;
}
// Orca: check if compatible_printers exists and is not empty, set it to the current printer if it is empty
if (nullptr != _current_printer && preset.is_system && m_type == Preset::TYPE_FILAMENT) {
ConfigOptionStrings* compatible_printers = preset.config.option<ConfigOptionStrings>("compatible_printers");
if (compatible_printers && compatible_printers->values.empty()) {
compatible_printers->values.push_back(_current_printer->name);
}
}
preset.is_default = false;
preset.is_system = false;
preset.is_external = false;