Marked string used at localization.

* Correct save changed color
This commit is contained in:
YuSanka 2018-02-15 17:30:33 +01:00
parent 39fae3777c
commit e0933786e3
13 changed files with 6149 additions and 946 deletions

Binary file not shown.

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -475,6 +475,16 @@ void ColourPicker::BUILD()
temp->SetToolTip(get_tooltip_text(clr)); temp->SetToolTip(get_tooltip_text(clr));
} }
boost::any ColourPicker::get_value(){
boost::any ret_val;
auto colour = static_cast<wxColourPickerCtrl*>(window)->GetColour();
auto clr_str = wxString::Format(wxT("#%02X%02X%02X"), colour.Red(), colour.Green(), colour.Blue());
ret_val = clr_str.ToStdString();
return ret_val;
}
void PointCtrl::BUILD() void PointCtrl::BUILD()
{ {
auto size = wxSize(wxDefaultSize); auto size = wxSize(wxDefaultSize);
@ -495,9 +505,9 @@ void PointCtrl::BUILD()
x_textctrl = new wxTextCtrl(m_parent, wxID_ANY, X, wxDefaultPosition, field_size); x_textctrl = new wxTextCtrl(m_parent, wxID_ANY, X, wxDefaultPosition, field_size);
y_textctrl = new wxTextCtrl(m_parent, wxID_ANY, Y, wxDefaultPosition, field_size); y_textctrl = new wxTextCtrl(m_parent, wxID_ANY, Y, wxDefaultPosition, field_size);
temp->Add(new wxStaticText(m_parent, wxID_ANY, "x : ")); temp->Add(new wxStaticText(m_parent, wxID_ANY, "x : "), 0, wxALIGN_CENTER_VERTICAL, 0);
temp->Add(x_textctrl); temp->Add(x_textctrl);
temp->Add(new wxStaticText(m_parent, wxID_ANY, " y : ")); temp->Add(new wxStaticText(m_parent, wxID_ANY, " y : "), 0, wxALIGN_CENTER_VERTICAL, 0);
temp->Add(y_textctrl); temp->Add(y_textctrl);
x_textctrl->Bind(wxEVT_TEXT, ([this](wxCommandEvent e) { on_change_field(); }), x_textctrl->GetId()); x_textctrl->Bind(wxEVT_TEXT, ([this](wxCommandEvent e) { on_change_field(); }), x_textctrl->GetId());

View file

@ -230,9 +230,7 @@ public:
m_disable_change_event = false; m_disable_change_event = false;
} }
boost::any get_value() override { boost::any get_value() override;
return boost::any(dynamic_cast<wxColourPickerCtrl*>(window)->GetColour());
}
void enable() override { dynamic_cast<wxColourPickerCtrl*>(window)->Enable(); }; void enable() override { dynamic_cast<wxColourPickerCtrl*>(window)->Enable(); };
void disable() override{ dynamic_cast<wxColourPickerCtrl*>(window)->Disable(); }; void disable() override{ dynamic_cast<wxColourPickerCtrl*>(window)->Disable(); };

View file

