From aad89bf4d16d45c0790bd2fc010d9ec06cc35430 Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Sat, 29 Dec 2018 13:38:13 -0200 Subject: wxWidgets update (3.1.2) and bugfixes --- Project/main.cpp | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'Project/main.cpp') diff --git a/Project/main.cpp b/Project/main.cpp index 536ef57..61b7fc2 100644 --- a/Project/main.cpp +++ b/Project/main.cpp @@ -1,9 +1,10 @@ #include +#include #include #include +#include #include #include -#include #include "MainFrame.h" #include "PropertiesData.h" @@ -76,13 +77,23 @@ class MainApp : public wxApp void LoadCatalogs(wxLocale* locale, PropertiesData* propertiesData) { - locale->Init(propertiesData->GetGeneralPropertiesData().language, wxLOCALE_DONT_LOAD_DEFAULT); + if(!locale->Init(propertiesData->GetGeneralPropertiesData().language, wxLOCALE_DONT_LOAD_DEFAULT)) { + wxMessageDialog msgDialog(NULL, _("This language is not supported by the system."), _("Error"), + wxOK | wxCENTRE | wxICON_ERROR); + msgDialog.ShowModal(); + } wxFileName fn(wxStandardPaths::Get().GetExecutablePath()); wxString langPath = fn.GetPath() + wxFileName::DirName("\\..\\data\\lang", wxPATH_WIN).GetPath(); locale->AddCatalogLookupPathPrefix(langPath); - // Load translation catalogs. - locale->AddCatalog(wxT("pt_BR"), wxLANGUAGE_PORTUGUESE_BRAZILIAN); + //pt_BR + if(propertiesData->GetGeneralPropertiesData().language == wxLANGUAGE_PORTUGUESE_BRAZILIAN) { + if(!locale->AddCatalog(wxT("pt_BR"))) { + wxMessageDialog msgDialog(NULL, _("Fail to load brazilian portuguese language catalog."), _("Error"), + wxOK | wxCENTRE | wxICON_ERROR); + msgDialog.ShowModal(); + } + } } virtual bool OnInit() @@ -104,15 +115,13 @@ class MainApp : public wxApp if(cmdLineParser.Parse() == 0) { wxCmdLineArgs args = cmdLineParser.GetArguments(); for(auto it = args.begin(), itEnd = args.end(); it != itEnd; ++it) { - if(it->GetKind() == wxCMD_LINE_PARAM) { - openFilePath = it->GetStrVal(); - } + if(it->GetKind() == wxCMD_LINE_PARAM) { openFilePath = it->GetStrVal(); } } } MainFrame* mainFrame = new MainFrame(NULL, locale, propertiesData, openFilePath); - #ifdef __WXMSW__ +#ifdef __WXMSW__ mainFrame->SetIcon(wxICON(aaaaprogicon)); - #endif +#endif SetTopWindow(mainFrame); return GetTopWindow()->Show(); } -- cgit From db3fadbcc9f396ca22c4578101bbcd0a7e81609e Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Wed, 16 Jan 2019 09:35:35 -0200 Subject: Stability and site updates --- Project/main.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Project/main.cpp') diff --git a/Project/main.cpp b/Project/main.cpp index 61b7fc2..718dd06 100644 --- a/Project/main.cpp +++ b/Project/main.cpp @@ -17,6 +17,8 @@ class MainApp : public wxApp virtual ~MainApp() {} bool LoadInitFile(PropertiesData* propertiesData) { + // Load configuration file, if don't exists create it. + // Find the executable location path. wxFileName fn(wxStandardPaths::Get().GetExecutablePath()); wxTextFile file(fn.GetPath() + wxFileName::GetPathSeparator() + "config.ini"); auto data = propertiesData->GetGeneralPropertiesData(); @@ -77,6 +79,7 @@ class MainApp : public wxApp void LoadCatalogs(wxLocale* locale, PropertiesData* propertiesData) { + // Load language catalogs according the propertiesData attribute. if(!locale->Init(propertiesData->GetGeneralPropertiesData().language, wxLOCALE_DONT_LOAD_DEFAULT)) { wxMessageDialog msgDialog(NULL, _("This language is not supported by the system."), _("Error"), wxOK | wxCENTRE | wxICON_ERROR); @@ -109,7 +112,8 @@ class MainApp : public wxApp LoadCatalogs(locale, propertiesData); wxString openFilePath = ""; - + + // Load command line attributes. This is used to directly open saved files (.psp). wxCmdLineParser cmdLineParser(wxApp::argc, wxApp::argv); cmdLineParser.AddParam("", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL); if(cmdLineParser.Parse() == 0) { @@ -120,6 +124,7 @@ class MainApp : public wxApp } MainFrame* mainFrame = new MainFrame(NULL, locale, propertiesData, openFilePath); #ifdef __WXMSW__ + //Set application icon for windows mainFrame->SetIcon(wxICON(aaaaprogicon)); #endif SetTopWindow(mainFrame); -- cgit