From 16104587ac097630a9ee79c59ecedb4a9fbab2f9 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Thu, 1 Jul 2021 16:48:38 +0200 Subject: [PATCH] Improvement in the subtitution information dialog. --- src/libslic3r/Config.hpp | 6 ++-- src/slic3r/GUI/GUI.cpp | 53 ++++++++++++++++++++---------------- src/slic3r/GUI/MsgDialog.cpp | 4 +-- src/slic3r/GUI/Plater.cpp | 2 +- 4 files changed, 35 insertions(+), 30 deletions(-) diff --git a/src/libslic3r/Config.hpp b/src/libslic3r/Config.hpp index a3d86d1453..84f1a8c000 100644 --- a/src/libslic3r/Config.hpp +++ b/src/libslic3r/Config.hpp @@ -97,13 +97,13 @@ namespace ConfigHelpers { return boost::iequals(value, "enabled") || boost::iequals(value, "on"); } - enum DeserializationSubstitution { + enum class DeserializationSubstitution { Disabled, DefaultsToFalse, DefaultsToTrue }; - enum DeserializationResult { + enum class DeserializationResult { Loaded, Substituted, Failed, @@ -1451,7 +1451,7 @@ public: } else if (item_str == "0") { new_value = false; } else if (substitution != ConfigHelpers::DeserializationSubstitution::Disabled && ConfigHelpers::looks_like_enum_value(item_str)) { - new_value = ConfigHelpers::enum_looks_like_true_value(item_str) || substituted == ConfigHelpers::DeserializationSubstitution::DefaultsToTrue; + new_value = ConfigHelpers::enum_looks_like_true_value(item_str) || substitution == ConfigHelpers::DeserializationSubstitution::DefaultsToTrue; substituted = true; } else return ConfigHelpers::DeserializationResult::Failed; diff --git a/src/slic3r/GUI/GUI.cpp b/src/slic3r/GUI/GUI.cpp index 17a46d3695..cfc5c13617 100644 --- a/src/slic3r/GUI/GUI.cpp +++ b/src/slic3r/GUI/GUI.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #if __APPLE__ @@ -245,7 +246,12 @@ void warning_catcher(wxWindow* parent, const wxString& message) msg.ShowModal(); } -static wxString bold(const wxString& str) +static wxString bold(const wxString& str) +{ + return wxString::Format("%s", str); +}; + +static wxString bold_string(const wxString& str) { return wxString::Format("\"%s\"", str); }; @@ -277,14 +283,17 @@ static void add_config_substitutions(const ConfigSubstitutions& conf_substitutio auto it = std::find(values.begin(), values.end(), key_val.first); if (it == values.end()) break; - new_val = from_u8(_utf8(labels[it - values.begin()])); + auto idx = it - values.begin(); + new_val = wxString("\"") + values[idx] + "\"" + " (" + from_u8(_utf8(labels[idx])) + ")"; break; } - if (new_val.IsEmpty()) - new_val = _L("Undef"); + if (new_val.IsEmpty()) { + assert(false); + new_val = _L("Undefined"); + } } else - new_val = from_u8(_utf8(labels[val])); + new_val = wxString("\"") + values[val] + "\"" + " (" + from_u8(_utf8(labels[val])) + ")"; break; } case coBool: @@ -304,13 +313,21 @@ static void add_config_substitutions(const ConfigSubstitutions& conf_substitutio assert(false); } - changes += "" + bold(_(def->label)) + ": " + - format_wxstr(_L("new unknown value %1% was changed to default value %2%"), bold(conf_substitution.old_value), bold(new_val)) + + changes += format_wxstr("\"%1%\" (%2%): ", def->opt_key, _(def->label)) + + format_wxstr(_L("%1% was substituted with %2%"), bold_string(conf_substitution.old_value), bold(new_val)) + ""; } changes += ""; } +static wxString substitution_message(const wxString& changes) +{ + return + _L("Most likely the configuration was produced by a newer version of PrusaSlicer or by some PrusaSlicer fork.") + " " + + _L("The following values were substituted:") + "\n" + changes + "\n\n" + + _L("Please review the substitutions and adjust them if needed."); +} + void show_substitutions_info(const PresetsConfigSubstitutions& presets_config_substitutions) { wxString changes; @@ -328,37 +345,25 @@ void show_substitutions_info(const PresetsConfigSubstitutions& presets_config_su }; for (const PresetConfigSubstitutions& substitution : presets_config_substitutions) { - changes += "\n\n" + format_wxstr("%1% : %2%", preset_type_name(substitution.preset_type), bold(substitution.preset_name)); + changes += "\n\n" + format_wxstr("%1% : %2%", preset_type_name(substitution.preset_type), bold_string(substitution.preset_name)); if (!substitution.preset_file.empty()) changes += format_wxstr(" (%1%)", substitution.preset_file); add_config_substitutions(substitution.substitutions, changes); } - if (!changes.IsEmpty()) - changes += "\n\n"; - wxString message = format_wxstr( _L("Loading profiles found following incompatibilities:%1%" - " To recover these files, incompatible values were changed to default values.\n" - " But data in files won't be changed until you save them in PrusaSlicer."), changes); - - InfoDialog msg(nullptr, message); + InfoDialog msg(nullptr, _L("Configuration bundle was loaded, however some configuration values were not recognized."), substitution_message(changes)); msg.ShowModal(); } void show_substitutions_info(const ConfigSubstitutions& config_substitutions, const std::string& filename) { wxString changes = "\n"; - add_config_substitutions(config_substitutions, changes); - if (!changes.IsEmpty()) - changes += "\n\n"; - - wxString message = format(_L("Loading %1% file found incompatibilities.\n" - "To recover this file, incompatible values were changed to default values:%2%" - "But data in files won't be changed until you save them in PrusaSlicer."), bold(from_u8(filename)), changes); - - InfoDialog msg(nullptr, message); + InfoDialog msg(nullptr, + format_wxstr(_L("Configuration file \"%1%\" was loaded, however some configuration values were not recognized."), from_u8(filename)), + substitution_message(changes)); msg.ShowModal(); } diff --git a/src/slic3r/GUI/MsgDialog.cpp b/src/slic3r/GUI/MsgDialog.cpp index 1e05ab8f15..41846500de 100644 --- a/src/slic3r/GUI/MsgDialog.cpp +++ b/src/slic3r/GUI/MsgDialog.cpp @@ -214,8 +214,8 @@ MessageDialog::MessageDialog(wxWindow* parent, // InfoDialog -InfoDialog::InfoDialog(wxWindow* parent, const wxString& msg) - : MsgDialog(parent, wxString::Format(_L("%s information"), SLIC3R_APP_NAME), _L("Note that")) +InfoDialog::InfoDialog(wxWindow* parent, const wxString &title, const wxString& msg) + : MsgDialog(parent, wxString::Format(_L("%s information"), SLIC3R_APP_NAME), title) , msg(msg) { this->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index d3149a2571..22a1b36ae0 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -5310,7 +5310,7 @@ void Plater::export_gcode(bool prefer_removable) GUI::file_wildcards((printer_technology() == ptFFF) ? FT_GCODE : boost::iequals(ext, ".sl1s") ? FT_SL1S : FT_SL1, ext), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); - if (dlg.ShowModal() == wxID_OK) + if (dlg.ShowModal() == wxID_OK) output_path = into_path(dlg.GetPath()); }