From 8be4a14fccdf917170f693d280591ab9a319b2bb Mon Sep 17 00:00:00 2001 From: Peng Liu Date: Thu, 31 Jul 2014 15:33:11 -0400 Subject: [PATCH 1/3] Before: If default is checked, Oracle will always save to the AppData path. If a path to cards.xml is set, Oracle will update that cards.xml. If Oracle is run before a path to cards.xml is set, if default is checked, cards.xml will be saved on the AppData path. Furthermore, this path will be set as the cards.xml path for both Oracle and Cockatrice. If Oracle is run before a path to cards.xml is set, if default is NOT checked, cards.xml will be saved at the selected path and this path will be set as the cards.xml path for both Oracle and Cockatrice. If a path to cards.xml is set, if default is NOT checked, cards.xml will be saved at the selected path but this path will NOT be set as the cards.xml path for either Oracle or Cockatrice. This allows people who already have a cards.xml (which may be customized), to still obtain clean copies of cards.xml through Oracle without overwriting their own --- oracle/src/oraclewizard.cpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/oracle/src/oraclewizard.cpp b/oracle/src/oraclewizard.cpp index 2a597d45..1bedde6b 100644 --- a/oracle/src/oraclewizard.cpp +++ b/oracle/src/oraclewizard.cpp @@ -402,16 +402,27 @@ bool SaveSetsPage::validatePage() #else QStandardPaths::standardLocations(QStandardPaths::DataLocation).first(); #endif - QDir dir(dataDir); - if (!dir.exists()) - dir.mkpath(dataDir); - QString savePath = dataDir + "/cards.xml"; + QSettings* settings = new QSettings(this); + QString savePath = settings->value("paths/carddatabase").toString(); + if (savePath.isEmpty()) { + QDir dir(dataDir); + if (!dir.exists()) + dir.mkpath(dataDir); + } do { QString fileName; - if (savePath.isEmpty() || !defaultPathCheckBox->isChecked()) - fileName = QFileDialog::getSaveFileName(this, tr("Save card database"), dataDir + "/cards.xml", tr("XML card database (*.xml)")); + if (savePath.isEmpty()) { + if (!defaultPathCheckBox->isChecked()) + fileName = QFileDialog::getSaveFileName(this, tr("Save card database"), dataDir + "/cards.xml", tr("XML card database (*.xml)")); + else + fileName = dataDir + "/cards.xml";; + settings->setValue("paths/carddatabase", fileName); + } else { - fileName = savePath; + if (!defaultPathCheckBox->isChecked()) + fileName = QFileDialog::getSaveFileName(this, tr("Save card database"), savePath, tr("XML card database (*.xml)")); + else + fileName = savePath; savePath.clear(); } if (fileName.isEmpty()) { From 605479694d1a33348ebfc0e933c564c18bb57c49 Mon Sep 17 00:00:00 2001 From: Peng Liu Date: Tue, 5 Aug 2014 08:50:42 -0400 Subject: [PATCH 2/3] Removed some redundant code. Factored out translations. --- oracle/src/oraclewizard.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/oracle/src/oraclewizard.cpp b/oracle/src/oraclewizard.cpp index 1bedde6b..f3faae4e 100644 --- a/oracle/src/oraclewizard.cpp +++ b/oracle/src/oraclewizard.cpp @@ -405,25 +405,24 @@ bool SaveSetsPage::validatePage() QSettings* settings = new QSettings(this); QString savePath = settings->value("paths/carddatabase").toString(); if (savePath.isEmpty()) { - QDir dir(dataDir); - if (!dir.exists()) - dir.mkpath(dataDir); + QDir().mkpath(dataDir); } + QString windowName = tr("Save card database"); + QString fileType = tr("XML; card database (*.xml)"); do { QString fileName; if (savePath.isEmpty()) { if (!defaultPathCheckBox->isChecked()) - fileName = QFileDialog::getSaveFileName(this, tr("Save card database"), dataDir + "/cards.xml", tr("XML card database (*.xml)")); + fileName = QFileDialog::getSaveFileName(this, windowName, dataDir + "/cards.xml", fileType); else fileName = dataDir + "/cards.xml";; settings->setValue("paths/carddatabase", fileName); } else { if (!defaultPathCheckBox->isChecked()) - fileName = QFileDialog::getSaveFileName(this, tr("Save card database"), savePath, tr("XML card database (*.xml)")); + fileName = QFileDialog::getSaveFileName(this, windowName, savePath, fileType); else fileName = savePath; - savePath.clear(); } if (fileName.isEmpty()) { return false; From 3375d4557134dc17f3c74e07f02bb07b8f98eae2 Mon Sep 17 00:00:00 2001 From: Peng Liu Date: Thu, 7 Aug 2014 12:58:03 -0400 Subject: [PATCH 3/3] Logically inverted the if... else statement by removing the logical not (!). Cleaned up a ;;. --- oracle/src/oraclewizard.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/oracle/src/oraclewizard.cpp b/oracle/src/oraclewizard.cpp index f3faae4e..2ed9c74a 100644 --- a/oracle/src/oraclewizard.cpp +++ b/oracle/src/oraclewizard.cpp @@ -412,17 +412,17 @@ bool SaveSetsPage::validatePage() do { QString fileName; if (savePath.isEmpty()) { - if (!defaultPathCheckBox->isChecked()) - fileName = QFileDialog::getSaveFileName(this, windowName, dataDir + "/cards.xml", fileType); + if (defaultPathCheckBox->isChecked()) + fileName = dataDir + "/cards.xml"; else - fileName = dataDir + "/cards.xml";; + fileName = QFileDialog::getSaveFileName(this, windowName, dataDir + "/cards.xml", fileType); settings->setValue("paths/carddatabase", fileName); } else { - if (!defaultPathCheckBox->isChecked()) - fileName = QFileDialog::getSaveFileName(this, windowName, savePath, fileType); - else + if (defaultPathCheckBox->isChecked()) fileName = savePath; + else + fileName = QFileDialog::getSaveFileName(this, windowName, savePath, fileType); } if (fileName.isEmpty()) { return false;