87{
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();
95
96
97 wxFileName fn(wxStandardPaths::Get().GetDocumentsDir() + wxFileName::GetPathSeparator() + "PSP-UFU" + wxFileName::GetPathSeparator() + "config.ini");
98 wxTextFile file(fn.GetFullPath());
99 if (!file.Create()) {
100 if (!file.Open()) {
101
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();
106 }
107 file.Clear();
108 }
109
110 wxString line = "lang=";
111 switch (m_choiceLanguage->GetSelection()) {
112 case 0: {
113 line += "en";
114 data.language = wxLANGUAGE_ENGLISH;
115 } break;
116 case 1: {
117 line += "pt-br";
118 data.language = wxLANGUAGE_PORTUGUESE_BRAZILIAN;
119 } break;
120 }
121 file.AddLine(line);
122 if (data.language != checkData.language) needRestart = true;
123
124 line = "plotlib=";
125 switch (m_choicePlotLib->GetSelection()) {
126 case 0: {
127 line += "chartdir";
128 data.plotLib = PlotLib::wxCHART_DIR;
129 } break;
130 case 1: {
131 line += "mathplot";
132 data.plotLib = PlotLib::wxMATH_PLOT;
133 } break;
134 }
135 file.AddLine(line);
136
137
138 line = "theme=";
139 switch (m_choiceTheme->GetSelection()) {
140 case 0: {
141 line += "light";
142 data.theme = THEME_LIGHT;
143 } break;
144 case 1: {
145 line += "dark";
146 data.theme = THEME_DARK;
147 } break;
148 }
149 file.AddLine(line);
150 if (data.theme != checkData.theme) needRestart = true;
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166 line = "labelfont=";
167 line += data.labelFont;
168 file.AddLine(line);
169
170 line = "labelfontsize=";
171 line += wxString::Format("%d", data.labelFontSize);
172 file.AddLine(line);
173
174
175 line = "atpfile=";
176 line += data.atpPath.GetFullPath();
177 file.AddLine(line);
178
179 file.Write();
180 file.Close();
181
182 if (needRestart) {
183 wxMessageDialog msgDialog(this, _("The application must be restarted to settings changes be applied."),
184 _("Info"), wxOK | wxCENTRE | wxICON_INFORMATION);
185 msgDialog.ShowModal();
186 }
187 m_properties->SetGeneralPropertiesData(data);
188 return true;
189}