From dc7373514d6f694cfeb5820501717e242cbd22e6 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 2 Mar 2023 10:16:09 +0100 Subject: [PATCH] Fixed localization of the tooltips for settings parameters (follow-up https://github.com/Prusa-Development/PrusaSlicerPrivate/commit/6238595a) --- src/libslic3r/PrintConfig.cpp | 33 +++++---------------------------- src/slic3r/GUI/Field.cpp | 14 +++++--------- src/slic3r/GUI/OptionsGroup.cpp | 19 ++++++++++++++++--- src/slic3r/GUI/OptionsGroup.hpp | 3 +-- 4 files changed, 27 insertions(+), 42 deletions(-) diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 878acc10a..76fddebc4 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -3270,9 +3270,6 @@ void PrintConfigDef::init_sla_support_params(const std::string &prefix) { ConfigOptionDef* def; - constexpr const char * pretext_unavailable = L("Unavailable for this method.\n"); - std::string pretext; - def = this->add(prefix + "support_head_front_diameter", coFloat); def->label = L("Pinhead front diameter"); def->category = L("Supports"); @@ -3322,13 +3319,9 @@ void PrintConfigDef::init_sla_support_params(const std::string &prefix) def->mode = comExpert; def->set_default_value(new ConfigOptionPercent(50)); - pretext = ""; - if (prefix == "branching") - pretext = pretext_unavailable; - def = this->add(prefix + "support_max_bridges_on_pillar", coInt); def->label = L("Max bridges on a pillar"); - def->tooltip = pretext + L( + def->tooltip = L( "Maximum number of bridges that can be placed on a pillar. Bridges " "hold support point pinheads and connect to pillars as small branches."); def->min = 0; @@ -3336,14 +3329,10 @@ void PrintConfigDef::init_sla_support_params(const std::string &prefix) def->mode = comExpert; def->set_default_value(new ConfigOptionInt(prefix == "branching" ? 2 : 3)); - pretext = ""; - if (prefix.empty()) - pretext = pretext_unavailable; - def = this->add(prefix + "support_max_weight_on_model", coFloat); def->label = L("Max weight on model"); def->category = L("Supports"); - def->tooltip = pretext + L( + def->tooltip = L( "Maximum weight of sub-trees that terminate on the model instead of the print bed. The weight is the sum of the lenghts of all " "branches emanating from the endpoint."); def->sidetext = L("mm"); @@ -3351,13 +3340,9 @@ void PrintConfigDef::init_sla_support_params(const std::string &prefix) def->mode = comExpert; def->set_default_value(new ConfigOptionFloat(10.)); - pretext = ""; - if (prefix == "branching") - pretext = pretext_unavailable; - def = this->add(prefix + "support_pillar_connection_mode", coEnum); def->label = L("Pillar connection mode"); - def->tooltip = pretext + L("Controls the bridge type between two neighboring pillars." + def->tooltip = L("Controls the bridge type between two neighboring pillars." " Can be zig-zag, cross (double zig-zag) or dynamic which" " will automatically switch between the first two depending" " on the distance of the two pillars."); @@ -3378,11 +3363,7 @@ void PrintConfigDef::init_sla_support_params(const std::string &prefix) def->label = L("Pillar widening factor"); def->category = L("Supports"); - pretext = ""; - if (prefix.empty()) - pretext = pretext_unavailable; - - def->tooltip = pretext + + def->tooltip = L("Merging bridges or pillars into another pillars can " "increase the radius. Zero means no increase, one means " "full increase. The exact amount of increase is unspecified and can " @@ -3449,14 +3430,10 @@ void PrintConfigDef::init_sla_support_params(const std::string &prefix) def->set_default_value(new ConfigOptionFloat(default_val)); - pretext = ""; - if (prefix == "branching") - pretext = pretext_unavailable; - def = this->add(prefix + "support_max_pillar_link_distance", coFloat); def->label = L("Max pillar linking distance"); def->category = L("Supports"); - def->tooltip = pretext + L("The max distance of two pillars to get linked with each other." + def->tooltip = L("The max distance of two pillars to get linked with each other." " A zero value will prohibit pillar cascading."); def->sidetext = L("mm"); def->min = 0; // 0 means no linking diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index 13a9e6e07..ffd5a6bc3 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -175,24 +175,20 @@ void Field::on_back_to_sys_value() wxString Field::get_tooltip_text(const wxString& default_string) { - wxString tooltip_text(""); - wxString tooltip = _(m_opt.tooltip); - edit_tooltip(tooltip); + if (m_opt.tooltip.empty()) + return ""; std::string opt_id = m_opt_id; - auto hash_pos = opt_id.find("#"); + auto hash_pos = opt_id.find('#'); if (hash_pos != std::string::npos) { opt_id.replace(hash_pos, 1,"["); opt_id += "]"; } - if (tooltip.length() > 0) - tooltip_text = tooltip + "\n" + _(L("default value")) + "\t: " + + return from_u8(m_opt.tooltip) + "\n" + _L("default value") + "\t: " + (boost::iends_with(opt_id, "_gcode") ? "\n" : "") + default_string + (boost::iends_with(opt_id, "_gcode") ? "" : "\n") + - _(L("parameter name")) + "\t: " + opt_id; - - return tooltip_text; + _L("parameter name") + "\t: " + opt_id; } bool Field::is_matched(const std::string& string, const std::string& pattern) diff --git a/src/slic3r/GUI/OptionsGroup.cpp b/src/slic3r/GUI/OptionsGroup.cpp index 688570f90..e567ac7c6 100644 --- a/src/slic3r/GUI/OptionsGroup.cpp +++ b/src/slic3r/GUI/OptionsGroup.cpp @@ -118,6 +118,20 @@ OptionsGroup::OptionsGroup( wxWindow* _parent, const wxString& title, { } +Option::Option(const ConfigOptionDef& _opt, t_config_option_key id) : opt(_opt), opt_id(id) +{ + if (!opt.tooltip.empty()) { + wxString tooltip; + if (opt.opt_key.rfind("branching", 0) == 0) + tooltip = _L("Unavailable for this method.") + "\n"; + tooltip += _(opt.tooltip); + + edit_tooltip(tooltip); + + opt.tooltip = into_u8(tooltip); + } +} + void Line::clear() { if (near_label_widget_win) @@ -517,9 +531,8 @@ void OptionsGroup::clear(bool destroy_custom_ctrl) Line OptionsGroup::create_single_option_line(const Option& option, const std::string& path/* = std::string()*/) const { - wxString tooltip = _(option.opt.tooltip); - edit_tooltip(tooltip); - Line retval{ _(option.opt.label), tooltip }; + Line retval{ _(option.opt.label), from_u8(option.opt.tooltip) }; + retval.label_path = path; retval.append_option(option); return retval; diff --git a/src/slic3r/GUI/OptionsGroup.hpp b/src/slic3r/GUI/OptionsGroup.hpp index 88d0ff8bf..f754505dd 100644 --- a/src/slic3r/GUI/OptionsGroup.hpp +++ b/src/slic3r/GUI/OptionsGroup.hpp @@ -47,8 +47,7 @@ struct Option { return (rhs.opt_id == this->opt_id); } - Option(const ConfigOptionDef& _opt, t_config_option_key id) : - opt(_opt), opt_id(id) {} + Option(const ConfigOptionDef& _opt, t_config_option_key id); }; using t_option = std::unique_ptr