Language configuration is saved now in AppConfig instead of wxConfig.
This commit is contained in:
parent
f5ae470e5e
commit
6ad38f80fb
@ -84,7 +84,6 @@ sub OnInit {
|
|||||||
# Mac: "~/Library/Application Support/Slic3r"
|
# Mac: "~/Library/Application Support/Slic3r"
|
||||||
Slic3r::set_data_dir($datadir || Wx::StandardPaths::Get->GetUserDataDir);
|
Slic3r::set_data_dir($datadir || Wx::StandardPaths::Get->GetUserDataDir);
|
||||||
Slic3r::GUI::set_wxapp($self);
|
Slic3r::GUI::set_wxapp($self);
|
||||||
Slic3r::GUI::load_language();
|
|
||||||
|
|
||||||
$self->{notifier} = Slic3r::GUI::Notifier->new;
|
$self->{notifier} = Slic3r::GUI::Notifier->new;
|
||||||
$self->{app_config} = Slic3r::GUI::AppConfig->new;
|
$self->{app_config} = Slic3r::GUI::AppConfig->new;
|
||||||
@ -103,6 +102,9 @@ sub OnInit {
|
|||||||
$self->{app_config}->set('version', $Slic3r::VERSION);
|
$self->{app_config}->set('version', $Slic3r::VERSION);
|
||||||
$self->{app_config}->save;
|
$self->{app_config}->save;
|
||||||
|
|
||||||
|
Slic3r::GUI::set_app_config($self->{app_config});
|
||||||
|
Slic3r::GUI::load_language();
|
||||||
|
|
||||||
# Suppress the '- default -' presets.
|
# Suppress the '- default -' presets.
|
||||||
$self->{preset_bundle}->set_default_suppressed($self->{app_config}->get('no_defaults') ? 1 : 0);
|
$self->{preset_bundle}->set_default_suppressed($self->{app_config}->get('no_defaults') ? 1 : 0);
|
||||||
eval { $self->{preset_bundle}->load_presets };
|
eval { $self->{preset_bundle}->load_presets };
|
||||||
|
@ -216,8 +216,8 @@ sub _init_tabpanel {
|
|||||||
$self->{is_disabled_button_browse} = (!eval "use Net::Bonjour; 1") ? 1 : 0 ;
|
$self->{is_disabled_button_browse} = (!eval "use Net::Bonjour; 1") ? 1 : 0 ;
|
||||||
# A variable to inform C++ Tab implementation about user_agent
|
# A variable to inform C++ Tab implementation about user_agent
|
||||||
$self->{is_user_agent} = (eval "use LWP::UserAgent; 1") ? 1 : 0 ;
|
$self->{is_user_agent} = (eval "use LWP::UserAgent; 1") ? 1 : 0 ;
|
||||||
Slic3r::GUI::create_preset_tabs(wxTheApp->{preset_bundle}, wxTheApp->{app_config},
|
Slic3r::GUI::create_preset_tabs(wxTheApp->{preset_bundle}, $self->{no_controller},
|
||||||
$self->{no_controller}, $self->{is_disabled_button_browse},
|
$self->{is_disabled_button_browse},
|
||||||
$self->{is_user_agent},
|
$self->{is_user_agent},
|
||||||
$VALUE_CHANGE_EVENT, $PRESETS_CHANGED_EVENT,
|
$VALUE_CHANGE_EVENT, $PRESETS_CHANGED_EVENT,
|
||||||
$BUTTON_BROWSE_EVENT, $BUTTON_TEST_EVENT);
|
$BUTTON_BROWSE_EVENT, $BUTTON_TEST_EVENT);
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
|
|
||||||
#include <wx/app.h>
|
#include <wx/app.h>
|
||||||
#include <wx/button.h>
|
#include <wx/button.h>
|
||||||
#include <wx/config.h>
|
|
||||||
#include <wx/dir.h>
|
#include <wx/dir.h>
|
||||||
#include <wx/filename.h>
|
#include <wx/filename.h>
|
||||||
#include <wx/frame.h>
|
#include <wx/frame.h>
|
||||||
@ -171,6 +170,7 @@ void break_to_debugger()
|
|||||||
wxApp *g_wxApp = nullptr;
|
wxApp *g_wxApp = nullptr;
|
||||||
wxFrame *g_wxMainFrame = nullptr;
|
wxFrame *g_wxMainFrame = nullptr;
|
||||||
wxNotebook *g_wxTabPanel = nullptr;
|
wxNotebook *g_wxTabPanel = nullptr;
|
||||||
|
AppConfig *g_AppConfig = nullptr;
|
||||||
|
|
||||||
std::vector<Tab *> g_tabs_list;
|
std::vector<Tab *> g_tabs_list;
|
||||||
|
|
||||||
@ -191,6 +191,11 @@ void set_tab_panel(wxNotebook *tab_panel)
|
|||||||
g_wxTabPanel = tab_panel;
|
g_wxTabPanel = tab_panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_app_config(AppConfig *app_config)
|
||||||
|
{
|
||||||
|
g_AppConfig = app_config;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<Tab *>& get_tabs_list()
|
std::vector<Tab *>& get_tabs_list()
|
||||||
{
|
{
|
||||||
return g_tabs_list;
|
return g_tabs_list;
|
||||||
@ -241,13 +246,14 @@ bool select_language(wxArrayString & names,
|
|||||||
|
|
||||||
bool load_language()
|
bool load_language()
|
||||||
{
|
{
|
||||||
wxConfig config(g_wxApp->GetAppName());
|
|
||||||
long language;
|
long language;
|
||||||
if (!config.Read(wxT("wxTranslation_Language"),
|
if (!g_AppConfig->has("translation_language"))
|
||||||
&language, wxLANGUAGE_UNKNOWN))
|
|
||||||
{
|
|
||||||
language = wxLANGUAGE_UNKNOWN;
|
language = wxLANGUAGE_UNKNOWN;
|
||||||
|
else {
|
||||||
|
auto str_language = g_AppConfig->get("translation_language");
|
||||||
|
language = str_language != "" ? stol(str_language) : wxLANGUAGE_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (language == wxLANGUAGE_UNKNOWN)
|
if (language == wxLANGUAGE_UNKNOWN)
|
||||||
return false;
|
return false;
|
||||||
wxArrayString names;
|
wxArrayString names;
|
||||||
@ -269,13 +275,13 @@ bool load_language()
|
|||||||
|
|
||||||
void save_language()
|
void save_language()
|
||||||
{
|
{
|
||||||
wxConfig config(g_wxApp->GetAppName());
|
|
||||||
long language = wxLANGUAGE_UNKNOWN;
|
long language = wxLANGUAGE_UNKNOWN;
|
||||||
if (g_wxLocale) {
|
if (g_wxLocale) {
|
||||||
language = g_wxLocale->GetLanguage();
|
language = g_wxLocale->GetLanguage();
|
||||||
}
|
}
|
||||||
config.Write(wxT("wxTranslation_Language"), language);
|
std::string str_language = std::to_string(language);
|
||||||
config.Flush();
|
g_AppConfig->set("translation_language", str_language);
|
||||||
|
g_AppConfig->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_installed_languages(wxArrayString & names,
|
void get_installed_languages(wxArrayString & names,
|
||||||
@ -336,15 +342,15 @@ void add_debug_menu(wxMenuBar *menu, int event_language_change)
|
|||||||
//#endif
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void create_preset_tabs(PresetBundle *preset_bundle, AppConfig *app_config,
|
void create_preset_tabs(PresetBundle *preset_bundle,
|
||||||
bool no_controller, bool is_disabled_button_browse, bool is_user_agent,
|
bool no_controller, bool is_disabled_button_browse, bool is_user_agent,
|
||||||
int event_value_change, int event_presets_changed,
|
int event_value_change, int event_presets_changed,
|
||||||
int event_button_browse, int event_button_test)
|
int event_button_browse, int event_button_test)
|
||||||
{
|
{
|
||||||
add_created_tab(new TabPrint (g_wxTabPanel, no_controller), preset_bundle, app_config);
|
add_created_tab(new TabPrint (g_wxTabPanel, no_controller), preset_bundle);
|
||||||
add_created_tab(new TabFilament (g_wxTabPanel, no_controller), preset_bundle, app_config);
|
add_created_tab(new TabFilament (g_wxTabPanel, no_controller), preset_bundle);
|
||||||
add_created_tab(new TabPrinter (g_wxTabPanel, no_controller, is_disabled_button_browse, is_user_agent),
|
add_created_tab(new TabPrinter (g_wxTabPanel, no_controller, is_disabled_button_browse, is_user_agent),
|
||||||
preset_bundle, app_config);
|
preset_bundle);
|
||||||
for (size_t i = 0; i < g_wxTabPanel->GetPageCount(); ++ i) {
|
for (size_t i = 0; i < g_wxTabPanel->GetPageCount(); ++ i) {
|
||||||
Tab *tab = dynamic_cast<Tab*>(g_wxTabPanel->GetPage(i));
|
Tab *tab = dynamic_cast<Tab*>(g_wxTabPanel->GetPage(i));
|
||||||
if (! tab)
|
if (! tab)
|
||||||
@ -455,9 +461,9 @@ void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, b
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_created_tab(Tab* panel, PresetBundle *preset_bundle, AppConfig *app_config)
|
void add_created_tab(Tab* panel, PresetBundle *preset_bundle)
|
||||||
{
|
{
|
||||||
panel->m_show_btn_incompatible_presets = app_config->get("show_incompatible_presets").empty();
|
panel->m_show_btn_incompatible_presets = g_AppConfig->get("show_incompatible_presets").empty();
|
||||||
panel->create_preset_tab(preset_bundle);
|
panel->create_preset_tab(preset_bundle);
|
||||||
|
|
||||||
// Load the currently selected preset into the GUI, update the preset selection box.
|
// Load the currently selected preset into the GUI, update the preset selection box.
|
||||||
|
@ -64,17 +64,18 @@ void break_to_debugger();
|
|||||||
void set_wxapp(wxApp *app);
|
void set_wxapp(wxApp *app);
|
||||||
void set_main_frame(wxFrame *main_frame);
|
void set_main_frame(wxFrame *main_frame);
|
||||||
void set_tab_panel(wxNotebook *tab_panel);
|
void set_tab_panel(wxNotebook *tab_panel);
|
||||||
|
void set_app_config(AppConfig *app_config);
|
||||||
|
|
||||||
void add_debug_menu(wxMenuBar *menu, int event_language_change);
|
void add_debug_menu(wxMenuBar *menu, int event_language_change);
|
||||||
// Create a new preset tab (print, filament and printer),
|
// Create a new preset tab (print, filament and printer),
|
||||||
void create_preset_tabs(PresetBundle *preset_bundle, AppConfig *app_config,
|
void create_preset_tabs(PresetBundle *preset_bundle,
|
||||||
bool no_controller, bool is_disabled_button_browse, bool is_user_agent,
|
bool no_controller, bool is_disabled_button_browse, bool is_user_agent,
|
||||||
int event_value_change, int event_presets_changed,
|
int event_value_change, int event_presets_changed,
|
||||||
int event_button_browse, int event_button_test);
|
int event_button_browse, int event_button_test);
|
||||||
TabIface* get_preset_tab_iface(char *name);
|
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);
|
||||||
// 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, int opt_index = 0);
|
void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, boost::any value, int opt_index = 0);
|
||||||
|
|
||||||
|
@ -35,11 +35,11 @@ void set_tab_panel(SV *ui)
|
|||||||
void add_debug_menu(SV *ui, int event_language_change)
|
void add_debug_menu(SV *ui, int event_language_change)
|
||||||
%code%{ Slic3r::GUI::add_debug_menu((wxMenuBar*)wxPli_sv_2_object(aTHX_ ui, "Wx::MenuBar"), event_language_change); %};
|
%code%{ Slic3r::GUI::add_debug_menu((wxMenuBar*)wxPli_sv_2_object(aTHX_ ui, "Wx::MenuBar"), event_language_change); %};
|
||||||
|
|
||||||
void create_preset_tabs(PresetBundle *preset_bundle, AppConfig *app_config,
|
void create_preset_tabs(PresetBundle *preset_bundle, bool no_controller,
|
||||||
bool no_controller, bool is_disabled_button_browse, bool is_user_agent,
|
bool is_disabled_button_browse, bool is_user_agent,
|
||||||
int event_value_change, int event_presets_changed,
|
int event_value_change, int event_presets_changed,
|
||||||
int event_button_browse, int event_button_test)
|
int event_button_browse, int event_button_test)
|
||||||
%code%{ Slic3r::GUI::create_preset_tabs(preset_bundle, app_config, no_controller,
|
%code%{ Slic3r::GUI::create_preset_tabs(preset_bundle, no_controller,
|
||||||
is_disabled_button_browse, is_user_agent,
|
is_disabled_button_browse, is_user_agent,
|
||||||
event_value_change, event_presets_changed,
|
event_value_change, event_presets_changed,
|
||||||
event_button_browse, event_button_test); %};
|
event_button_browse, event_button_test); %};
|
||||||
@ -55,3 +55,6 @@ void create_combochecklist(SV *ui, std::string text, std::string items, bool ini
|
|||||||
|
|
||||||
int combochecklist_get_flags(SV *ui)
|
int combochecklist_get_flags(SV *ui)
|
||||||
%code%{ RETVAL=Slic3r::GUI::combochecklist_get_flags((wxComboCtrl*)wxPli_sv_2_object(aTHX_ ui, "Wx::ComboCtrl")); %};
|
%code%{ RETVAL=Slic3r::GUI::combochecklist_get_flags((wxComboCtrl*)wxPli_sv_2_object(aTHX_ ui, "Wx::ComboCtrl")); %};
|
||||||
|
|
||||||
|
void set_app_config(AppConfig *app_config)
|
||||||
|
%code%{ Slic3r::GUI::set_app_config(app_config); %};
|
||||||
|
Loading…
Reference in New Issue
Block a user