~ubuntu-branches/ubuntu/wily/ginkgocadx/wily-proposed

« back to all changes in this revision

Viewing changes to src/cadxcore/main/gui/configuration/panelconfiguraciongeneral.cpp

  • Committer: Package Import Robot
  • Author(s): Dmitry Smirnov
  • Date: 2013-10-24 21:28:17 UTC
  • mfrom: (1.2.2)
  • Revision ID: package-import@ubuntu.com-20131024212817-ej1skb9og09d3ht6
Tags: 3.5.0.1137.31+dfsg-1
New upstream release [October 2013]

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 *  $Id: panelconfiguraciongeneral.cpp $
4
4
 *  Ginkgo CADx Project
5
5
 *
6
 
 *  Copyright 2008-12 MetaEmotion S.L. All rights reserved.
 
6
 *  Copyright 2008-14 MetaEmotion S.L. All rights reserved.
7
7
 *  http://ginkgo-cadx.com
8
8
 *
9
9
 *  This file is licensed under LGPL v3 license.
35
35
#include <main/controllers/controladorvistas.h>
36
36
#include <main/controllers/commandcontroller.h>
37
37
#include <main/controllers/historycontroller.h>
 
38
#include <main/controllers/autocleaningcontroller.h>
38
39
#include <main/gui/history3/historypanel3.h>
39
40
#include <main/entorno.h>
40
41
#include <api/controllers/icontroladorinternacionalizacion.h>
45
46
 
46
47
                PanelConfiguracionGeneral::PanelConfiguracionGeneral(wxWindow* pParent,IDialogoConfiguracion* pDialogo): PanelConfiguracionGeneralBase(pParent), IPasoConfiguracion(pDialogo)
47
48
                {                       
 
49
                        m_idiomaCambiado = false;
48
50
                        pProxySettings = new wxProxySettings();
49
 
                        if (GNC::GCS::ControladorVistas::Instance()->GetVistas().size() > 0)
50
 
                        {
51
 
                                m_pPanelDicomDir->Enable(false);
52
 
                                m_pstaticTextAdvertencia->Show(true);
53
 
                        }
54
 
                        else
55
 
                        {
56
 
                                m_pstaticTextAdvertencia->Show(false);
57
 
                        }
58
 
                        m_idiomaCambiado = false;
59
51
                        Recargar();
60
52
                        Layout();
61
53
                }
67
59
 
68
60
                void PanelConfiguracionGeneral::Recargar()