@ -227,13 +227,7 @@ bool select_language(wxArrayString & names,
g_wxLocale = new wxLocale; g_wxLocale = new wxLocale;
g_wxLocale->Init(identifiers[index]); g_wxLocale->Init(identifiers[index]);
g_wxLocale->AddCatalogLookupPathPrefix(wxPathOnly(localization_dir())); g_wxLocale->AddCatalogLookupPathPrefix(wxPathOnly(localization_dir()));
wxLogTrace(wxTraceMask(),
_L("Slic3rPE: Path Prefix = \"%s\""),
wxPathOnly(localization_dir()).GetData());
g_wxLocale->AddCatalog(g_wxApp->GetAppName()); g_wxLocale->AddCatalog(g_wxApp->GetAppName());
wxLogTrace(wxTraceMask(),
_L("Slic3rPE: Catalog Name = \"%s\""),
g_wxApp->GetAppName().GetData());
return true; return true;
} }
return false; return false;
@ -372,7 +366,8 @@ TabIface* get_preset_tab_iface(char *name)
return new TabIface(nullptr); return new TabIface(nullptr);
} }
void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, boost::any value) // opt_index = 0, by the reason of zero-index in ConfigOptionVector by default (in case only one element)
void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, boost::any value, int opt_index /*= 0*/)
{ {
try{ try{
switch (config.def()->get(opt_key)->type){ switch (config.def()->get(opt_key)->type){
@ -405,7 +400,7 @@ void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, b
} }
else{ else{
ConfigOptionStrings* vec_new = new ConfigOptionStrings{ boost::any_cast<std::string>(value) }; ConfigOptionStrings* vec_new = new ConfigOptionStrings{ boost::any_cast<std::string>(value) };
config.option<ConfigOptionStrings>(opt_key)->set_at(vec_new, 0, 0); config.option<ConfigOptionStrings>(opt_key)->set_at(vec_new, opt_index, opt_index);
} }
} }
break; break;
@ -414,14 +409,14 @@ void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, b
break; break;
case coBools:{ case coBools:{
ConfigOptionBools* vec_new = new ConfigOptionBools{ boost::any_cast<bool>(value) }; ConfigOptionBools* vec_new = new ConfigOptionBools{ boost::any_cast<bool>(value) };
config.option<ConfigOptionBools>(opt_key)->set_at(vec_new, 0, 0); config.option<ConfigOptionBools>(opt_key)->set_at(vec_new, opt_index, opt_index);
break;} break;}
case coInt: case coInt:
config.set_key_value(opt_key, new ConfigOptionInt(boost::any_cast<int>(value))); config.set_key_value(opt_key, new ConfigOptionInt(boost::any_cast<int>(value)));
break; break;
case coInts:{ case coInts:{
ConfigOptionInts* vec_new = new ConfigOptionInts{ boost::any_cast<int>(value) }; ConfigOptionInts* vec_new = new ConfigOptionInts{ boost::any_cast<int>(value) };
config.option<ConfigOptionInts>(opt_key)->set_at(vec_new, 0, 0); config.option<ConfigOptionInts>(opt_key)->set_at(vec_new, opt_index, opt_index);
} }
break; break;
case coEnum:{ case coEnum:{

View file

@ -69,7 +69,7 @@ TabIface* get_preset_tab_iface(char *name);
// add it at the end of the tab panel. // add it at the end of the tab panel.
void add_created_tab(Tab* panel, PresetBundle *preset_bundle, AppConfig *app_config); void add_created_tab(Tab* panel, PresetBundle *preset_bundle, AppConfig *app_config);
// Change option value in config // Change option value in config
void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, boost::any value); void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, boost::any value, int opt_index = 0);
void show_error(wxWindow* parent, wxString message); void show_error(wxWindow* parent, wxString message);
void show_info(wxWindow* parent, wxString message, wxString title); void show_info(wxWindow* parent, wxString message, wxString title);

View file

@ -178,7 +178,7 @@ void OptionsGroup::append_line(const Line& line) {
if (opt.opt_id != option_set.back().opt_id) //! istead of (opt != option_set.back()) if (opt.opt_id != option_set.back().opt_id) //! istead of (opt != option_set.back())
{ {
sizer->AddSpacer(4); sizer->AddSpacer(6);
} }
} }
// add extra sizers if any // add extra sizers if any
@ -248,6 +248,7 @@ void ConfigOptionsGroup::on_change_OG(t_config_option_key opt_id, boost::any val
change_opt_value(*m_config, opt_key, value); change_opt_value(*m_config, opt_key, value);
} }
else { else {
change_opt_value(*m_config, opt_key, value, opt_index);
// auto value = m_config->get($opt_key); // auto value = m_config->get($opt_key);
// $value->[$opt_index] = $field_value; // $value->[$opt_index] = $field_value;
// $self->config->set($opt_key, $value); // $self->config->set($opt_key, $value);
@ -266,6 +267,7 @@ void ConfigOptionsGroup::reload_config(){
auto option = m_options.at(opt_id).opt; auto option = m_options.at(opt_id).opt;
set_value(opt_id, config_value(opt_key, opt_index, option.gui_flags.compare("serialized") == 0 )); set_value(opt_id, config_value(opt_key, opt_index, option.gui_flags.compare("serialized") == 0 ));
} }
} }
boost::any ConfigOptionsGroup::config_value(std::string opt_key, int opt_index, bool deserialize){ boost::any ConfigOptionsGroup::config_value(std::string opt_key, int opt_index, bool deserialize){
@ -395,5 +397,14 @@ void ogStaticText::SetText(wxString value)
GetParent()->Layout(); GetParent()->Layout();
} }
void Option::translate()
{
opt.label = _LU8(opt.label);
opt.tooltip = _LU8(opt.tooltip);
opt.sidetext = _LU8(opt.sidetext);
opt.full_label = _LU8(opt.full_label);
opt.category = _LU8(opt.category);
}
} // GUI } // GUI
} // Slic3r } // Slic3r

View file

@ -34,8 +34,9 @@ struct Option {
widget_t side_widget {nullptr}; widget_t side_widget {nullptr};
bool readonly {false}; bool readonly {false};
Option(const ConfigOptionDef& _opt, t_config_option_key id) : Option(const ConfigOptionDef& _opt, t_config_option_key id) :
opt(_opt), opt_id(id) {} opt(_opt), opt_id(id) { translate(); }
void translate();
}; };
using t_option = std::unique_ptr<Option>; //! using t_option = std::unique_ptr<Option>; //!

View file

@ -226,7 +226,7 @@ void Tab::reload_config(){
Freeze(); Freeze();
for (auto page : m_pages) for (auto page : m_pages)
page->reload_config(); page->reload_config();
Thaw(); Thaw();
} }
Field* Tab::get_field(t_config_option_key opt_key, int opt_index/* = -1*/) const Field* Tab::get_field(t_config_option_key opt_key, int opt_index/* = -1*/) const
@ -1233,7 +1233,6 @@ void TabPrinter::build_extruder_pages(){
for (auto page_extruder : m_extruder_pages) for (auto page_extruder : m_extruder_pages)
m_pages.push_back(page_extruder); m_pages.push_back(page_extruder);
m_pages.push_back(page_note); m_pages.push_back(page_note);
rebuild_page_tree(); rebuild_page_tree();
} }