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
|
@ -100,16 +100,12 @@ sub OnInit {
|
|||
|
||||
# Suppress the '- default -' presets.
|
||||
$self->{preset_bundle}->set_default_suppressed($self->{app_config}->get('no_defaults') ? 1 : 0);
|
||||
eval {
|
||||
$self->{preset_bundle}->load_presets(Slic3r::data_dir);
|
||||
};
|
||||
eval { $self->{preset_bundle}->load_presets };
|
||||
if ($@) {
|
||||
warn $@ . "\n";
|
||||
show_error(undef, $@);
|
||||
}
|
||||
eval {
|
||||
$self->{preset_bundle}->load_selections($self->{app_config});
|
||||
};
|
||||
eval { $self->{preset_bundle}->load_selections($self->{app_config}) };
|
||||
$run_wizard = 1 if $self->{preset_bundle}->has_defauls_only;
|
||||
|
||||
# application frame
|
||||
|
|
|
@ -147,7 +147,7 @@ sub save_preset {
|
|||
return unless $dlg->ShowModal == wxID_OK;
|
||||
$name = $dlg->get_name;
|
||||
}
|
||||
# Save the preset into Slic3r::data_dir/section_name/preset_name.ini
|
||||
# Save the preset into Slic3r::data_dir/presets/section_name/preset_name.ini
|
||||
eval { $self->{presets}->save_current_preset($name); };
|
||||
Slic3r::GUI::catch_error($self) and return;
|
||||
# Add the new item into the UI component, remove dirty flags and activate the saved item.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -106,12 +106,13 @@ PresetCollection::arrayref()
|
|||
croak("Cannot create configuration directories:\n%s\n", e.what());
|
||||
}
|
||||
%};
|
||||
void load_presets(const char *dir_path)
|
||||
void load_presets()
|
||||
%code%{
|
||||
try {
|
||||
THIS->load_presets(dir_path);
|
||||
THIS->load_presets();
|
||||
} catch (std::exception& e) {
|
||||
croak("Loading of Slic3r presets from %s failed.\n\n%s\n", dir_path, e.what());
|
||||
croak("Loading of Slic3r presets from %s failed.\n\n%s\n",
|
||||
Slic3r::data_dir().c_str(), e.what());
|
||||
}
|
||||
%};
|
||||
void load_config_file(const char *path)
|
||||
|
|
|
@ -91,14 +91,6 @@ data_dir()
|
|||
RETVAL = const_cast<char*>(Slic3r::data_dir().c_str());
|
||||
OUTPUT: RETVAL
|
||||
|
||||
std::string
|
||||
config_path(section, name)
|
||||
const char *section;
|
||||
const char *name;
|
||||
CODE:
|
||||
RETVAL = Slic3r::config_path(section, name);
|
||||
OUTPUT: RETVAL
|
||||
|
||||
std::string
|
||||
encode_path(src)
|
||||
const char *src;
|
||||
|
|
Loading…
Reference in a new issue