mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Rework "paths" settings loading and card database loading
* main.cpp: removed path checking and db loading * card database: merge card loading methods into a single one * settings cache: take care of returning safe paths for decks, replays, etc.. * main window: if db loading fails (eg. first run), propose to run oracle NSIS: propose to run cockatrice instead of oracle Rework card database loading * Move carddatabase-related method out of deckeditor tab * Load cards in another thread and render them progressively * Optimize database reload after enabled sets change Fix deck editor column width * removed the noCard hack. * getCard() no more creates cards instead of just returning existing ones * Fix the “edit tokens” dialog. * PictureLoader: avoid trying to download twice the same card * PictureLoader: correct return of card background * AbstractCardItem: avoid recalculating card color at every paint Use a different file to save custom tokens Misc required improvements * Use nullptr; * Refactor CardInfoWidget to use CardInfoPicture and CardInfoText instead of duplicating code; * Added CardInfo::getColorChar() * Fixed some potential crashes * removed dead code related to CardInfoWidget * Don't require a restart after adding a new custom sets file * Bump CMake requirements to 3.1
This commit is contained in:
parent
0b8f52e084
commit
1e3fb6c6e1
41 changed files with 855 additions and 1074 deletions
|
|
@ -48,19 +48,7 @@ OracleWizard::OracleWizard(QWidget *parent)
|
|||
settings = new QSettings(settingsCache->getSettingsPath()+"global.ini",QSettings::IniFormat, this);
|
||||
connect(settingsCache, SIGNAL(langChanged()), this, SLOT(updateLanguage()));
|
||||
|
||||
QString dataDir;
|
||||
|
||||
#ifndef PORTABLE_BUILD
|
||||
#if QT_VERSION < 0x050000
|
||||
QDesktopServices::storageLocation(QDesktopServices::DataLocation);
|
||||
#else
|
||||
QStandardPaths::standardLocations(QStandardPaths::DataLocation).first();
|
||||
#endif
|
||||
#else
|
||||
dataDir.append("data");
|
||||
#endif
|
||||
|
||||
importer = new OracleImporter(dataDir, this);
|
||||
importer = new OracleImporter(settingsCache->getDataPath(), this);
|
||||
|
||||
addPage(new IntroPage);
|
||||
addPage(new LoadSetsPage);
|
||||
|
|
@ -521,47 +509,19 @@ void SaveSetsPage::updateTotalProgress(int cardsImported, int /* setIndex */, co
|
|||
bool SaveSetsPage::validatePage()
|
||||
{
|
||||
bool ok = false;
|
||||
QString dataDir;
|
||||
#ifndef PORTABLE_BUILD
|
||||
#if QT_VERSION < 0x050000
|
||||
dataDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
|
||||
#else
|
||||
dataDir = QStandardPaths::standardLocations(QStandardPaths::DataLocation).first();
|
||||
#endif
|
||||
#else
|
||||
dataDir = qApp->applicationDirPath() + "/data";
|
||||
#endif
|
||||
|
||||
#ifdef PORTABLE_BUILD
|
||||
QSettings* settings = new QSettings("settings/global.ini",QSettings::IniFormat,this);
|
||||
QString defaultPath = "data/cards.xml";
|
||||
settings->setValue("paths/carddatabase", defaultPath);
|
||||
#else
|
||||
QSettings* settings = new QSettings(settingsCache->getSettingsPath()+"global.ini",QSettings::IniFormat,this);
|
||||
QString defaultPath = settings->value("paths/carddatabase").toString();
|
||||
#endif
|
||||
QString defaultPath = settingsCache->getCardDatabasePath();
|
||||
QString windowName = tr("Save card database");
|
||||
QString fileType = tr("XML; card database (*.xml)");
|
||||
|
||||
do {
|
||||
QString fileName;
|
||||
if (defaultPath.isEmpty()) {
|
||||
if (defaultPathCheckBox->isChecked())
|
||||
fileName = dataDir + "/cards.xml";
|
||||
else
|
||||
fileName = QFileDialog::getSaveFileName(this, windowName, dataDir + "/cards.xml", fileType);
|
||||
if (defaultPathCheckBox->isChecked())
|
||||
fileName = defaultPath;
|
||||
else
|
||||
fileName = QFileDialog::getSaveFileName(this, windowName, defaultPath, fileType);
|
||||
|
||||
settings->setValue("paths/carddatabase", fileName);
|
||||
}
|
||||
else {
|
||||
if (defaultPathCheckBox->isChecked())
|
||||
fileName = defaultPath;
|
||||
else
|
||||
fileName = QFileDialog::getSaveFileName(this, windowName, defaultPath, fileType);
|
||||
}
|
||||
if (fileName.isEmpty()) {
|
||||
if (fileName.isEmpty())
|
||||
return false;
|
||||
}
|
||||
|
||||
QFileInfo fi(fileName);
|
||||
QDir fileDir(fi.path());
|
||||
|
|
@ -741,55 +701,24 @@ void SaveTokensPage::retranslateUi()
|
|||
"Press \"Save\" to save the imported tokens to the Cockatrice tokens database."));
|
||||
|
||||
defaultPathCheckBox->setText(tr("Save to the default path (recommended)"));
|
||||
#ifdef PORTABLE_BUILD
|
||||
defaultPathCheckBox->setEnabled(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool SaveTokensPage::validatePage()
|
||||
{
|
||||
bool ok = false;
|
||||
QString dataDir;
|
||||
#ifndef PORTABLE_BUILD
|
||||
#if QT_VERSION < 0x050000
|
||||
dataDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
|
||||
#else
|
||||
dataDir = QStandardPaths::standardLocations(QStandardPaths::DataLocation).first();
|
||||
#endif
|
||||
#else
|
||||
dataDir = qApp->applicationDirPath() + "/data";
|
||||
#endif
|
||||
|
||||
#ifdef PORTABLE_BUILD
|
||||
QSettings* settings = new QSettings("settings/global.ini",QSettings::IniFormat,this);
|
||||
QString defaultPath = "data/tokens.xml";
|
||||
settings->setValue("paths/tokendatabase", defaultPath);
|
||||
#else
|
||||
QSettings* settings = new QSettings(settingsCache->getSettingsPath()+"global.ini",QSettings::IniFormat,this);
|
||||
QString defaultPath = settings->value("paths/tokendatabase").toString();
|
||||
#endif
|
||||
|
||||
QString defaultPath = settingsCache->getTokenDatabasePath();
|
||||
QString windowName = tr("Save token database");
|
||||
QString fileType = tr("XML; token database (*.xml)");
|
||||
|
||||
do {
|
||||
QString fileName;
|
||||
if (defaultPath.isEmpty()) {
|
||||
if (defaultPathCheckBox->isChecked())
|
||||
fileName = dataDir + "/tokens.xml";
|
||||
else
|
||||
fileName = QFileDialog::getSaveFileName(this, windowName, dataDir + "/tokens.xml", fileType);
|
||||
settings->setValue("paths/tokendatabase", fileName);
|
||||
}
|
||||
else {
|
||||
if (defaultPathCheckBox->isChecked())
|
||||
fileName = defaultPath;
|
||||
else
|
||||
fileName = QFileDialog::getSaveFileName(this, windowName, defaultPath, fileType);
|
||||
}
|
||||
if (fileName.isEmpty()) {
|
||||
if (defaultPathCheckBox->isChecked())
|
||||
fileName = defaultPath;
|
||||
else
|
||||
fileName = QFileDialog::getSaveFileName(this, windowName, defaultPath, fileType);
|
||||
|
||||
if (fileName.isEmpty())
|
||||
return false;
|
||||
}
|
||||
|
||||
QFileInfo fi(fileName);
|
||||
QDir fileDir(fi.path());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue