2018-12-06 11:52:28 +00:00
|
|
|
#include "libslic3r/libslic3r.h"
|
|
|
|
#include "libslic3r/Utils.hpp"
|
2017-10-30 17:41:50 +00:00
|
|
|
#include "AppConfig.hpp"
|
|
|
|
|
|
|
|
#include <utility>
|
2018-03-28 09:36:36 +00:00
|
|
|
#include <vector>
|
2018-04-11 11:12:08 +00:00
|
|
|
#include <stdexcept>
|
2017-10-30 17:41:50 +00:00
|
|
|
|
2020-02-28 10:13:14 +00:00
|
|
|
#include <boost/filesystem/path.hpp>
|
|
|
|
#include <boost/filesystem/operations.hpp>
|
2017-10-30 17:41:50 +00:00
|
|
|
#include <boost/nowide/cenv.hpp>
|
|
|
|
#include <boost/nowide/fstream.hpp>
|
|
|
|
#include <boost/property_tree/ini_parser.hpp>
|
2020-02-28 10:13:14 +00:00
|
|
|
#include <boost/property_tree/ptree_fwd.hpp>
|
2018-03-28 09:36:36 +00:00
|
|
|
#include <boost/algorithm/string/predicate.hpp>
|
2020-02-28 10:13:14 +00:00
|
|
|
#include <boost/format/format_fwd.hpp>
|
2017-10-30 17:41:50 +00:00
|
|
|
|
2020-08-08 15:03:20 +00:00
|
|
|
//#include <wx/string.h>
|
|
|
|
//#include "I18N.hpp"
|
2019-08-19 10:55:57 +00:00
|
|
|
|
2017-10-30 17:41:50 +00:00
|
|
|
namespace Slic3r {
|
|
|
|
|
2018-03-28 09:36:36 +00:00
|
|
|
static const std::string VENDOR_PREFIX = "vendor:";
|
|
|
|
static const std::string MODEL_PREFIX = "model:";
|
2019-09-16 15:51:31 +00:00
|
|
|
static const std::string VERSION_CHECK_URL = "https://files.prusa3d.com/wp-content/uploads/repository/PrusaSlicer-settings-master/live/PrusaSlicer.version";
|
2018-03-28 09:36:36 +00:00
|
|
|
|
2019-06-03 08:15:26 +00:00
|
|
|
const std::string AppConfig::SECTION_FILAMENTS = "filaments";
|
|
|
|
const std::string AppConfig::SECTION_MATERIALS = "sla_materials";
|
|
|
|
|
2017-10-30 17:41:50 +00:00
|
|
|
void AppConfig::reset()
|
|
|
|
{
|
|
|
|
m_storage.clear();
|
|
|
|
set_defaults();
|
|
|
|
};
|
|
|
|
|
|
|
|
// Override missing or keys with their defaults.
|
|
|
|
void AppConfig::set_defaults()
|
|
|
|
{
|
2017-11-02 15:21:34 +00:00
|
|
|
// Reset the empty fields to defaults.
|
2017-10-30 17:41:50 +00:00
|
|
|
if (get("autocenter").empty())
|
2017-12-29 20:17:30 +00:00
|
|
|
set("autocenter", "0");
|
2017-10-30 17:41:50 +00:00
|
|
|
// Disable background processing by default as it is not stable.
|
|
|
|
if (get("background_processing").empty())
|
|
|
|
set("background_processing", "0");
|
|
|
|
// If set, the "Controller" tab for the control of the printer over serial line and the serial port settings are hidden.
|
|
|
|
// By default, Prusa has the controller hidden.
|
|
|
|
if (get("no_controller").empty())
|
2017-11-02 15:21:34 +00:00
|
|
|
set("no_controller", "1");
|
2017-10-30 17:41:50 +00:00
|
|
|
// If set, the "- default -" selections of print/filament/printer are suppressed, if there is a valid preset available.
|
|
|
|
if (get("no_defaults").empty())
|
|
|
|
set("no_defaults", "1");
|
2017-11-10 16:27:05 +00:00
|
|
|
if (get("show_incompatible_presets").empty())
|
|
|
|
set("show_incompatible_presets", "0");
|
2018-04-13 13:08:58 +00:00
|
|
|
|
2017-11-02 15:21:34 +00:00
|
|
|
if (get("version_check").empty())
|
|
|
|
set("version_check", "1");
|
2018-03-28 09:36:36 +00:00
|
|
|
if (get("preset_update").empty())
|
|
|
|
set("preset_update", "1");
|
2018-04-13 13:08:58 +00:00
|
|
|
|
2020-01-08 10:11:38 +00:00
|
|
|
if (get("export_sources_full_pathnames").empty())
|
2020-01-13 07:47:11 +00:00
|
|
|
set("export_sources_full_pathnames", "0");
|
2020-01-08 10:11:38 +00:00
|
|
|
|
2019-06-25 07:20:58 +00:00
|
|
|
// remove old 'use_legacy_opengl' parameter from this config, if present
|
|
|
|
if (!get("use_legacy_opengl").empty())
|
|
|
|
erase("", "use_legacy_opengl");
|
2018-05-22 11:57:28 +00:00
|
|
|
|
2019-08-19 10:55:57 +00:00
|
|
|
#ifdef __APPLE__
|
2019-01-24 10:30:29 +00:00
|
|
|
if (get("use_retina_opengl").empty())
|
|
|
|
set("use_retina_opengl", "1");
|
|
|
|
#endif
|
|
|
|
|
2020-04-29 08:50:28 +00:00
|
|
|
if (get("single_instance").empty())
|
|
|
|
set("single_instance", "0");
|
|
|
|
|
2018-05-22 11:57:28 +00:00
|
|
|
if (get("remember_output_path").empty())
|
|
|
|
set("remember_output_path", "1");
|
2018-09-17 13:12:13 +00:00
|
|
|
|
2020-03-03 13:52:16 +00:00
|
|
|
if (get("remember_output_path_removable").empty())
|
2020-01-02 15:30:28 +00:00
|
|
|
set("remember_output_path_removable", "1");
|
|
|
|
|
2019-05-22 11:51:02 +00:00
|
|
|
if (get("use_custom_toolbar_size").empty())
|
|
|
|
set("use_custom_toolbar_size", "0");
|
|
|
|
|
|
|
|
if (get("custom_toolbar_size").empty())
|
|
|
|
set("custom_toolbar_size", "100");
|
|
|
|
|
2020-05-12 21:07:06 +00:00
|
|
|
if (get("auto_toolbar_size").empty())
|
|
|
|
set("auto_toolbar_size", "100");
|
|
|
|
|
2019-06-24 13:55:14 +00:00
|
|
|
if (get("use_perspective_camera").empty())
|
|
|
|
set("use_perspective_camera", "1");
|
2019-06-20 08:02:52 +00:00
|
|
|
|
2020-01-16 08:12:36 +00:00
|
|
|
if (get("use_free_camera").empty())
|
|
|
|
set("use_free_camera", "0");
|
|
|
|
|
2020-05-28 13:27:29 +00:00
|
|
|
#if ENABLE_ENVIRONMENT_MAP
|
|
|
|
if (get("use_environment_map").empty())
|
|
|
|
set("use_environment_map", "0");
|
|
|
|
#endif // ENABLE_ENVIRONMENT_MAP
|
|
|
|
|
2020-06-10 09:02:54 +00:00
|
|
|
if (get("use_inches").empty())
|
|
|
|
set("use_inches", "0");
|
|
|
|
|
2020-09-10 14:03:43 +00:00
|
|
|
if (get("show_splash_screen").empty())
|
|
|
|
set("show_splash_screen", "1");
|
|
|
|
|
2018-09-17 13:12:13 +00:00
|
|
|
// Remove legacy window positions/sizes
|
|
|
|
erase("", "main_frame_maximized");
|
|
|
|
erase("", "main_frame_pos");
|
|
|
|
erase("", "main_frame_size");
|
|
|
|
erase("", "object_settings_maximized");
|
|
|
|
erase("", "object_settings_pos");
|
|
|
|
erase("", "object_settings_size");
|
2017-10-30 17:41:50 +00:00
|
|
|
}
|
|
|
|
|
2020-08-08 15:03:20 +00:00
|
|
|
std::string AppConfig::load()
|
2017-10-30 17:41:50 +00:00
|
|
|
{
|
|
|
|
// 1) Read the complete config file into a boost::property_tree.
|
|
|
|
namespace pt = boost::property_tree;
|
|
|
|
pt::ptree tree;
|
|
|
|
boost::nowide::ifstream ifs(AppConfig::config_path());
|
2019-08-19 10:55:57 +00:00
|
|
|
try {
|
|
|
|
pt::read_ini(ifs, tree);
|
|
|
|
} catch (pt::ptree_error& ex) {
|
|
|
|
// Error while parsing config file. We'll customize the error message and rethrow to be displayed.
|
2020-08-08 15:03:20 +00:00
|
|
|
// ! But to avoid the use of _utf8 (related to use of wxWidgets)
|
|
|
|
// we will rethrow this exception from the place of load() call, if returned value wouldn't be empty
|
|
|
|
/*
|
2019-08-20 14:19:30 +00:00
|
|
|
throw std::runtime_error(
|
|
|
|
_utf8(L("Error parsing PrusaSlicer config file, it is probably corrupted. "
|
2019-12-04 14:12:00 +00:00
|
|
|
"Try to manually delete the file to recover from the error. Your user profiles will not be affected.")) +
|
2019-08-20 14:19:30 +00:00
|
|
|
"\n\n" + AppConfig::config_path() + "\n\n" + ex.what());
|
2020-08-08 15:03:20 +00:00
|
|
|
*/
|
|
|
|
return ex.what();
|
2019-08-19 10:55:57 +00:00
|
|
|
}
|
2017-10-30 17:41:50 +00:00
|
|
|
|
|
|
|
// 2) Parse the property_tree, extract the sections and key / value pairs.
|
|
|
|
for (const auto §ion : tree) {
|
|
|
|
if (section.second.empty()) {
|
|
|
|
// This may be a top level (no section) entry, or an empty section.
|
|
|
|
std::string data = section.second.data();
|
|
|
|
if (! data.empty())
|
|
|
|
// If there is a non-empty data, then it must be a top-level (without a section) config entry.
|
|
|
|
m_storage[""][section.first] = data;
|
2018-03-28 09:36:36 +00:00
|
|
|
} else if (boost::starts_with(section.first, VENDOR_PREFIX)) {
|
|
|
|
// This is a vendor section listing enabled model / variants
|
|
|
|
const auto vendor_name = section.first.substr(VENDOR_PREFIX.size());
|
|
|
|
auto &vendor = m_vendors[vendor_name];
|
|
|
|
for (const auto &kvp : section.second) {
|
|
|
|
if (! boost::starts_with(kvp.first, MODEL_PREFIX)) { continue; }
|
|
|
|
const auto model_name = kvp.first.substr(MODEL_PREFIX.size());
|
|
|
|
std::vector<std::string> variants;
|
|
|
|
if (! unescape_strings_cstyle(kvp.second.data(), variants)) { continue; }
|
|
|
|
for (const auto &variant : variants) {
|
|
|
|
vendor[model_name].insert(variant);
|
|
|
|
}
|
|
|
|
}
|
2017-10-30 17:41:50 +00:00
|
|
|
} else {
|
|
|
|
// This must be a section name. Read the entries of a section.
|
|
|
|
std::map<std::string, std::string> &storage = m_storage[section.first];
|
|
|
|
for (auto &kvp : section.second)
|
|
|
|
storage[kvp.first] = kvp.second.data();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-16 14:52:11 +00:00
|
|
|
// Figure out if datadir has legacy presets
|
|
|
|
auto ini_ver = Semver::parse(get("version"));
|
2018-04-19 16:29:19 +00:00
|
|
|
m_legacy_datadir = false;
|
|
|
|
if (ini_ver) {
|
2018-05-17 14:19:40 +00:00
|
|
|
m_orig_version = *ini_ver;
|
2018-04-19 16:29:19 +00:00
|
|
|
// Make 1.40.0 alphas compare well
|
|
|
|
ini_ver->set_metadata(boost::none);
|
|
|
|
ini_ver->set_prerelease(boost::none);
|
|
|
|
m_legacy_datadir = ini_ver < Semver(1, 40, 0);
|
|
|
|
}
|
2018-04-16 14:52:11 +00:00
|
|
|
|
2017-10-30 17:41:50 +00:00
|
|
|
// Override missing or keys with their defaults.
|
|
|
|
this->set_defaults();
|
|
|
|
m_dirty = false;
|
2020-08-08 15:03:20 +00:00
|
|
|
return "";
|
2017-10-30 17:41:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AppConfig::save()
|
|
|
|
{
|
2020-09-10 06:49:50 +00:00
|
|
|
#if ENABLE_GCODE_VIEWER
|
2020-09-08 09:40:06 +00:00
|
|
|
if (!m_save_enabled)
|
|
|
|
return;
|
2020-09-10 06:49:50 +00:00
|
|
|
#endif // ENABLE_GCODE_VIEWER
|
2020-09-08 09:40:06 +00:00
|
|
|
|
2018-12-11 15:33:43 +00:00
|
|
|
// The config is first written to a file with a PID suffix and then moved
|
|
|
|
// to avoid race conditions with multiple instances of Slic3r
|
|
|
|
const auto path = config_path();
|
|
|
|
std::string path_pid = (boost::format("%1%.%2%") % path % get_current_pid()).str();
|
|
|
|
|
2017-10-30 17:41:50 +00:00
|
|
|
boost::nowide::ofstream c;
|
2018-12-11 15:33:43 +00:00
|
|
|
c.open(path_pid, std::ios::out | std::ios::trunc);
|
2017-10-30 17:41:50 +00:00
|
|
|
c << "# " << Slic3r::header_slic3r_generated() << std::endl;
|
|
|
|
// Make sure the "no" category is written first.
|
|
|
|
for (const std::pair<std::string, std::string> &kvp : m_storage[""])
|
|
|
|
c << kvp.first << " = " << kvp.second << std::endl;
|
|
|
|
// Write the other categories.
|
|
|
|
for (const auto category : m_storage) {
|
|
|
|
if (category.first.empty())
|
|
|
|
continue;
|
|
|
|
c << std::endl << "[" << category.first << "]" << std::endl;
|
|
|
|
for (const std::pair<std::string, std::string> &kvp : category.second)
|
|
|
|
c << kvp.first << " = " << kvp.second << std::endl;
|
|
|
|
}
|
2018-03-28 09:36:36 +00:00
|
|
|
// Write vendor sections
|
|
|
|
for (const auto &vendor : m_vendors) {
|
|
|
|
size_t size_sum = 0;
|
|
|
|
for (const auto &model : vendor.second) { size_sum += model.second.size(); }
|
|
|
|
if (size_sum == 0) { continue; }
|
|
|
|
|
|
|
|
c << std::endl << "[" << VENDOR_PREFIX << vendor.first << "]" << std::endl;
|
|
|
|
|
|
|
|
for (const auto &model : vendor.second) {
|
|
|
|
if (model.second.size() == 0) { continue; }
|
|
|
|
const std::vector<std::string> variants(model.second.begin(), model.second.end());
|
|
|
|
const auto escaped = escape_strings_cstyle(variants);
|
|
|
|
c << MODEL_PREFIX << model.first << " = " << escaped << std::endl;
|
|
|
|
}
|
|
|
|
}
|
2017-10-30 17:41:50 +00:00
|
|
|
c.close();
|
2018-12-11 15:33:43 +00:00
|
|
|
|
|
|
|
rename_file(path_pid, path);
|
2017-10-30 17:41:50 +00:00
|
|
|
m_dirty = false;
|
|
|
|
}
|
|
|
|
|
2018-03-28 09:36:36 +00:00
|
|
|
bool AppConfig::get_variant(const std::string &vendor, const std::string &model, const std::string &variant) const
|
|
|
|
{
|
|
|
|
const auto it_v = m_vendors.find(vendor);
|
|
|
|
if (it_v == m_vendors.end()) { return false; }
|
|
|
|
const auto it_m = it_v->second.find(model);
|
|
|
|
return it_m == it_v->second.end() ? false : it_m->second.find(variant) != it_m->second.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppConfig::set_variant(const std::string &vendor, const std::string &model, const std::string &variant, bool enable)
|
|
|
|
{
|
|
|
|
if (enable) {
|
|
|
|
if (get_variant(vendor, model, variant)) { return; }
|
|
|
|
m_vendors[vendor][model].insert(variant);
|
|
|
|
} else {
|
|
|
|
auto it_v = m_vendors.find(vendor);
|
|
|
|
if (it_v == m_vendors.end()) { return; }
|
|
|
|
auto it_m = it_v->second.find(model);
|
|
|
|
if (it_m == it_v->second.end()) { return; }
|
|
|
|
auto it_var = it_m->second.find(variant);
|
|
|
|
if (it_var == it_m->second.end()) { return; }
|
|
|
|
it_m->second.erase(it_var);
|
|
|
|
}
|
|
|
|
// If we got here, there was an update
|
|
|
|
m_dirty = true;
|
2018-03-29 15:54:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AppConfig::set_vendors(const AppConfig &from)
|
|
|
|
{
|
|
|
|
m_vendors = from.m_vendors;
|
|
|
|
m_dirty = true;
|
2018-03-28 09:36:36 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 17:41:50 +00:00
|
|
|
std::string AppConfig::get_last_dir() const
|
|
|
|
{
|
|
|
|
const auto it = m_storage.find("recent");
|
|
|
|
if (it != m_storage.end()) {
|
|
|
|
{
|
|
|
|
const auto it2 = it->second.find("skein_directory");
|
|
|
|
if (it2 != it->second.end() && ! it2->second.empty())
|
|
|
|
return it2->second;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
const auto it2 = it->second.find("config_directory");
|
|
|
|
if (it2 != it->second.end() && ! it2->second.empty())
|
|
|
|
return it2->second;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
|
2019-07-12 13:36:01 +00:00
|
|
|
std::vector<std::string> AppConfig::get_recent_projects() const
|
|
|
|
{
|
|
|
|
std::vector<std::string> ret;
|
|
|
|
const auto it = m_storage.find("recent_projects");
|
|
|
|
if (it != m_storage.end())
|
|
|
|
{
|
|
|
|
for (const std::map<std::string, std::string>::value_type& item : it->second)
|
|
|
|
{
|
|
|
|
ret.push_back(item.second);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppConfig::set_recent_projects(const std::vector<std::string>& recent_projects)
|
|
|
|
{
|
|
|
|
auto it = m_storage.find("recent_projects");
|
|
|
|
if (it == m_storage.end())
|
|
|
|
it = m_storage.insert(std::map<std::string, std::map<std::string, std::string>>::value_type("recent_projects", std::map<std::string, std::string>())).first;
|
|
|
|
|
|
|
|
it->second.clear();
|
|
|
|
for (unsigned int i = 0; i < (unsigned int)recent_projects.size(); ++i)
|
|
|
|
{
|
|
|
|
it->second[std::to_string(i + 1)] = recent_projects[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-20 15:13:08 +00:00
|
|
|
void AppConfig::set_mouse_device(const std::string& name, double translation_speed, double translation_deadzone, float rotation_speed, float rotation_deadzone, double zoom_speed, bool swap_yz)
|
2019-10-03 08:26:28 +00:00
|
|
|
{
|
|
|
|
std::string key = std::string("mouse_device:") + name;
|
|
|
|
auto it = m_storage.find(key);
|
|
|
|
if (it == m_storage.end())
|
|
|
|
it = m_storage.insert(std::map<std::string, std::map<std::string, std::string>>::value_type(key, std::map<std::string, std::string>())).first;
|
|
|
|
|
|
|
|
it->second.clear();
|
|
|
|
it->second["translation_speed"] = std::to_string(translation_speed);
|
2019-10-08 12:32:05 +00:00
|
|
|
it->second["translation_deadzone"] = std::to_string(translation_deadzone);
|
2019-10-03 08:26:28 +00:00
|
|
|
it->second["rotation_speed"] = std::to_string(rotation_speed);
|
2019-10-08 12:32:05 +00:00
|
|
|
it->second["rotation_deadzone"] = std::to_string(rotation_deadzone);
|
2020-01-03 13:42:52 +00:00
|
|
|
it->second["zoom_speed"] = std::to_string(zoom_speed);
|
2020-03-20 15:13:08 +00:00
|
|
|
it->second["swap_yz"] = swap_yz ? "1" : "0";
|
2019-10-03 08:26:28 +00:00
|
|
|
}
|
|
|
|
|
2020-03-04 10:36:36 +00:00
|
|
|
std::vector<std::string> AppConfig::get_mouse_device_names() const
|
2019-10-03 08:26:28 +00:00
|
|
|
{
|
2020-04-22 10:49:52 +00:00
|
|
|
static constexpr const char *prefix = "mouse_device:";
|
|
|
|
static const size_t prefix_len = strlen(prefix);
|
|
|
|
std::vector<std::string> out;
|
2020-03-04 10:36:36 +00:00
|
|
|
for (const std::pair<std::string, std::map<std::string, std::string>>& key_value_pair : m_storage)
|
2020-04-22 10:49:52 +00:00
|
|
|
if (boost::starts_with(key_value_pair.first, prefix) && key_value_pair.first.size() > prefix_len)
|
2020-03-04 10:36:36 +00:00
|
|
|
out.emplace_back(key_value_pair.first.substr(prefix_len));
|
2020-04-22 10:49:52 +00:00
|
|
|
return out;
|
2020-01-03 13:42:52 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 17:41:50 +00:00
|
|
|
void AppConfig::update_config_dir(const std::string &dir)
|
|
|
|
{
|
|
|
|
this->set("recent", "config_directory", dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppConfig::update_skein_dir(const std::string &dir)
|
|
|
|
{
|
|
|
|
this->set("recent", "skein_directory", dir);
|
|
|
|
}
|
2020-01-02 15:30:28 +00:00
|
|
|
/*
|
2017-10-30 17:41:50 +00:00
|
|
|
std::string AppConfig::get_last_output_dir(const std::string &alt) const
|
|
|
|
{
|
2019-11-27 12:30:45 +00:00
|
|
|
|
2017-10-30 17:41:50 +00:00
|
|
|
const auto it = m_storage.find("");
|
|
|
|
if (it != m_storage.end()) {
|
|
|
|
const auto it2 = it->second.find("last_output_path");
|
|
|
|
const auto it3 = it->second.find("remember_output_path");
|
|
|
|
if (it2 != it->second.end() && it3 != it->second.end() && ! it2->second.empty() && it3->second == "1")
|
|
|
|
return it2->second;
|
|
|
|
}
|
|
|
|
return alt;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppConfig::update_last_output_dir(const std::string &dir)
|
|
|
|
{
|
|
|
|
this->set("", "last_output_path", dir);
|
|
|
|
}
|
2020-01-02 15:30:28 +00:00
|
|
|
*/
|
|
|
|
std::string AppConfig::get_last_output_dir(const std::string& alt, const bool removable) const
|
|
|
|
{
|
|
|
|
std::string s1 = (removable ? "last_output_path_removable" : "last_output_path");
|
|
|
|
std::string s2 = (removable ? "remember_output_path_removable" : "remember_output_path");
|
|
|
|
const auto it = m_storage.find("");
|
|
|
|
if (it != m_storage.end()) {
|
|
|
|
const auto it2 = it->second.find(s1);
|
|
|
|
const auto it3 = it->second.find(s2);
|
|
|
|
if (it2 != it->second.end() && it3 != it->second.end() && !it2->second.empty() && it3->second == "1")
|
|
|
|
return it2->second;
|
|
|
|
}
|
|
|
|
return alt;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppConfig::update_last_output_dir(const std::string& dir, const bool removable)
|
|
|
|
{
|
|
|
|
this->set("", (removable ? "last_output_path_removable" : "last_output_path"), dir);
|
|
|
|
}
|
|
|
|
|
2017-10-30 17:41:50 +00:00
|
|
|
|
2018-03-14 12:29:50 +00:00
|
|
|
void AppConfig::reset_selections()
|
|
|
|
{
|
|
|
|
auto it = m_storage.find("presets");
|
|
|
|
if (it != m_storage.end()) {
|
|
|
|
it->second.erase("print");
|
|
|
|
it->second.erase("filament");
|
2018-11-19 10:10:22 +00:00
|
|
|
it->second.erase("sla_print");
|
2018-07-31 13:09:57 +00:00
|
|
|
it->second.erase("sla_material");
|
2018-03-14 12:29:50 +00:00
|
|
|
it->second.erase("printer");
|
|
|
|
m_dirty = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-30 17:41:50 +00:00
|
|
|
std::string AppConfig::config_path()
|
|
|
|
{
|
2019-05-13 12:11:21 +00:00
|
|
|
return (boost::filesystem::path(Slic3r::data_dir()) / (SLIC3R_APP_KEY ".ini")).make_preferred().string();
|
2017-10-30 17:41:50 +00:00
|
|
|
}
|
|
|
|
|
2018-04-25 15:43:01 +00:00
|
|
|
std::string AppConfig::version_check_url() const
|
|
|
|
{
|
|
|
|
auto from_settings = get("version_check_url");
|
|
|
|
return from_settings.empty() ? VERSION_CHECK_URL : from_settings;
|
|
|
|
}
|
|
|
|
|
2017-10-30 17:41:50 +00:00
|
|
|
bool AppConfig::exists()
|
|
|
|
{
|
|
|
|
return boost::filesystem::exists(AppConfig::config_path());
|
|
|
|
}
|
|
|
|
|
|
|
|
}; // namespace Slic3r
|