From 0ec5842c3f4d134f837730368e4a3c0d7e518fcc Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sat, 21 Jun 2014 12:10:04 +0200 Subject: [PATCH] Add an unexposed config value for the AllSets.json file url MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It will be saved only if: * it’s different than the default (the user used a custom url); * the download actually worked --- oracle/src/oraclewizard.cpp | 12 ++++++++++-- oracle/src/oraclewizard.h | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/oracle/src/oraclewizard.cpp b/oracle/src/oraclewizard.cpp index 28a5c646..75381b1d 100644 --- a/oracle/src/oraclewizard.cpp +++ b/oracle/src/oraclewizard.cpp @@ -12,6 +12,7 @@ OracleWizard::OracleWizard(QWidget *parent) : QWizard(parent) { + settings = new QSettings(this); importer = new OracleImporter(QDesktopServices::storageLocation(QDesktopServices::DataLocation), this); addPage(new IntroPage); @@ -76,7 +77,6 @@ LoadSetsPage::LoadSetsPage(QWidget *parent) progressBar = new QProgressBar(this); urlRadioButton->setChecked(true); - urlLineEdit->setText(ALLSETS_URL); fileButton = new QPushButton(tr("Choose file..."), this); connect(fileButton, SIGNAL(clicked()), this, SLOT(actLoadSetsFile())); @@ -97,6 +97,8 @@ LoadSetsPage::LoadSetsPage(QWidget *parent) void LoadSetsPage::initializePage() { + urlLineEdit->setText(wizard()->settings->value("allsetsurl", ALLSETS_URL).toString()); + progressLabel->hide(); progressBar->hide(); } @@ -200,7 +202,13 @@ void LoadSetsPage::actDownloadFinishedSetsFile() 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(); } diff --git a/oracle/src/oraclewizard.h b/oracle/src/oraclewizard.h index 152ce3ad..6e6a6ea8 100644 --- a/oracle/src/oraclewizard.h +++ b/oracle/src/oraclewizard.h @@ -15,6 +15,7 @@ class QNetworkAccessManager; class QTextEdit; class QVBoxLayout; class OracleImporter; +class QSettings; class OracleWizard : public QWizard { @@ -26,6 +27,7 @@ public: void disableButtons(); public: OracleImporter *importer; + QSettings * settings; };