69
61
                {
70
 
                        std::string dicomDir;
71
 
                        
72
 
                        if(!GNC::GCS::ConfigurationController::Instance()->readStringUser("/GinkgoCore/Estacion","DicomDir", dicomDir)) {
73
 
                                m_pathDicomDir = FROMPATH(GNC::GCS::HistoryController::Instance()->GetGinkgoDicomDir());
74
 
                        } else {
75
 
                                m_pathDicomDir = wxString::FromUTF8(dicomDir.c_str());
76
 
                        }
77
 
                        m_pDICOMDir->SetValue(m_pathDicomDir);
78
 
 
79
62
                        //check for updates
80
63
                        bool check;
81
64
                        GNC::GCS::ConfigurationController::Instance()->readBoolGeneral("/GinkgoCore/Estacion", "CheckForUpdates", check, true);
142
125
 
143
126
                bool PanelConfiguracionGeneral::Validar()
144
127
                {
145
 
                        wxString path = m_pDICOMDir->GetValue();
146
 
                        wxFileName fileName(path);
147
 
                        if(!fileName.IsAbsolute()) {
148
 
                                wxFileName pathOfExec(wxStandardPaths::Get().GetExecutablePath());
149
 
                                fileName.MakeAbsolute(pathOfExec.GetPath());
150
 
                                path = fileName.GetFullPath();
151
 
                        }
152
 
 
153
 
                        if(!wxDir::Exists(path)) {
154
 
                                //se pregunta si desea crearlo
155
 
                                int answer = wxMessageBox(_("The selected directory does not exist\nWould you like to create it?"),_("Info"),wxYES_NO,this);
156
 
                                if(answer == wxNO) {
157
 
                                        return false;
158
 
                                } else {
159
 
                #ifdef _WIN32
160
 
                                        wxMkdir(path,511);
161
 
                #else
162
 
                                        wxMkDir(path.ToUTF8(), 0770);
163
 
                #endif
164
 
                                        if(!wxDirExists(path))
165
 
                                        {
166
 
                                                wxMessageBox(_("Failed to create directory, make sure the path is correct and you have permissions on parent directory"), _("Info"));
167
 
                                                return false;
168
 
                                        }
169
 
                                }
170
 
                        } else {
171
 
                                //se comprueba que puede escribir(escribimos y borramos un fichero chorra)
172
 
                                wxString pathFicheroPrueba = path + wxFileName::GetPathSeparator() + wxString::Format(wxT("%d"),rand());
173
 
                                while(wxFileExists(pathFicheroPrueba)) {
174
 
                                        pathFicheroPrueba = path + wxFileName::GetPathSeparator() + wxString::Format(wxT("%d"),rand());
175
 
                                }
176
 
                                {
177
 
                                        wxFile ficheroTmp;
178
 
                                        if(!ficheroTmp.Create(pathFicheroPrueba,false)){
179
 
                                                if(!wxFileExists(pathFicheroPrueba) ) {
180
 
                                                        wxMessageBox(_("There was an error reading the directory, make sure you have write permissions on it"), _("Info"));
181
 
                                                                return false;
182
 
                                                }
183
 
                                        }
184
 
                                        ficheroTmp.Write(wxT("prueba"));
185
 
                                        ficheroTmp.Close();
186
 
                                }
187
 
                                wxRemoveFile(pathFicheroPrueba);
188
 
                        }
189
 
 
190
128
                        if(m_idiomaCambiado) {
191
129
                                wxMessageBox(_("Ginkgo CADx must restart for the changes to take effect"),_("Info"));
192
130
                        }
196
134
 
197
135
                bool PanelConfiguracionGeneral::Guardar()
198
136
                {
199
 
                        //se actualiza el fichero de configuracion
200
 
                        wxFileName dirAnterior(m_pathDicomDir);
201
 
                        wxFileName dirNuevo(m_pDICOMDir->GetValue());
202
 
                        if(dirAnterior != dirNuevo)
203
 
                        {
204
 
                                GNC::GCS::ConfigurationController::Instance()->writeStringUser("/GinkgoCore/Estacion", "DicomDir",std::string(m_pDICOMDir->GetValue().ToUTF8()));
205
 
                                //se vacia el dicomdir actual y se carga el nuevo...
206
 
                                GNC::GCS::HistoryController::FreeInstance();
207
 
                                if (!GNC::GCS::HistoryController::Instance()->IsOk()) {
208
 
                                        //revert changes....
209
 
                                        GNC::GCS::ConfigurationController::Instance()->writeStringUser("/GinkgoCore/Estacion", "DicomDir", std::string(m_pathDicomDir.ToUTF8()));
210
 
                                        //se vacia el dicomdir actual y se carga el nuevo...
211
 
                                        GNC::GCS::HistoryController::FreeInstance();
212
 
                                }
213
 
                                GNC::GUI::HistoryPanel3::Instance()->ReloadHistory();
214
 
                                
215
 
                        }
216
 
 
217
137
                        GNC::GCS::ConfigurationController::Instance()->writeBoolGeneral("/GinkgoCore/Estacion", "CheckForUpdates", m_pCheckForUpdates->GetValue());
218
138
 
219
139
                        //internacionalizacion                  
257
177
                                m_idiomaCambiado = true;
258
178
                        }
259
179
                }
260
 
 
261
 
                
262
 
                void PanelConfiguracionGeneral::OnSeleccionarDirectorio(wxCommandEvent &)
263
 
                {
264
 
                        wxDirDialog seleccionarDirectorio(this,_("Select DICOMDIR"),m_pDICOMDir->GetValue(),wxDD_DEFAULT_STYLE|wxDD_NEW_DIR_BUTTON);
265
 
                        int response = seleccionarDirectorio.ShowModal();
266
 
                        if (response == wxID_OK)
267
 
                        {
268
 
                                m_pDICOMDir->SetValue(seleccionarDirectorio.GetPath());
269
 
                        }
270
 
                }
271
 
 
272
 
                void PanelConfiguracionGeneral::OnSize(wxSizeEvent & event){
273
 
                        wxSize oldSize = m_pstaticTextAdvertencia->GetSize();
274
 
                        Freeze();
275
 
                        m_pstaticTextAdvertencia->Freeze();
276
 
                        m_pstaticTextAdvertencia->SetLabel(_("Warning, to update the directory, you must close current opened series."));
277
 
                        m_pstaticTextAdvertencia->Wrap( event.GetSize().x - 25 );
278
 
                        m_pstaticTextAdvertencia->Thaw();
279
 
                        Thaw();
280
 
                        wxSize newSize = m_pstaticTextAdvertencia->GetSize();
281
 
                        if (newSize != oldSize) {
282
 
                                Layout();
283
 
                                event.Skip(false);
284
 
                        } else {
285
 
                                event.Skip(true);
286
 
                        }
287
 
                }
288
180
                
289
181
                void PanelConfiguracionGeneral::OnProxySettings(wxCommandEvent &)
290
182
                {