diff --git a/cockatrice/src/main.cpp b/cockatrice/src/main.cpp index 5225ee1b1..ffb93a9c0 100644 --- a/cockatrice/src/main.cpp +++ b/cockatrice/src/main.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include "main.h" @@ -99,15 +100,18 @@ int main(int argc, char *argv[]) qsrand(QDateTime::currentDateTime().toTime_t()); bool startMainProgram = true; -#ifdef Q_OS_MAC + const QString dataDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); if (!db->getLoadSuccess()) - if (db->loadCardDatabase(baseDir.absolutePath() + "/cards.xml")) - settingsCache->setCardDatabasePath(baseDir.absolutePath() + "/cards.xml"); - if (!QDir(settingsCache->getDeckPath()).exists()) - settingsCache->setDeckPath(baseDir.absolutePath() + "/decks"); - if (!QDir(settingsCache->getPicsPath()).exists()) - settingsCache->setPicsPath(baseDir.absolutePath() + "/pics"); -#endif + if (db->loadCardDatabase(dataDir + "/cards.xml")) + settingsCache->setCardDatabasePath(dataDir + "/cards.xml"); + if (!QDir(settingsCache->getDeckPath()).exists()) { + QDir().mkpath(dataDir + "/decks"); + settingsCache->setDeckPath(dataDir + "/decks"); + } + if (!QDir(settingsCache->getPicsPath()).exists()) { + QDir().mkpath(dataDir + "/pics"); + settingsCache->setPicsPath(dataDir + "/pics"); + } if (!db->getLoadSuccess() || !QDir(settingsCache->getDeckPath()).exists() || settingsCache->getDeckPath().isEmpty() || settingsCache->getPicsPath().isEmpty() || !QDir(settingsCache->getPicsPath()).exists()) { DlgSettings dlgSettings; dlgSettings.show(); diff --git a/oracle/src/main.cpp b/oracle/src/main.cpp index 3886f924b..a84f49755 100644 --- a/oracle/src/main.cpp +++ b/oracle/src/main.cpp @@ -1,6 +1,5 @@ #include #include -#include "oracleimporter.h" #include "window_main.h" #include "settingscache.h" @@ -11,7 +10,11 @@ int main(int argc, char *argv[]) QApplication app(argc, argv); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); - + + QCoreApplication::setOrganizationName("Cockatrice"); + QCoreApplication::setOrganizationDomain("cockatrice.de"); + QCoreApplication::setApplicationName("Cockatrice"); + settingsCache = new SettingsCache; WindowMain wnd; diff --git a/oracle/src/oracleimporter.cpp b/oracle/src/oracleimporter.cpp index c51a23541..26e40b8cb 100644 --- a/oracle/src/oracleimporter.cpp +++ b/oracle/src/oracleimporter.cpp @@ -235,6 +235,8 @@ QString OracleImporter::getPictureUrl(QString url, int cardId, QString name, con int OracleImporter::startDownload() { + clear(); + setsToDownload.clear(); for (int i = 0; i < allSets.size(); ++i) if (allSets[i].getImport()) diff --git a/oracle/src/window_main.cpp b/oracle/src/window_main.cpp index 9cf164e8d..f41545e2d 100644 --- a/oracle/src/window_main.cpp +++ b/oracle/src/window_main.cpp @@ -1,4 +1,19 @@ -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include "window_main.h" @@ -9,13 +24,7 @@ const QString WindowMain::defaultSetsUrl = QString("http://www.cockatrice.de/fil WindowMain::WindowMain(QWidget *parent) : QMainWindow(parent) { - QDir dataDir(qApp->applicationDirPath()); -#ifdef Q_OS_MAC - dataDir.cdUp(); - dataDir.cdUp(); - dataDir.cdUp(); -#endif - importer = new OracleImporter(dataDir.absolutePath(), this); + importer = new OracleImporter(QDesktopServices::storageLocation(QDesktopServices::DataLocation), this); nam = new QNetworkAccessManager(this); checkBoxLayout = new QVBoxLayout; @@ -167,17 +176,23 @@ void WindowMain::updateTotalProgress(int cardsImported, int setIndex, const QStr if (nextSetName.isEmpty()) { QMessageBox::information(this, tr("Oracle importer"), tr("Import finished: %1 cards.").arg(importer->getCardList().size())); bool ok = false; - QString savePath = importer->getDataDir() + "/cards.xml"; + const QString dataDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); + QDir dir(dataDir); + if (!dir.exists()) + dir.mkpath(dataDir); + QString savePath = dataDir + "/cards.xml"; do { QString fileName; if (savePath.isEmpty()) - fileName = QFileDialog::getSaveFileName(this, tr("Save card database"), importer->getDataDir() + "/cards.xml", tr("XML card database (*.xml)")); + fileName = QFileDialog::getSaveFileName(this, tr("Save card database"), dataDir + "/cards.xml", tr("XML card database (*.xml)")); else { fileName = savePath; savePath.clear(); } - if (fileName.isEmpty()) + if (fileName.isEmpty()) { qApp->quit(); + return; + } if (importer->saveToFile(fileName)) ok = true; else