]> Creatis software - clitk.git/commitdiff
the dialog is filled with previous settings if the user was already registered
authorMaxime <mpech@russule.clb.loc>
Mon, 9 May 2011 13:30:44 +0000 (15:30 +0200)
committerMaxime <mpech@russule.clb.loc>
Mon, 9 May 2011 13:30:44 +0000 (15:30 +0200)
vv/vvMainWindow.cxx
vv/vvRegisterForm.cxx
vv/vvRegisterForm.h

index d4c2976dc801beef46843fbf3f1217af8a7c01fa..95df533c63e923238f85f943c6fb5857932a858c 100644 (file)
@@ -22,6 +22,7 @@
 #include <QTimer>
 #include "QTreePushButton.h"
 #include <QUrl>
+#include <QSettings>
 
 // VV include
 #include "vvMainWindow.h"
@@ -329,11 +330,11 @@ vvMainWindow::vvMainWindow():vvMainWindowBase()
 //------------------------------------------------------------------------------
 
 void vvMainWindow::show(){
- vvMainWindowBase::show();
 vvMainWindowBase::show();
   vvRegisterForm* registerForm = new vvRegisterForm(QUrl("http://localhost/vvregister/write.php"));
   if(registerForm->canPush()){
-      registerForm->show();
-      registerForm->acquitPushed();//too bad if there is not internet connection anymore.
+    registerForm->show();
+    registerForm->acquitPushed();//too bad if there is not internet connection anymore.
   }
 }
 //------------------------------------------------------------------------------
index c084bfa25eb6b095ba33dce5534a375b8c5b8d69..d77b8fd1a5bc6018e1c7819e07c0722c7ea8e76b 100644 (file)
 
 #include "vvRegisterForm.h"
 #include <QNetworkRequest>
-#include <QSettings>
 #include <QDir>
-#include <iostream>
 #include "common/globals.h"
 #include "vvCommon.h"
 #include "vvUtils.h"
 
-vvRegisterForm::vvRegisterForm(QUrl url):url(url) 
+vvRegisterForm::vvRegisterForm(QUrl url):url(url), settings(getVVSettingsPath(), getSettingsOptionFormat())
   manager = new QNetworkAccessManager(this);
   setupUi(this);
 }
@@ -37,23 +35,32 @@ void vvRegisterForm::sendData(){
   url2.addQueryItem("lastName", lastName->text().toUtf8());
   url2.addQueryItem("email", email->text().toUtf8());
   url2.addQueryItem("group", group->text().toUtf8());
-  url2.addQueryItem("os", QString::fromUtf8(OS_NAME));
-  url2.addQueryItem("vvVersion", QString::fromUtf8(VV_VERSION));
+  url2.addQueryItem("os", osName->text().toUtf8());
+  url2.addQueryItem("vvVersion", VV_VERSION);
   manager->get(QNetworkRequest(url2));
 }
 void vvRegisterForm::accept(){
   sendData();
+  settings.setValue("name", firstName->text().toUtf8());
+  settings.setValue("lastName", lastName->text().toUtf8());
+  settings.setValue("email", email->text().toUtf8());
+  settings.setValue("group", group->text().toUtf8());
+  settings.setValue("os", osName->text().toUtf8());
   QDialog::accept();
 }
 bool vvRegisterForm::canPush(){
-  QSettings settings(getVVSettingsPath(), getSettingsOptionFormat());
+  ///maybe we show this dialog only for new major release, not for any patches?
   return settings.value("vvVersion").toString().toStdString()<VV_VERSION;
 }
 void vvRegisterForm::acquitPushed(){
-  QSettings settings(getVVSettingsPath(), getSettingsOptionFormat());
   settings.setValue("vvVersion", VV_VERSION);
 }
 void vvRegisterForm::show(){
+ firstName->setText(settings.value("name").toString());
+ lastName->setText(settings.value("lastName").toString()); 
+ email->setText(settings.value("email").toString()); 
+ group->setText(settings.value("group").toString()); 
+  
  osName->setText(QString::fromStdString(OS_NAME));
  QDialog::show();
 }
\ No newline at end of file
index 72bec2a61f274eb082687d28fc0ace8c5cda332f..e5f1ea682979bf913100499ef8a51efda6c3fc8c 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "ui_vvRegisterForm.h"
 #include <QUrl>
+#include <QSettings>
 #include <QNetworkAccessManager>
 class vvRegisterForm : public QDialog, private Ui::vvRegisterForm
 {
@@ -29,7 +30,6 @@ public:
     vvRegisterForm(QUrl url);
     void sendData();
     ~vvRegisterForm() {}
-    //return true only if first time
     virtual bool canPush();
     virtual void acquitPushed();
 public slots:
@@ -37,6 +37,7 @@ public slots:
   virtual void show();
 protected:
   QUrl url;
+  QSettings settings;
   QNetworkAccessManager* manager;
 };