ENH: config: allow invisible preset to be selected

when switch printer, we found some filament preset not visible
and we need to allow it to be selected
jira: STUDIO-9979

Change-Id: I9613747a755f449c2f48563082b6893e426f37ea
(cherry picked from commit bc5514bbabbbaddefb33ade556a0f15c051aed7e)
This commit is contained in:
lane.wei
2025-02-13 22:28:32 +08:00
committed by Noisyfox
parent 0ecb7eb48a
commit b08fe2cf0c
4 changed files with 36 additions and 7 deletions

View File

@@ -628,7 +628,7 @@ public:
int match_quality = -1;
for (; i < n; ++i)
// Since we use the filament selection from Wizard, it's needed to control the preset visibility too
if (m_presets[i].is_compatible && m_presets[i].is_visible) {
if (m_presets[i].is_compatible) {
int this_match_quality = prefered_condition(m_presets[i]);
if (this_match_quality > match_quality) {
if (match_quality == std::numeric_limits<int>::max())
@@ -665,9 +665,11 @@ public:
template<typename PreferedCondition>
void update_compatible(const PresetWithVendorProfile &active_printer, const PresetWithVendorProfile *active_print, PresetSelectCompatibleType select_other_if_incompatible, PreferedCondition prefered_condition)
{
if (this->update_compatible_internal(active_printer, active_print, select_other_if_incompatible) == (size_t)-1)
if (this->update_compatible_internal(active_printer, active_print, select_other_if_incompatible) == (size_t)-1) {
// Find some other compatible preset, or the "-- default --" preset.
this->select_preset(this->first_compatible_idx(prefered_condition));
size_t index = this->first_compatible_idx(prefered_condition);
this->select_preset(index);
}
}
void update_compatible(const PresetWithVendorProfile &active_printer, const PresetWithVendorProfile *active_print, PresetSelectCompatibleType select_other_if_incompatible)
{ this->update_compatible(active_printer, active_print, select_other_if_incompatible, [](const Preset&) -> int { return 0; }); }