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

@@ -1255,7 +1255,7 @@ void PresetCollection::load_presets(
m_presets.insert(m_presets.end(), std::make_move_iterator(presets_loaded.begin()), std::make_move_iterator(presets_loaded.end()));
std::sort(m_presets.begin() + m_num_default_presets, m_presets.end());
//BBS: add config related logs
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(": loaded %1% presets from %2%, type %3%")%presets_loaded.size() %dir %Preset::get_type_string(m_type);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": loaded %1% presets from %2%, type %3%")%presets_loaded.size() %dir %Preset::get_type_string(m_type);
//this->select_preset(first_visible_idx());
if (! errors_cummulative.empty())
throw Slic3r::RuntimeError(errors_cummulative);
@@ -2858,6 +2858,12 @@ Preset& PresetCollection::select_preset(size_t idx)
bool default_visible = ! m_default_suppressed || m_idx_selected < m_num_default_presets;
for (size_t i = 0; i < m_num_default_presets; ++i)
m_presets[i].is_visible = default_visible;
//set this preset to true
if (!m_presets[idx].is_visible) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": %1% set %2%, idx %3% to visible") % Preset::get_type_string(m_type) % m_presets[idx].name % idx;
m_presets[idx].is_visible = true;
}
//BBS: add config related logs
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": %1% select success, m_idx_selected %2%, name %3%, is_system %4%, is_default %5%")%Preset::get_type_string(m_type) % m_idx_selected % m_edited_preset.name % m_edited_preset.is_system % m_edited_preset.is_default;
return m_presets[idx];
@@ -2893,7 +2899,10 @@ bool PresetCollection::select_preset_by_name(const std::string &name_w_suffix, b
}
//BBS: add config related logs
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": %1%, select %2%, failed")%Preset::get_type_string(m_type) %name_w_suffix;
if (m_idx_selected == idx)
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": %1%, already selected before") % Preset::get_type_string(m_type);
else
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": %1%, select %2%, failed")%Preset::get_type_string(m_type) %name_w_suffix;
return false;
}