From: Maxime Date: Fri, 6 May 2011 15:00:52 +0000 (+0200) Subject: factorising parameters for QSettings X-Git-Tag: v1.2.1~37 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=09f83ca95651df8b78844118db4676a8bf67ff60;p=clitk.git factorising parameters for QSettings we propose the popup only if it is a new version --- diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index df3b675..7075b2c 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -328,7 +328,10 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() vvRegisterForm* registerForm = new vvRegisterForm(QUrl("http://localhost/vvregister/write.php")); - registerForm->show(); + if(registerForm->canPush()){ + registerForm->show(); + registerForm->acquitPushed();//too bad if there is not internet connection anymore. + } } //------------------------------------------------------------------------------ diff --git a/vv/vvRegisterForm.cxx b/vv/vvRegisterForm.cxx index 3903796..430ba5f 100644 --- a/vv/vvRegisterForm.cxx +++ b/vv/vvRegisterForm.cxx @@ -19,9 +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) { manager = new QNetworkAccessManager(this); @@ -29,7 +32,6 @@ vvRegisterForm::vvRegisterForm(QUrl url):url(url) { } void vvRegisterForm::sendData(){ - if(canPush()){ QUrl url2(url); url2.addQueryItem("name", firstName->text().toUtf8()); url2.addQueryItem("lastName", lastName->text().toUtf8()); @@ -37,17 +39,17 @@ void vvRegisterForm::sendData(){ url2.addQueryItem("group", group->text().toUtf8()); url2.addQueryItem("os", QString::fromUtf8(OS_NAME)); url2.addQueryItem("vvVersion", QString::fromUtf8(VV_VERSION)); - manager->get(QNetworkRequest(url2));//make pushed in callback? - acquitPushed(); - } + manager->get(QNetworkRequest(url2)); } void vvRegisterForm::accept(){ - sendData(); - QDialog::accept(); + sendData(); + QDialog::accept(); } bool vvRegisterForm::canPush(){ - return true; + QSettings settings(getVVSettingsPath(), getSettingsOptionFormat()); + return settings.value("vvVersion").toString().toStdString() #include #include -#include #include "clitkCommon.h" #include "vvUtils.h" const std::string vv_user_file=".vv_settings.txt"; +const std::string recentFileList="recentFiles"; typedef std::list FileListType; -static QSettings settings(QDir::homePath()+QString::fromStdString("/"+vv_user_file), QSettings::NativeFormat); +QString getVVSettingsPath(){ + return QDir::homePath()+QString::fromStdString("/"+vv_user_file); +} + +QSettings::Format getSettingsOptionFormat(){ + return QSettings::NativeFormat; +} + ///Returns the last images opened by the user FileListType GetRecentlyOpenedImages() { + QSettings settings(getVVSettingsPath(), getSettingsOptionFormat()); FileListType result; - settings.beginGroup("recentFiles"); + settings.beginGroup(QString::fromStdString(recentFileList)); QStringList keys = settings.childKeys(); for(int i=0; i #include +#include ///Returns the last images opened by the user std::list GetRecentlyOpenedImages(); @@ -26,4 +27,10 @@ std::list GetRecentlyOpenedImages(); ///Adds an image to the list of recently opened images void AddToRecentlyOpenedImages(std::string filename); +///path to user settings +QString getVVSettingsPath(); + +///by default nativeFormat +QSettings::Format getSettingsOptionFormat(); + #endif