From: Maxime Date: Mon, 9 May 2011 13:30:44 +0000 (+0200) Subject: the dialog is filled with previous settings if the user was already registered X-Git-Tag: v1.2.1~33 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=1ec47c5838e94f0ff1606093ae3998fc239a3191;p=clitk.git the dialog is filled with previous settings if the user was already registered --- diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index d4c2976..95df533 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -22,6 +22,7 @@ #include #include "QTreePushButton.h" #include +#include // 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. } } //------------------------------------------------------------------------------ diff --git a/vv/vvRegisterForm.cxx b/vv/vvRegisterForm.cxx index c084bfa..d77b8fd 100644 --- a/vv/vvRegisterForm.cxx +++ b/vv/vvRegisterForm.cxx @@ -19,14 +19,12 @@ #include "vvRegisterForm.h" #include -#include #include -#include #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()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 diff --git a/vv/vvRegisterForm.h b/vv/vvRegisterForm.h index 72bec2a..e5f1ea6 100644 --- a/vv/vvRegisterForm.h +++ b/vv/vvRegisterForm.h @@ -20,6 +20,7 @@ #include "ui_vvRegisterForm.h" #include +#include #include 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; };