summaryrefslogtreecommitdiffstats
path: root/Project/main.cpp
diff options
context:
space:
mode:
authorThales Lima Oliveira <thaleslima.ufu@gmail.com>2019-01-16 09:38:08 -0200
committerGitHub <noreply@github.com>2019-01-16 09:38:08 -0200
commit9c7c255d7dc957241364aca0e5322da926e33fc7 (patch)
tree16dda6fad8398941c3c8e4db6d48ef98602ec06f /Project/main.cpp
parentaf070d92462ac5586aa6a0a80c51a8fa72710600 (diff)
parentdb3fadbcc9f396ca22c4578101bbcd0a7e81609e (diff)
downloadPSP.git-9c7c255d7dc957241364aca0e5322da926e33fc7.tar.gz
PSP.git-9c7c255d7dc957241364aca0e5322da926e33fc7.tar.xz
PSP.git-9c7c255d7dc957241364aca0e5322da926e33fc7.zip
Merge pull request #46 from Thales1330/wip/induction-motor
Wip/induction motor
Diffstat (limited to 'Project/main.cpp')
-rw-r--r--Project/main.cpp34
1 files changed, 24 insertions, 10 deletions
diff --git a/Project/main.cpp b/Project/main.cpp
index 536ef57..718dd06 100644
--- a/Project/main.cpp
+++ b/Project/main.cpp
@@ -1,9 +1,10 @@
#include <wx/app.h>
+#include <wx/cmdline.h>
#include <wx/event.h>
#include <wx/image.h>
+#include <wx/msgdlg.h>
#include <wx/stdpaths.h>
#include <wx/textfile.h>
-#include <wx/cmdline.h>
#include "MainFrame.h"
#include "PropertiesData.h"
@@ -16,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();
@@ -76,13 +79,24 @@ class MainApp : public wxApp
void LoadCatalogs(wxLocale* locale, PropertiesData* propertiesData)
{
- locale->Init(propertiesData->GetGeneralPropertiesData().language, wxLOCALE_DONT_LOAD_DEFAULT);
+ // 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);
+ 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()
@@ -98,21 +112,21 @@ 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) {
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__
+ //Set application icon for windows
mainFrame->SetIcon(wxICON(aaaaprogicon));
- #endif
+#endif
SetTopWindow(mainFrame);
return GetTopWindow()->Show();
}