]> Creatis software - clitk.git/blob - vv/vvRegisterForm.cxx
Merge branch 'master' of /home/dsarrut/clitk3.server
[clitk.git] / vv / vvRegisterForm.cxx
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to:
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://www.centreleonberard.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
18 #include <QApplication>
19
20 #include "vvRegisterForm.h"
21 #include <QNetworkRequest>
22 #include <QDir>
23 #include "common/globals.h"
24 #include "vvCommon.h"
25 #include "vvUtils.h"
26
27 vvRegisterForm::vvRegisterForm(QUrl url, QString path, QSettings::Format format):url(url), settings(path, format){ 
28   manager = new QNetworkAccessManager(this);
29   setupUi(this);
30 }
31
32 void vvRegisterForm::sendData(){
33   QUrl url2(url);
34   url2.addQueryItem("name", firstName->text().toUtf8());
35   url2.addQueryItem("lastName", lastName->text().toUtf8());
36   url2.addQueryItem("email", email->text().toUtf8());
37   url2.addQueryItem("group", group->text().toUtf8());
38   url2.addQueryItem("os", osName->text().toUtf8());
39   url2.addQueryItem("vvVersion", VV_VERSION);
40   manager->get(QNetworkRequest(url2));
41 }
42 void vvRegisterForm::accept(){
43   sendData();
44   settings.setValue("name", firstName->text().toUtf8());
45   settings.setValue("lastName", lastName->text().toUtf8());
46   settings.setValue("email", email->text().toUtf8());
47   settings.setValue("group", group->text().toUtf8());
48   settings.setValue("os", osName->text().toUtf8());
49   QDialog::accept();
50 }
51 bool vvRegisterForm::canPush(){
52   ///maybe we show this dialog only for new major release, not for any patches?
53   return settings.value("vvVersion").toString().toStdString()<VV_VERSION;
54 }
55 void vvRegisterForm::acquitPushed(){
56   settings.setValue("vvVersion", VV_VERSION);
57 }
58 void vvRegisterForm::show(){
59  firstName->setText(settings.value("name").toString());
60  lastName->setText(settings.value("lastName").toString()); 
61  email->setText(settings.value("email").toString()); 
62  group->setText(settings.value("group").toString()); 
63   
64  osName->setText(QString::fromStdString(OS_NAME));
65  QDialog::show();
66 }