Add an unexposed config value for the AllSets.json file url

It will be saved only if:
* it’s different than the default (the user used a custom url);
* the download actually worked
This commit is contained in:
Fabio Bas 2014-06-21 12:10:04 +02:00
parent 17f7fe7ad9
commit 0ec5842c3f
2 changed files with 12 additions and 2 deletions

View file

@ -12,6 +12,7 @@
OracleWizard::OracleWizard(QWidget *parent) OracleWizard::OracleWizard(QWidget *parent)
: QWizard(parent) : QWizard(parent)
{ {
settings = new QSettings(this);
importer = new OracleImporter(QDesktopServices::storageLocation(QDesktopServices::DataLocation), this); importer = new OracleImporter(QDesktopServices::storageLocation(QDesktopServices::DataLocation), this);
addPage(new IntroPage); addPage(new IntroPage);
@ -76,7 +77,6 @@ LoadSetsPage::LoadSetsPage(QWidget *parent)
progressBar = new QProgressBar(this); progressBar = new QProgressBar(this);
urlRadioButton->setChecked(true); urlRadioButton->setChecked(true);
urlLineEdit->setText(ALLSETS_URL);
fileButton = new QPushButton(tr("Choose file..."), this); fileButton = new QPushButton(tr("Choose file..."), this);
connect(fileButton, SIGNAL(clicked()), this, SLOT(actLoadSetsFile())); connect(fileButton, SIGNAL(clicked()), this, SLOT(actLoadSetsFile()));
@ -97,6 +97,8 @@ LoadSetsPage::LoadSetsPage(QWidget *parent)
void LoadSetsPage::initializePage() void LoadSetsPage::initializePage()
{ {
urlLineEdit->setText(wizard()->settings->value("allsetsurl", ALLSETS_URL).toString());
progressLabel->hide(); progressLabel->hide();
progressBar->hide(); progressBar->hide();
} }
@ -200,7 +202,13 @@ void LoadSetsPage::actDownloadFinishedSetsFile()
return; return;
} }
this->readSetsFromByteArray(reply->readAll()); // save allsets.json url, but only if the user customized it and download was successfull
if(urlLineEdit->text() != QString(ALLSETS_URL))
wizard()->settings->setValue("allsetsurl", urlLineEdit->text());
else
wizard()->settings->remove("allsetsurl");
readSetsFromByteArray(reply->readAll());
reply->deleteLater(); reply->deleteLater();
} }

View file

@ -15,6 +15,7 @@ class QNetworkAccessManager;
class QTextEdit; class QTextEdit;
class QVBoxLayout; class QVBoxLayout;
class OracleImporter; class OracleImporter;
class QSettings;
class OracleWizard : public QWizard class OracleWizard : public QWizard
{ {
@ -26,6 +27,7 @@ public:
void disableButtons(); void disableButtons();
public: public:
OracleImporter *importer; OracleImporter *importer;
QSettings * settings;
}; };