mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-23 00:31:11 -06:00
ConfigWizard: Add reset option, fixes
Fix mock vendors
This commit is contained in:
parent
c884f3b213
commit
81c6ad3ab7
9 changed files with 102 additions and 78 deletions
|
@ -17,7 +17,6 @@
|
|||
#include "GUI.hpp"
|
||||
#include "slic3r/Utils/PresetUpdater.hpp"
|
||||
|
||||
// TODO: Wizard vs Assistant
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
@ -205,9 +204,18 @@ void ConfigWizardPage::enable_next(bool enable) { parent->p->enable_next(enable)
|
|||
PageWelcome::PageWelcome(ConfigWizard *parent) :
|
||||
ConfigWizardPage(parent, wxString::Format(_(L("Welcome to the Slic3r %s")), ConfigWizard::name()), _(L("Welcome"))),
|
||||
printer_picker(nullptr),
|
||||
others_buttons(new wxPanel(parent))
|
||||
others_buttons(new wxPanel(parent)),
|
||||
cbox_reset(new wxCheckBox(this, wxID_ANY, _(L("Remove user profiles - install from scratch (a snapshot will be taken beforehand)"))))
|
||||
{
|
||||
append_text(_(L("Hello, welcome to Slic3r Prusa Edition! TODO: This text.")));
|
||||
if (wizard_p()->flag_startup && wizard_p()->flag_empty_datadir) {
|
||||
wxString::Format(_(L("Run %s")), ConfigWizard::name());
|
||||
append_text(wxString::Format(
|
||||
_(L("Hello, welcome to Slic3r Prusa Edition! This %s helps you with the initial configuration; just a few settings and you will be ready to print.")),
|
||||
ConfigWizard::name())
|
||||
);
|
||||
} else {
|
||||
append(cbox_reset);
|
||||
}
|
||||
|
||||
const auto &vendors = wizard_p()->vendors;
|
||||
const auto vendor_prusa = vendors.find("PrusaResearch");
|
||||
|
@ -720,14 +728,22 @@ void ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese
|
|||
// This vendor needs to be installed
|
||||
install_bundles.emplace_back(vendor_rsrc.second);
|
||||
}
|
||||
|
||||
// If the datadir was empty don't take a snapshot (it would just be an empty snapshot)
|
||||
const bool snapshot = !flag_empty_datadir || page_welcome->reset_user_profile();
|
||||
if (install_bundles.size() > 0) {
|
||||
updater->install_bundles_rsrc(std::move(install_bundles));
|
||||
// Install bundles from resources.
|
||||
updater->install_bundles_rsrc(std::move(install_bundles), snapshot);
|
||||
}
|
||||
|
||||
if (page_welcome->reset_user_profile()) {
|
||||
preset_bundle->reset(true);
|
||||
}
|
||||
|
||||
app_config->set_vendors(appconfig_vendors);
|
||||
app_config->set("version_check", page_update->version_check ? "1" : "0");
|
||||
app_config->set("preset_update", page_update->preset_update ? "1" : "0");
|
||||
if (fresh_start)
|
||||
if (flag_startup)
|
||||
app_config->reset_selections();
|
||||
// ^ TODO: replace with appropriate printer selection
|
||||
preset_bundle->load_presets(*app_config);
|
||||
|
@ -743,11 +759,13 @@ void ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese
|
|||
|
||||
// Public
|
||||
|
||||
ConfigWizard::ConfigWizard(wxWindow *parent, bool fresh_start) :
|
||||
ConfigWizard::ConfigWizard(wxWindow *parent, bool startup, bool empty_datadir) :
|
||||
wxDialog(parent, wxID_ANY, name(), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
|
||||
p(new priv(this))
|
||||
{
|
||||
p->fresh_start = fresh_start;
|
||||
p->flag_startup = startup;
|
||||
p->flag_empty_datadir = empty_datadir;
|
||||
|
||||
p->load_vendors();
|
||||
p->custom_config.reset(DynamicPrintConfig::new_from_defaults_keys({
|
||||
"gcode_flavor", "bed_shape", "nozzle_diameter", "filament_diameter", "temperature", "bed_temperature",
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace GUI {
|
|||
class ConfigWizard: public wxDialog
|
||||
{
|
||||
public:
|
||||
ConfigWizard(wxWindow *parent, bool fresh_start);
|
||||
ConfigWizard(wxWindow *parent, bool startup, bool empty_datadir);
|
||||
ConfigWizard(ConfigWizard &&) = delete;
|
||||
ConfigWizard(const ConfigWizard &) = delete;
|
||||
ConfigWizard &operator=(ConfigWizard &&) = delete;
|
||||
|
|
|
@ -100,12 +100,14 @@ struct PageWelcome: ConfigWizardPage
|
|||
{
|
||||
PrinterPicker *printer_picker;
|
||||
wxPanel *others_buttons;
|
||||
wxCheckBox *cbox_reset;
|
||||
|
||||
PageWelcome(ConfigWizard *parent);
|
||||
|
||||
virtual wxPanel* extra_buttons() { return others_buttons; }
|
||||
virtual void on_page_set();
|
||||
|
||||
bool reset_user_profile() const { return cbox_reset->GetValue(); }
|
||||
void on_variant_checked();
|
||||
};
|
||||
|
||||
|
@ -188,9 +190,10 @@ private:
|
|||
struct ConfigWizard::priv
|
||||
{
|
||||
ConfigWizard *q;
|
||||
bool fresh_start;
|
||||
AppConfig appconfig_vendors; // TODO: use order-preserving container
|
||||
std::unordered_map<std::string, VendorProfile> vendors; // TODO: just set?
|
||||
bool flag_startup;
|
||||
bool flag_empty_datadir;
|
||||
AppConfig appconfig_vendors;
|
||||
std::unordered_map<std::string, VendorProfile> vendors;
|
||||
std::unordered_map<std::string, std::string> vendors_rsrc;
|
||||
std::unique_ptr<DynamicPrintConfig> custom_config;
|
||||
|
||||
|
|
|
@ -390,7 +390,7 @@ void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_l
|
|||
local_menu->Bind(wxEVT_MENU, [config_id_base, event_language_change, event_preferences_changed](wxEvent &event){
|
||||
switch (event.GetId() - config_id_base) {
|
||||
case ConfigMenuWizard:
|
||||
config_wizard(0);
|
||||
config_wizard(false, false);
|
||||
break;
|
||||
case ConfigMenuTakeSnapshot:
|
||||
// Take a configuration snapshot.
|
||||
|
@ -465,33 +465,35 @@ bool check_unsaved_changes()
|
|||
void config_wizard_startup(bool app_config_exists)
|
||||
{
|
||||
if (! app_config_exists || g_PresetBundle->has_defauls_only()) {
|
||||
config_wizard(true);
|
||||
config_wizard(true, true);
|
||||
} else if (g_AppConfig->legacy_datadir()) {
|
||||
// Looks like user has legacy pre-vendorbundle data directory,
|
||||
// explain what this is and run the wizard
|
||||
|
||||
const auto msg = _(L("Configuration update"));
|
||||
const auto ext_msg = _(L(
|
||||
"Slic3r PE now uses an updated configuration structure.\n\n"
|
||||
const auto ext_msg = wxString::Format(
|
||||
_(L(
|
||||
"Slic3r PE now uses an updated configuration structure.\n\n"
|
||||
|
||||
"So called 'System presets' have been introduced, which hold the built-in default settings for various "
|
||||
"printers. These System presets cannot be modified, instead, users now may create their"
|
||||
"own presets inheriting settings from one of the System presets.\n"
|
||||
"An inheriting preset may either inherit a particular value from its parent or override it with a customized value.\n\n"
|
||||
"So called 'System presets' have been introduced, which hold the built-in default settings for various "
|
||||
"printers. These System presets cannot be modified, instead, users now may create their"
|
||||
"own presets inheriting settings from one of the System presets.\n"
|
||||
"An inheriting preset may either inherit a particular value from its parent or override it with a customized value.\n\n"
|
||||
|
||||
// TODO: Assistant vs Wizard
|
||||
"Please proceed with the Configuration wizard that follows to set up the new presets "
|
||||
"and to choose whether to enable automatic preset updates."
|
||||
));
|
||||
"Please proceed with the %s that follows to set up the new presets "
|
||||
"and to choose whether to enable automatic preset updates."
|
||||
)),
|
||||
ConfigWizard::name()
|
||||
);
|
||||
wxMessageDialog dlg(NULL, msg, _(L("Configuration update")), wxOK|wxCENTRE);
|
||||
dlg.SetExtendedMessage(ext_msg);
|
||||
const auto res = dlg.ShowModal();
|
||||
|
||||
config_wizard(true);
|
||||
config_wizard(true, false);
|
||||
}
|
||||
}
|
||||
|
||||
void config_wizard(bool fresh_start) // TODO: fresh_start useful ?
|
||||
void config_wizard(bool startup, bool empty_datadir)
|
||||
{
|
||||
if (g_wxMainFrame == nullptr)
|
||||
throw std::runtime_error("Main frame not set");
|
||||
|
@ -500,8 +502,7 @@ void config_wizard(bool fresh_start) // TODO: fresh_start useful ?
|
|||
if (! check_unsaved_changes())
|
||||
return;
|
||||
|
||||
// TODO: Offer "reset user profile" ???
|
||||
ConfigWizard wizard(g_wxMainFrame, fresh_start);
|
||||
ConfigWizard wizard(g_wxMainFrame, startup, empty_datadir);
|
||||
wizard.run(g_PresetBundle, g_PresetUpdater);
|
||||
|
||||
// Load the currently selected preset into the GUI, update the preset selection box.
|
||||
|
|
|
@ -97,7 +97,7 @@ extern bool check_unsaved_changes();
|
|||
extern void config_wizard_startup(bool app_config_exists);
|
||||
|
||||
// Opens the configuration wizard, returns true if wizard is finished & accepted.
|
||||
extern void config_wizard(bool fresh_start);
|
||||
extern void config_wizard(bool startup, bool empty_datadir);
|
||||
|
||||
// Create "Preferences" dialog after selecting menu "Preferences" in Perl part
|
||||
extern void open_preferences_dialog(int event_preferences);
|
||||
|
|
|
@ -155,7 +155,7 @@ struct PresetUpdater::priv
|
|||
|
||||
void check_install_indices() const;
|
||||
Updates config_update() const;
|
||||
void perform_updates(Updates &&updates) const;
|
||||
void perform_updates(Updates &&updates, bool snapshot = true) const;
|
||||
};
|
||||
|
||||
PresetUpdater::priv::priv(int version_online_event) :
|
||||
|
@ -348,9 +348,11 @@ Updates PresetUpdater::priv::config_update() const
|
|||
return updates;
|
||||
}
|
||||
|
||||
void PresetUpdater::priv::perform_updates(Updates &&updates) const
|
||||
void PresetUpdater::priv::perform_updates(Updates &&updates, bool snapshot) const
|
||||
{
|
||||
SnapshotDB::singleton().take_snapshot(*GUI::get_app_config(), Snapshot::SNAPSHOT_UPGRADE);
|
||||
if (snapshot) {
|
||||
SnapshotDB::singleton().take_snapshot(*GUI::get_app_config(), Snapshot::SNAPSHOT_UPGRADE);
|
||||
}
|
||||
|
||||
for (const auto &update : updates) {
|
||||
fs::copy_file(update.source, update.target, fs::copy_option::overwrite_if_exists);
|
||||
|
@ -458,7 +460,7 @@ void PresetUpdater::config_update() const
|
|||
}
|
||||
}
|
||||
|
||||
void PresetUpdater::install_bundles_rsrc(std::vector<std::string> &&bundles)
|
||||
void PresetUpdater::install_bundles_rsrc(std::vector<std::string> &&bundles, bool snapshot)
|
||||
{
|
||||
Updates updates;
|
||||
|
||||
|
@ -468,7 +470,7 @@ void PresetUpdater::install_bundles_rsrc(std::vector<std::string> &&bundles)
|
|||
updates.emplace_back(std::move(path_in_rsrc), std::move(path_in_vendors));
|
||||
}
|
||||
|
||||
p->perform_updates(std::move(updates));
|
||||
p->perform_updates(std::move(updates), snapshot);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
void sync(PresetBundle *preset_bundle);
|
||||
void slic3r_update_notify();
|
||||
void config_update() const;
|
||||
void install_bundles_rsrc(std::vector<std::string> &&bundles);
|
||||
void install_bundles_rsrc(std::vector<std::string> &&bundles, bool snapshot = true);
|
||||
private:
|
||||
struct priv;
|
||||
std::unique_ptr<priv> p;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue