QoL: remember each printer's filament/bed/process settings (#1592)

* init work
TODO:
1. support multi filament
2. support project

* Properly handle filament number change when switching printers
This commit is contained in:
SoftFever 2023-07-25 21:54:34 +08:00 committed by GitHub
parent 6aa3e400d1
commit 7f6f01c4c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 159 additions and 27 deletions

View file

@ -505,7 +505,11 @@ std::string AppConfig::load()
m_storage[it.key()][iter.key()] = iter.value().get<std::string>();
}
}
} else {
} else if (it.key() == "orca_presets") {
for (auto& j_model : it.value()) {
m_printer_settings[j_model["machine"].get<std::string>()] = j_model;
}
}else {
if (it.value().is_object()) {
for (auto iter = it.value().begin(); iter != it.value().end(); iter++) {
if (iter.value().is_boolean()) {
@ -630,7 +634,8 @@ void AppConfig::save()
j[category.first][kvp.first] = kvp.second;
}
}
j["presets"]["filaments"] = j_filament_array;
if(j_filament_array.size() > 0)
j["presets"]["filaments"] = j_filament_array;
continue;
}
for (const auto& kvp : category.second) {
@ -665,6 +670,10 @@ void AppConfig::save()
}
}
// write machine settings
for (const auto& preset : m_printer_settings) {
j["orca_presets"].push_back(preset.second);
}
boost::nowide::ofstream c;
c.open(path_pid, std::ios::out | std::ios::trunc);
c << std::setw(4) << j << std::endl;