ENH: config: add default_nozzle_volume_type in printer

1. also remove original nozzle_volume_type from printer
and move into project config
2. support save nozzle_volume_type into appconfig
and load from it at beginning or printer switch

jira: no-jira

Change-Id: I01fc82d142fc633fc59a238796a71b9f8d180efb
(cherry picked from commit fe8b904e7551cde83b1ead75922e9b60278b50ad)
This commit is contained in:
lane.wei
2024-08-06 16:31:32 +08:00
committed by Noisyfox
parent b2f2e41b80
commit 9142654795
7 changed files with 98 additions and 9 deletions

View File

@@ -1360,6 +1360,32 @@ std::vector<std::string> AppConfig::get_custom_color_from_config()
return colors;
}
void AppConfig::save_nozzle_volume_types_to_config(const std::string& printer_name, const std::string& nozzle_volume_types)
{
if (!has_section("nozzle_volume_types")) {
std::map<std::string, std::string> data;
data[printer_name] = nozzle_volume_types;
set_section("nozzle_volume_types", data);
} else {
auto data = get_section("nozzle_volume_types");
auto data_modify = const_cast<std::map<std::string, std::string>&>(data);
data_modify[printer_name] = nozzle_volume_types;
set_section("nozzle_volume_types", data_modify);
}
}
std::string AppConfig::get_nozzle_volume_types_from_config(const std::string& printer_name)
{
std::string nozzle_volume_types;
if (has_section("nozzle_volume_types")) {
auto data = get_section("nozzle_volume_types");
if (data.find(printer_name) != data.end())
nozzle_volume_types = data[printer_name];
}
return nozzle_volume_types;
}
void AppConfig::reset_selections()
{
auto it = m_storage.find("presets");