19#include <wx/fontenum.h>
21#include "../utils/PropertiesData.h"
24GeneralPropertiesForm::GeneralPropertiesForm(wxWindow* parent,
PropertiesData* properties)
25 : GeneralPropertiesFormBase(parent)
27 m_properties = properties;
28 auto data = m_properties->GetGeneralPropertiesData();
31 m_choiceLanguage->Clear();
32 m_choiceLanguage->Insert(_(
"English"), 0);
33 m_choiceLanguage->Insert(_(
"Portuguese"), 1);
34 m_choiceTheme->Clear();
35 m_choiceTheme->Insert(_(
"Light"), 0);
36 m_choiceTheme->Insert(_(
"Dark"), 1);
40 m_choicePlotLib->Clear();
41 m_choicePlotLib->Insert(_(
"Chart Director"), 0);
42 m_choicePlotLib->Insert(_(
"wxMathPlot"), 1);
44 switch (data.language) {
45 case wxLANGUAGE_ENGLISH: {
46 m_choiceLanguage->SetSelection(0);
48 case wxLANGUAGE_PORTUGUESE_BRAZILIAN: {
49 m_choiceLanguage->SetSelection(1);
52 m_choiceLanguage->SetSelection(wxNOT_FOUND);
55 switch (data.plotLib) {
56 case PlotLib::wxCHART_DIR: {
57 m_choicePlotLib->SetSelection(0);
59 case PlotLib::wxMATH_PLOT: {
60 m_choicePlotLib->SetSelection(1);
65 m_choiceTheme->SetSelection(0);
68 m_choiceTheme->SetSelection(1);
73 m_filePickerATPFolder->SetPath(data.atpPath.GetFullPath());
76 wxFont currentFont(data.labelFontSize, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL,
false, data.labelFont);
77 m_fontPickerText->SetSelectedFont(currentFont);
80GeneralPropertiesForm::~GeneralPropertiesForm() {}
81void GeneralPropertiesForm::OnButtonOKClick(wxCommandEvent& event)
83 if (ValidateData()) EndModal(wxID_OK);
86bool GeneralPropertiesForm::ValidateData()
88 auto data = m_properties->GetGeneralPropertiesData();
89 auto checkData = m_properties->GetGeneralPropertiesData();
90 bool needRestart =
false;
91 data.atpPath = wxFileName(m_filePickerATPFolder->GetPath());
92 wxFont slectedFont = m_fontPickerText->GetSelectedFont();
93 data.labelFont = slectedFont.GetFaceName();
94 data.labelFontSize = slectedFont.GetPointSize();
97 wxFileName fn(wxStandardPaths::Get().GetDocumentsDir() + wxFileName::GetPathSeparator() +
"PSP-UFU" + wxFileName::GetPathSeparator() +
"config.ini");
98 wxTextFile file(fn.GetFullPath());
102 wxMessageDialog msgDialog(
this,
103 _(
"It was not possible to access the init file.\nThe settings won't be applied."),
104 _(
"Error"), wxOK | wxCENTRE | wxICON_ERROR);
105 msgDialog.ShowModal();
110 wxString line =
"lang=";
111 switch (m_choiceLanguage->GetSelection()) {
114 data.language = wxLANGUAGE_ENGLISH;
118 data.language = wxLANGUAGE_PORTUGUESE_BRAZILIAN;
122 if (data.language != checkData.language) needRestart =
true;
125 switch (m_choicePlotLib->GetSelection()) {
128 data.plotLib = PlotLib::wxCHART_DIR;
132 data.plotLib = PlotLib::wxMATH_PLOT;
139 switch (m_choiceTheme->GetSelection()) {
142 data.theme = THEME_LIGHT;
146 data.theme = THEME_DARK;
150 if (data.theme != checkData.theme) needRestart =
true;
167 line += data.labelFont;
170 line =
"labelfontsize=";
171 line += wxString::Format(
"%d", data.labelFontSize);
176 line += data.atpPath.GetFullPath();
183 wxMessageDialog msgDialog(
this, _(
"The application must be restarted to settings changes be applied."),
184 _(
"Info"), wxOK | wxCENTRE | wxICON_INFORMATION);
185 msgDialog.ShowModal();
187 m_properties->SetGeneralPropertiesData(data);
General and simulation data manager.