mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-22 00:01:09 -06:00
Moved the Slic3rPE/print,filament,printer folders to
Slic3rPE/presets/print,filament,printer to separate the presets from further data stored into the Slic3rPE directory.
This commit is contained in:
parent
ca4bd96d5d
commit
679aa2822c
8 changed files with 21 additions and 41 deletions
|
@ -24,11 +24,6 @@ const std::string& resources_dir();
|
|||
void set_data_dir(const std::string &path);
|
||||
// Return a full path to the GUI resource files.
|
||||
const std::string& data_dir();
|
||||
// Return a full path to a configuration file given its file name..
|
||||
std::string config_path(const std::string &file_name);
|
||||
// Return a full path to a configuration file given the section and name.
|
||||
// The suffix ".ini" will be added if it is missing in the name.
|
||||
std::string config_path(const std::string §ion, const std::string &name);
|
||||
|
||||
extern std::string encode_path(const char *src);
|
||||
extern std::string decode_path(const char *src);
|
||||
|
|
|
@ -113,19 +113,6 @@ const std::string& data_dir()
|
|||
return g_data_dir;
|
||||
}
|
||||
|
||||
std::string config_path(const std::string &file_name)
|
||||
{
|
||||
auto file = (boost::filesystem::path(g_data_dir) / file_name).make_preferred();
|
||||
return file.string();
|
||||
}
|
||||
|
||||
std::string config_path(const std::string §ion, const std::string &name)
|
||||
{
|
||||
auto file_name = boost::algorithm::iends_with(name, ".ini") ? name : name + ".ini";
|
||||
auto file = (boost::filesystem::path(g_data_dir) / section / file_name).make_preferred();
|
||||
return file.string();
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
#ifdef SLIC3R_HAS_BROKEN_CROAK
|
||||
|
|
|
@ -66,7 +66,12 @@ PresetBundle::~PresetBundle()
|
|||
void PresetBundle::setup_directories()
|
||||
{
|
||||
boost::filesystem::path data_dir = boost::filesystem::path(Slic3r::data_dir());
|
||||
std::initializer_list<boost::filesystem::path> paths = { data_dir, data_dir / "print", data_dir / "filament", data_dir / "printer" };
|
||||
std::initializer_list<boost::filesystem::path> paths = {
|
||||
data_dir,
|
||||
data_dir / "presets",
|
||||
data_dir / "presets" / "print",
|
||||
data_dir / "presets" / "filament",
|
||||
data_dir / "presets" / "printer" };
|
||||
for (const boost::filesystem::path &path : paths) {
|
||||
boost::filesystem::path subdir = path;
|
||||
subdir.make_preferred();
|
||||
|
@ -76,9 +81,10 @@ void PresetBundle::setup_directories()
|
|||
}
|
||||
}
|
||||
|
||||
void PresetBundle::load_presets(const std::string &dir_path)
|
||||
void PresetBundle::load_presets()
|
||||
{
|
||||
std::string errors_cummulative;
|
||||
const std::string dir_path = data_dir() + "/presets";
|
||||
try {
|
||||
this->prints.load_presets(dir_path, "print");
|
||||
} catch (const std::runtime_error &err) {
|
||||
|
@ -465,8 +471,11 @@ size_t PresetBundle::load_configbundle(const std::string &path)
|
|||
for (auto &kvp : section.second)
|
||||
config.set_deserialize(kvp.first, kvp.second.data());
|
||||
Preset::normalize(config);
|
||||
// Decide a full path to this .ini file.
|
||||
auto file_name = boost::algorithm::iends_with(preset_name, ".ini") ? preset_name : preset_name + ".ini";
|
||||
auto file_path = (boost::filesystem::path(data_dir()) / "presets" / presets->name() / file_name).make_preferred();
|
||||
// Load the preset into the list of presets, save it to disk.
|
||||
presets->load_preset(Slic3r::config_path(presets->name(), preset_name), preset_name, std::move(config), false).save();
|
||||
presets->load_preset(file_path.string(), preset_name, std::move(config), false).save();
|
||||
++ presets_loaded;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@ public:
|
|||
|
||||
void setup_directories();
|
||||
|
||||
// Load ini files of all types (print, filament, printer) from the provided directory path.
|
||||
void load_presets(const std::string &dir_path);
|
||||
// Load ini files of all types (print, filament, printer) from Slic3r::data_dir() / presets.
|
||||
void load_presets();
|
||||
|
||||
// Load selections (current print, current filaments, current printer) from config.ini
|
||||
// This is done just once on application start up.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue