mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 01:07:57 -06:00
Save binded local machines
This commit is contained in:
parent
82ce8c94b4
commit
2e64cc2f7e
5 changed files with 129 additions and 12 deletions
|
@ -607,6 +607,19 @@ std::string AppConfig::load()
|
|||
for (auto& j_model : it.value()) {
|
||||
m_printer_settings[j_model["machine"].get<std::string>()] = j_model;
|
||||
}
|
||||
} else if (it.key() == "local_machines") {
|
||||
for (auto m = it.value().begin(); m != it.value().end(); ++m) {
|
||||
const auto& p = m.value();
|
||||
BBLocalMachine local_machine;
|
||||
local_machine.dev_id = m.key();
|
||||
if (p.contains("dev_name"))
|
||||
local_machine.dev_name = p["dev_name"].get<std::string>();
|
||||
if (p.contains("dev_ip"))
|
||||
local_machine.dev_ip = p["dev_ip"].get<std::string>();
|
||||
if (p.contains("printer_type"))
|
||||
local_machine.printer_type = p["printer_type"].get<std::string>();
|
||||
m_local_machines[local_machine.dev_id] = local_machine;
|
||||
}
|
||||
} else {
|
||||
if (it.value().is_object()) {
|
||||
for (auto iter = it.value().begin(); iter != it.value().end(); iter++) {
|
||||
|
@ -783,6 +796,14 @@ void AppConfig::save()
|
|||
for (const auto& preset : m_printer_settings) {
|
||||
j["orca_presets"].push_back(preset.second);
|
||||
}
|
||||
for (const auto& local_machine : m_local_machines) {
|
||||
json m_json;
|
||||
m_json["dev_name"] = local_machine.second.dev_name;
|
||||
m_json["dev_ip"] = local_machine.second.dev_ip;
|
||||
m_json["printer_type"] = local_machine.second.printer_type;
|
||||
|
||||
j["local_machines"][local_machine.first] = m_json;
|
||||
}
|
||||
boost::nowide::ofstream c;
|
||||
c.open(path_pid, std::ios::out | std::ios::trunc);
|
||||
c << std::setw(4) << j << std::endl;
|
||||
|
@ -791,7 +812,7 @@ void AppConfig::save()
|
|||
// WIN32 specific: The final "rename_file()" call is not safe in case of an application crash, there is no atomic "rename file" API
|
||||
// provided by Windows (sic!). Therefore we save a MD5 checksum to be able to verify file corruption. In addition,
|
||||
// we save the config file into a backup first before moving it to the final destination.
|
||||
c << appconfig_md5_hash_line({j.dump(4)});
|
||||
c << appconfig_md5_hash_line(j.dump(4));
|
||||
#endif
|
||||
|
||||
c.close();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue