89{
90 auto data = m_properties->GetGeneralPropertiesData();
91 auto checkData = m_properties->GetGeneralPropertiesData();
92 bool needRestart = false;
93 data.atpPath = wxFileName(m_filePickerATPFolder->GetPath());
94 wxFont slectedFont = m_fontPickerText->GetSelectedFont();
95 data.labelFont = slectedFont.GetFaceName();
96 data.labelFontSize = slectedFont.GetPointSize();
97
98
99 wxFileName fn(wxStandardPaths::Get().GetDocumentsDir() + wxFileName::GetPathSeparator() + "PSP-UFU" + wxFileName::GetPathSeparator() + "config.ini");
100 wxTextFile file(fn.GetFullPath());
101 if (!file.Create()) {
102 if (!file.Open()) {
103
104 wxMessageDialog msgDialog(this,
105 _("It was not possible to access the init file.\nThe settings won't be applied."),
106 _("Error"), wxOK | wxCENTRE | wxICON_ERROR);
107 msgDialog.ShowModal();
108 }
109 file.Clear();
110 }
111
112 wxString line = "lang=";
113 switch (m_choiceLanguage->GetSelection()) {
114 case 0: {
115 line += "en";
116 data.language = wxLANGUAGE_ENGLISH;
117 } break;
118 case 1: {
119 line += "pt-br";
120 data.language = wxLANGUAGE_PORTUGUESE_BRAZILIAN;
121 } break;
122 }
123 file.AddLine(line);
124 if (data.language != checkData.language) needRestart = true;
125
126 line = "plotlib=";
127 switch (m_choicePlotLib->GetSelection()) {
128 case 0: {
129 line += "chartdir";
130 data.plotLib = PlotLib::wxCHART_DIR;
131 } break;
132 case 1: {
133 line += "mathplot";
134 data.plotLib = PlotLib::wxMATH_PLOT;
135 } break;
136 }
137 file.AddLine(line);
138
139
140 line = "theme=";
141 switch (m_choiceTheme->GetSelection()) {
142 case 0: {
143 line += "light";
144 data.theme = THEME_LIGHT;
145 wxTheApp->SetAppearance(wxApp::Appearance::Light);
146 } break;
147 case 1: {
148 line += "dark";
149 data.theme = THEME_DARK;
150 wxTheApp->SetAppearance(wxApp::Appearance::Dark);
151 } break;
152 }
153 file.AddLine(line);
154 if (data.theme != checkData.theme) needRestart = true;
155
156 line = "labelfont=";
157 line += data.labelFont;
158 file.AddLine(line);
159
160 line = "labelfontsize=";
161 line += wxString::Format("%d", data.labelFontSize);
162 file.AddLine(line);
163
164
165 line = "atpfile=";
166 line += data.atpPath.GetFullPath();
167 file.AddLine(line);
168
169 file.Write();
170 file.Close();
171
172 if (needRestart) {
173 wxMessageDialog msgDialog(this, _("The application must be restarted to settings changes be applied."),
174 _("Info"), wxOK | wxCENTRE | wxICON_INFORMATION);
175 msgDialog.ShowModal();
176 }
177 m_properties->SetGeneralPropertiesData(data);
178 return true;
179}