From 6c53c1afc30f80eb54e97db3e819848ef52598c8 Mon Sep 17 00:00:00 2001 From: pliu037 Date: Thu, 31 Jul 2014 07:25:59 -0400 Subject: [PATCH] Cleaned up some code and reworked the logic regarding which cards.xml Oracle and Cockatrice consider default. Original: If default is checked, Oracle will always save to the AppData path. 1st commit: If a path to cards.xml is set, Oracle will update that cards.xml. Bug: Running Oracle before setting a cards.xml (i.e.: on a fresh install) will lead to Oracle asking for a location at which to save cards.xml, even if default was checked. 2nd commit: Fix of 1st commit +: 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. This commit: Fix of 2nd commit +: 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 copy. --- oracle/src/oraclewizard.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/oracle/src/oraclewizard.cpp b/oracle/src/oraclewizard.cpp index bae4240b1..981a8f6bf 100644 --- a/oracle/src/oraclewizard.cpp +++ b/oracle/src/oraclewizard.cpp @@ -379,21 +379,25 @@ bool SaveSetsPage::validatePage() QDir dir(dataDir); if (!dir.exists()) dir.mkpath(dataDir); - savePath = dataDir + "/cards.xml"; - settings->setValue("paths/carddatabase", savePath); } - qDebug(savePath.toLatin1()); 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()) { + if (fileName.isEmpty()) return false; - } if (wizard()->importer->saveToFile(fileName)) ok = true; else