diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index a50363131..2204ab03c 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -69,7 +69,9 @@ our $grey = Wx::Colour->new(200,200,200); # Events to be sent from a C++ menu implementation: # 1) To inform about a change of the application language. -our $LANGUAGE_CHANGE_EVENT = Wx::NewEventType; +our $LANGUAGE_CHANGE_EVENT = Wx::NewEventType; +# 2) To inform about a change of Preferences. +our $PREFERENCES_EVENT = Wx::NewEventType; sub OnInit { my ($self) = @_; @@ -122,6 +124,7 @@ sub OnInit { no_controller => $self->{app_config}->get('no_controller'), no_plater => $no_plater, lang_ch_event => $LANGUAGE_CHANGE_EVENT, + preferences_event => $PREFERENCES_EVENT, ); $self->SetTopWindow($frame); @@ -146,6 +149,11 @@ sub OnInit { EVT_COMMAND($self, -1, $LANGUAGE_CHANGE_EVENT, sub{ $self->recreate_GUI; }); + + # The following event is emited by the C++ menu implementation of preferences change. + EVT_COMMAND($self, -1, $PREFERENCES_EVENT, sub{ + $self->update_ui_from_settings; + }); return 1; } @@ -158,6 +166,7 @@ sub recreate_GUI{ no_controller => $self->{app_config}->get('no_controller'), no_plater => $no_plater, lang_ch_event => $LANGUAGE_CHANGE_EVENT, + preferences_event => $PREFERENCES_EVENT, ); if($topwindow) diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm index 76920c17f..1b05218cd 100644 --- a/lib/Slic3r/GUI/MainFrame.pm +++ b/lib/Slic3r/GUI/MainFrame.pm @@ -50,6 +50,7 @@ sub new { $self->{no_plater} = $params{no_plater}; $self->{loaded} = 0; $self->{lang_ch_event} = $params{lang_ch_event}; + $self->{preferences_event} = $params{preferences_event}; # initialize tabpanel and menubar $self->_init_tabpanel; @@ -296,7 +297,9 @@ sub _init_menubar { $fileMenu->AppendSeparator(); # Cmd+, is standard on OS X - what about other operating systems? $self->_append_menu_item($fileMenu, L("Preferences…\tCtrl+,"), L('Application preferences'), sub { - Slic3r::GUI::Preferences->new($self)->ShowModal; + # Slic3r::GUI::Preferences->new($self)->ShowModal; + # It's in C++ part now + Slic3r::GUI::open_preferences_dialog($self->{preferences_event}); }, wxID_PREFERENCES); $fileMenu->AppendSeparator(); $self->_append_menu_item($fileMenu, L("&Quit"), L('Quit Slic3r'), sub { diff --git a/resources/localization/uk/Slic3rPE.mo b/resources/localization/uk/Slic3rPE.mo index ff041bdee..1aea46283 100644 Binary files a/resources/localization/uk/Slic3rPE.mo and b/resources/localization/uk/Slic3rPE.mo differ diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 394aca9ad..8c0f696e9 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -44,6 +44,7 @@ #include "TabIface.hpp" #include "AppConfig.hpp" #include "Utils.hpp" +#include "Preferences.hpp" namespace Slic3r { namespace GUI { @@ -342,6 +343,12 @@ void add_debug_menu(wxMenuBar *menu, int event_language_change) //#endif } +void open_preferences_dialog(int event_preferences) +{ + auto dlg = new PreferencesDialog(g_wxMainFrame, event_preferences); + dlg->ShowModal(); +} + void create_preset_tabs(PresetBundle *preset_bundle, bool no_controller, bool is_disabled_button_browse, bool is_user_agent, int event_value_change, int event_presets_changed, @@ -487,6 +494,13 @@ void show_info(wxWindow* parent, wxString message, wxString title){ msg_wingow->ShowModal(); } +void warning_catcher(wxWindow* parent, wxString message){ + if (message == _L("GLUquadricObjPtr | Attempt to free unreferenced scalar") ) + return; + auto msg = new wxMessageDialog(parent, message, _L("Warning"), wxOK | wxICON_WARNING); + msg->ShowModal(); +} + wxApp* get_app(){ return g_wxApp; } @@ -536,4 +550,9 @@ int combochecklist_get_flags(wxComboCtrl* comboCtrl) return flags; } +AppConfig* get_app_config() +{ + return g_AppConfig; +} + } } diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index 2ffacbc28..69a0f342c 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -66,7 +66,14 @@ void set_main_frame(wxFrame *main_frame); void set_tab_panel(wxNotebook *tab_panel); void set_app_config(AppConfig *app_config); +AppConfig* get_app_config(); +wxApp* get_app(); + void add_debug_menu(wxMenuBar *menu, int event_language_change); + +// Create "Preferences" dialog after selecting menu "Preferences" in Perl part +void open_preferences_dialog(int event_preferences); + // Create a new preset tab (print, filament and printer), void create_preset_tabs(PresetBundle *preset_bundle, bool no_controller, bool is_disabled_button_browse, bool is_user_agent, @@ -81,6 +88,7 @@ void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, b void show_error(wxWindow* parent, wxString message); void show_info(wxWindow* parent, wxString message, wxString title); +void warning_catcher(wxWindow* parent, wxString message); // load language saved at application config bool load_language(); diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index db23a1874..95eb83e87 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -904,7 +904,7 @@ void TabFilament::update() void TabFilament::OnActivate() { - m_volumetric_speed_description_line->SetText(PresetHints::maximum_volumetric_flow_description(*m_preset_bundle)); + m_volumetric_speed_description_line->SetText(wxString::FromUTF8(PresetHints::maximum_volumetric_flow_description(*m_preset_bundle).c_str())); } wxSizer* Tab::description_line_widget(wxWindow* parent, ogStaticText* *StaticText) diff --git a/xs/xsp/GUI.xsp b/xs/xsp/GUI.xsp index ad4dd7550..cae480c2f 100644 --- a/xs/xsp/GUI.xsp +++ b/xs/xsp/GUI.xsp @@ -58,3 +58,6 @@ int combochecklist_get_flags(SV *ui) void set_app_config(AppConfig *app_config) %code%{ Slic3r::GUI::set_app_config(app_config); %}; + +void open_preferences_dialog(int preferences_event) + %code%{ Slic3r::GUI::open_preferences_dialog(preferences_event); %};