Fixed selection of sensible active print / filament / printer profile

after the initial wizard run.
This commit is contained in:
bubnikv 2018-03-14 13:29:50 +01:00
parent 1969a8b2c1
commit e680658cf5
4 changed files with 22 additions and 0 deletions

View File

@ -723,6 +723,10 @@ sub config_wizard {
} else { } else {
# Wizard returned a name of a preset bundle bundled with the installation. Unpack it. # Wizard returned a name of a preset bundle bundled with the installation. Unpack it.
wxTheApp->{preset_bundle}->install_vendor_configbundle($directory . '/' . $result->{preset_name} . '.ini'); wxTheApp->{preset_bundle}->install_vendor_configbundle($directory . '/' . $result->{preset_name} . '.ini');
# Reset the print / filament / printer selections, so that following line will select some sensible defaults.
if ($fresh_start) {
wxTheApp->{app_config}->reset_selections;
}
# Reload all presets after the vendor config bundle has been installed. # Reload all presets after the vendor config bundle has been installed.
wxTheApp->{preset_bundle}->load_presets(wxTheApp->{app_config}); wxTheApp->{preset_bundle}->load_presets(wxTheApp->{app_config});
} }

View File

@ -145,6 +145,17 @@ void AppConfig::update_last_output_dir(const std::string &dir)
this->set("", "last_output_path", dir); this->set("", "last_output_path", dir);
} }
void AppConfig::reset_selections()
{
auto it = m_storage.find("presets");
if (it != m_storage.end()) {
it->second.erase("print");
it->second.erase("filament");
it->second.erase("printer");
m_dirty = true;
}
}
std::string AppConfig::config_path() std::string AppConfig::config_path()
{ {
return (boost::filesystem::path(Slic3r::data_dir()) / "slic3r.ini").make_preferred().string(); return (boost::filesystem::path(Slic3r::data_dir()) / "slic3r.ini").make_preferred().string();

View File

@ -73,6 +73,11 @@ public:
std::string get_last_output_dir(const std::string &alt) const; std::string get_last_output_dir(const std::string &alt) const;
void update_last_output_dir(const std::string &dir); void update_last_output_dir(const std::string &dir);
// reset the current print / filament / printer selections, so that
// the PresetBundle::load_selections(const AppConfig &config) call will select
// the first non-default preset when called.
void reset_selections();
// Get the default config path from Slic3r::data_dir(). // Get the default config path from Slic3r::data_dir().
static std::string config_path(); static std::string config_path();

View File

@ -41,4 +41,6 @@
void update_skein_dir(char *dir); void update_skein_dir(char *dir);
std::string get_last_output_dir(const char *alt = ""); std::string get_last_output_dir(const char *alt = "");
void update_last_output_dir(char *dir); void update_last_output_dir(char *dir);
void reset_selections();
}; };