Clang-format (#3028)

* 1/3 Add .clang-format file and travis compilation check

* 2/3 Run clang-format

* 3/3 Fix compilation problems due to include reordering

* 3bis/3 AfterControlStatement: false
This commit is contained in:
ctrlaltca 2018-01-27 10:41:32 +01:00 committed by GitHub
parent 8dbdd24c8e
commit b29bd9e070
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
272 changed files with 13378 additions and 9535 deletions

View file

@ -1,9 +1,9 @@
#include <QApplication>
#include <QTextCodec>
#include <QIcon>
#include <QTranslator>
#include <QLibraryInfo>
#include <QCommandLineParser>
#include <QIcon>
#include <QLibraryInfo>
#include <QTextCodec>
#include <QTranslator>
#include "main.h"
#include "oraclewizard.h"
@ -30,12 +30,12 @@ void installNewTranslator()
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QApplication app(argc, argv);
QCoreApplication::setOrganizationName("Cockatrice");
QCoreApplication::setOrganizationDomain("cockatrice");
// this can't be changed, as it influences the default savepath for cards.xml
QCoreApplication::setApplicationName("Cockatrice");
QCoreApplication::setOrganizationName("Cockatrice");
QCoreApplication::setOrganizationDomain("cockatrice");
// this can't be changed, as it influences the default savepath for cards.xml
QCoreApplication::setApplicationName("Cockatrice");
// If the program is opened with the -s flag, it will only do spoilers. Otherwise it will do MTGJSON/Tokens
QCommandLineParser parser;
@ -52,19 +52,19 @@ int main(int argc, char *argv[])
translationPath = qApp->applicationDirPath() + "/../share/cockatrice/translations";
#endif
settingsCache = new SettingsCache;
settingsCache = new SettingsCache;
themeManager = new ThemeManager;
qtTranslator = new QTranslator;
translator = new QTranslator;
installNewTranslator();
OracleWizard wizard;
OracleWizard wizard;
QIcon icon("theme:appicon.svg");
wizard.setWindowIcon(icon);
wizard.show();
wizard.show();
return app.exec();
return app.exec();
}

View file

@ -1,26 +1,25 @@
#include "oracleimporter.h"
#include <QtWidgets>
#include <QDebug>
#include <QtWidgets>
#include "qt-json/json.h"
OracleImporter::OracleImporter(const QString &_dataDir, QObject *parent)
: CardDatabase(parent), dataDir(_dataDir)
OracleImporter::OracleImporter(const QString &_dataDir, QObject *parent) : CardDatabase(parent), dataDir(_dataDir)
{
}
bool OracleImporter::readSetsFromByteArray(const QByteArray &data)
{
QList<SetToDownload> newSetList;
bool ok;
setsMap = QtJson::Json::parse(QString(data), ok).toMap();
if (!ok) {
qDebug() << "error: QtJson::Json::parse()";
return 0;
}
QListIterator<QVariant> it(setsMap.values());
QVariantMap map;
@ -37,7 +36,7 @@ bool OracleImporter::readSetsFromByteArray(const QByteArray &data)
editionCards = map.value("cards");
setType = map.value("type").toString();
// capitalize set type
if(setType.length() > 0)
if (setType.length() > 0)
setType[0] = setType[0].toUpper();
releaseDate = map.value("releaseDate").toDate();
@ -63,12 +62,11 @@ CardInfo *OracleImporter::addCard(const QString &setName,
const QString &cardPT,
int cardLoyalty,
const QString &cardText,
const QStringList & colors,
const QList<CardRelation *> & relatedCards,
const QList<CardRelation *> & reverseRelatedCards,
const QStringList &colors,
const QList<CardRelation *> &relatedCards,
const QList<CardRelation *> &reverseRelatedCards,
bool upsideDown,
QString &rarity
)
QString &rarity)
{
QStringList cardTextRows = cardText.split("\n");
@ -76,7 +74,7 @@ CardInfo *OracleImporter::addCard(const QString &setName,
cardName = cardName.replace("Æ", "AE");
cardName = cardName.replace("", "'");
CardInfo * card;
CardInfo *card;
if (cards.contains(cardName)) {
card = cards.value(cardName);
} else {
@ -92,10 +90,13 @@ CardInfo *OracleImporter::addCard(const QString &setName,
mArtifact = true;
// detect cards that enter the field tapped
bool cipt = cardText.contains("Hideaway") || (cardText.contains(cardName + " enters the battlefield tapped") && !cardText.contains(cardName + " enters the battlefield tapped unless"));
bool cipt =
cardText.contains("Hideaway") || (cardText.contains(cardName + " enters the battlefield tapped") &&
!cardText.contains(cardName + " enters the battlefield tapped unless"));
// insert the card and its properties
card = new CardInfo(cardName, isToken, cardCost, cmc, cardType, cardPT, cardText, colors, relatedCards, reverseRelatedCards, upsideDown, cardLoyalty, cipt);
card = new CardInfo(cardName, isToken, cardCost, cmc, cardType, cardPT, cardText, colors, relatedCards,
reverseRelatedCards, upsideDown, cardLoyalty, cipt);
int tableRow = 1;
QString mainCardType = card->getMainCardType();
if ((mainCardType == "Land") || mArtifact)
@ -105,7 +106,7 @@ CardInfo *OracleImporter::addCard(const QString &setName,
else if (mainCardType == "Creature")
tableRow = 2;
card->setTableRow(tableRow);
cards.insert(cardName, card);
}
card->setMuId(setName, cardId);
@ -115,10 +116,9 @@ CardInfo *OracleImporter::addCard(const QString &setName,
return card;
}
void OracleImporter::extractColors(const QStringList & in, QStringList & out)
void OracleImporter::extractColors(const QStringList &in, QStringList &out)
{
foreach(QString c, in)
{
foreach (QString c, in) {
if (c == "White")
out << "W";
else if (c == "Blue")
@ -137,7 +137,7 @@ void OracleImporter::extractColors(const QStringList & in, QStringList & out)
int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data)
{
int cards = 0;
QListIterator<QVariant> it(data.toList());
QVariantMap map;
QString cardName;
@ -156,21 +156,19 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data)
bool upsideDown = false;
QMap<int, QVariantMap> splitCards;
while (it.hasNext())
{
while (it.hasNext()) {
map = it.next().toMap();
QString layout = map.value("layout").toString();
if(layout == "token")
if (layout == "token")
continue;
if(layout == "split" || layout == "aftermath")
{
if (layout == "split" || layout == "aftermath") {
// Enqueue split card for later handling
cardId = map.contains("multiverseid") ? map.value("multiverseid").toInt() : 0;
if (cardId)
splitCards.insertMulti(cardId, map);
splitCards.insertMulti(cardId, map);
continue;
}
@ -179,21 +177,22 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data)
cardCost = map.contains("manaCost") ? map.value("manaCost").toString() : QString("");
cmc = map.contains("cmc") ? map.value("cmc").toString() : QString("0");
cardType = map.contains("type") ? map.value("type").toString() : QString("");
cardPT = map.contains("power") || map.contains("toughness") ? map.value("power").toString() + QString('/') + map.value("toughness").toString() : QString("");
cardPT = map.contains("power") || map.contains("toughness")
? map.value("power").toString() + QString('/') + map.value("toughness").toString()
: QString("");
cardText = map.contains("text") ? map.value("text").toString() : QString("");
cardId = map.contains("multiverseid") ? map.value("multiverseid").toInt() : 0;
setNumber = map.contains("number") ? map.value("number").toString() : QString("");
rarity = map.contains("rarity") ? map.value("rarity").toString() : QString("");
cardLoyalty = map.contains("loyalty") ? map.value("loyalty").toInt() : 0;
relatedCards = QList<CardRelation *>();
if(map.contains("names"))
foreach(const QString & name, map.value("names").toStringList()) {
if(name != cardName)
if (map.contains("names"))
foreach (const QString &name, map.value("names").toStringList()) {
if (name != cardName)
relatedCards.append(new CardRelation(name, true));
}
if(0 == QString::compare(map.value("layout").toString(), QString("flip"), Qt::CaseInsensitive))
{
if (0 == QString::compare(map.value("layout").toString(), QString("flip"), Qt::CaseInsensitive)) {
QStringList cardNames = map.contains("names") ? map.value("names").toStringList() : QStringList();
upsideDown = (cardNames.indexOf(cardName) > 0);
} else {
@ -203,26 +202,26 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data)
colors.clear();
extractColors(map.value("colors").toStringList(), colors);
CardInfo *card = addCard(set->getShortName(), cardName, false, cardId, setNumber, cardCost, cmc, cardType, cardPT, cardLoyalty, cardText, colors, relatedCards, reverseRelatedCards, upsideDown, rarity);
CardInfo *card =
addCard(set->getShortName(), cardName, false, cardId, setNumber, cardCost, cmc, cardType, cardPT,
cardLoyalty, cardText, colors, relatedCards, reverseRelatedCards, upsideDown, rarity);
if (!set->contains(card)) {
card->addToSet(set);
cards++;
}
}
// split cards handling - get all unique card muids
QList<int> muids = splitCards.uniqueKeys();
foreach(int muid, muids)
{
foreach (int muid, muids) {
// get all cards for this specific muid
QList<QVariantMap> maps = splitCards.values(muid);
QStringList names;
// now, reorder the cards using the ordered list of names
QMap<int, QVariantMap> orderedMaps;
foreach(QVariantMap map, maps)
{
if(names.isEmpty())
foreach (QVariantMap map, maps) {
if (names.isEmpty())
names = map.contains("names") ? map.value("names").toStringList() : QStringList();
QString name = map.value("name").toString();
int index = names.indexOf(name);
@ -236,7 +235,7 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data)
cardType = "";
cardPT = "";
cardText = "";
setNumber = "";
setNumber = "";
rarity = "";
colors.clear();
// this is currently an integer; can't accept 2 values
@ -245,47 +244,39 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data)
// loop cards and merge their contents
QString prefix = QString(" // ");
QString prefix2 = QString("\n\n---\n\n");
foreach(QVariantMap map, orderedMaps.values())
{
if(map.contains("name"))
{
if(!cardName.isEmpty())
cardName += (orderedMaps.count() > 2) ? QString("/") : prefix;
foreach (QVariantMap map, orderedMaps.values()) {
if (map.contains("name")) {
if (!cardName.isEmpty())
cardName += (orderedMaps.count() > 2) ? QString("/") : prefix;
cardName += map.value("name").toString();
}
if(map.contains("manaCost"))
{
if(!cardCost.isEmpty())
if (map.contains("manaCost")) {
if (!cardCost.isEmpty())
cardCost += prefix;
cardCost += map.value("manaCost").toString();
}
if(map.contains("cmc"))
{
if(!cmc.isEmpty())
if (map.contains("cmc")) {
if (!cmc.isEmpty())
cmc += prefix;
cmc += map.value("cmc").toString();
}
if(map.contains("type"))
{
if(!cardType.isEmpty())
if (map.contains("type")) {
if (!cardType.isEmpty())
cardType += prefix;
cardType += map.value("type").toString();
}
if(map.contains("power") || map.contains("toughness"))
{
if(!cardPT.isEmpty())
if (map.contains("power") || map.contains("toughness")) {
if (!cardPT.isEmpty())
cardPT += prefix;
cardPT += map.value("power").toString() + QString('/') + map.value("toughness").toString();
}
if(map.contains("text"))
{
if(!cardText.isEmpty())
if (map.contains("text")) {
if (!cardText.isEmpty())
cardText += prefix2;
cardText += map.value("text").toString();
}
if(map.contains("number"))
{
if(setNumber.isEmpty())
if (map.contains("number")) {
if (setNumber.isEmpty())
setNumber = map.value("number").toString();
}
@ -293,19 +284,19 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data)
}
colors.removeDuplicates();
//Fortunately, there are no split cards that flip, transform or meld.
// Fortunately, there are no split cards that flip, transform or meld.
relatedCards = QList<CardRelation *>();
reverseRelatedCards = QList<CardRelation *>();
upsideDown = false;
// add the card
CardInfo *card = addCard(set->getShortName(), cardName, false, muid, setNumber, cardCost, cmc, cardType, cardPT, cardLoyalty, cardText, colors, relatedCards, reverseRelatedCards, upsideDown, rarity);
CardInfo *card = addCard(set->getShortName(), cardName, false, muid, setNumber, cardCost, cmc, cardType, cardPT,
cardLoyalty, cardText, colors, relatedCards, reverseRelatedCards, upsideDown, rarity);
if (!set->contains(card)) {
card->addToSet(set);
cards++;
}
}
return cards;
@ -315,28 +306,28 @@ int OracleImporter::startImport()
{
clear();
int setCards = 0, setIndex= 0;
int setCards = 0, setIndex = 0;
QListIterator<SetToDownload> it(allSets);
const SetToDownload * curSet;
const SetToDownload *curSet;
// add an empty set for tokens
CardSet *tokenSet = new CardSet(TOKENS_SETNAME, tr("Dummy set containing tokens"), "Tokens");
sets.insert(TOKENS_SETNAME, tokenSet);
while (it.hasNext())
{
curSet = & it.next();
CardSet *set = new CardSet(curSet->getShortName(), curSet->getLongName(), curSet->getSetType(), curSet->getReleaseDate());
while (it.hasNext()) {
curSet = &it.next();
CardSet *set =
new CardSet(curSet->getShortName(), curSet->getLongName(), curSet->getSetType(), curSet->getReleaseDate());
if (!sets.contains(set->getShortName()))
sets.insert(set->getShortName(), set);
int setCards = importTextSpoiler(set, curSet->getCards());
++setIndex;
emit setIndexChanged(setCards, setIndex, curSet->getLongName());
}
emit setIndexChanged(setCards, setIndex, QString());
// total number of sets

View file

@ -6,60 +6,93 @@
#include <carddatabase.h>
class SetToDownload {
class SetToDownload
{
private:
QString shortName, longName;
QVariant cards;
QDate releaseDate;
QString setType;
public:
const QString &getShortName() const { return shortName; }
const QString &getLongName() const { return longName; }
const QVariant &getCards() const { return cards; }
const QString &getSetType() const { return setType; }
const QDate &getReleaseDate() const { return releaseDate; }
SetToDownload(const QString &_shortName, const QString &_longName, const QVariant &_cards, const QString &_setType = QString(), const QDate &_releaseDate = QDate())
: shortName(_shortName), longName(_longName), cards(_cards), releaseDate(_releaseDate), setType(_setType) { }
bool operator<(const SetToDownload &set) const { return longName.compare(set.longName, Qt::CaseInsensitive) < 0; }
const QString &getShortName() const
{
return shortName;
}
const QString &getLongName() const
{
return longName;
}
const QVariant &getCards() const
{
return cards;
}
const QString &getSetType() const
{
return setType;
}
const QDate &getReleaseDate() const
{
return releaseDate;
}
SetToDownload(const QString &_shortName,
const QString &_longName,
const QVariant &_cards,
const QString &_setType = QString(),
const QDate &_releaseDate = QDate())
: shortName(_shortName), longName(_longName), cards(_cards), releaseDate(_releaseDate), setType(_setType)
{
}
bool operator<(const SetToDownload &set) const
{
return longName.compare(set.longName, Qt::CaseInsensitive) < 0;
}
};
class OracleImporter : public CardDatabase {
class OracleImporter : public CardDatabase
{
Q_OBJECT
private:
QList<SetToDownload> allSets;
QVariantMap setsMap;
QString dataDir;
CardInfo *addCard(
const QString &setName,
QString cardName,
bool isToken,
int cardId,
QString &setNumber,
QString &cardCost,
QString &cmc,
const QString &cardType,
const QString &cardPT,
int cardLoyalty,
const QString &cardText,
const QStringList & colors,
const QList<CardRelation *> & relatedCards,
const QList<CardRelation *> & reverseRelatedCards,
bool upsideDown,
QString &rarity
);
CardInfo *addCard(const QString &setName,
QString cardName,
bool isToken,
int cardId,
QString &setNumber,
QString &cardCost,
QString &cmc,
const QString &cardType,
const QString &cardPT,
int cardLoyalty,
const QString &cardText,
const QStringList &colors,
const QList<CardRelation *> &relatedCards,
const QList<CardRelation *> &reverseRelatedCards,
bool upsideDown,
QString &rarity);
signals:
void setIndexChanged(int cardsImported, int setIndex, const QString &setName);
void dataReadProgress(int bytesRead, int totalBytes);
public:
OracleImporter(const QString &_dataDir, QObject *parent = 0);
bool readSetsFromByteArray(const QByteArray &data);
int startImport();
int importTextSpoiler(CardSet *set, const QVariant &data);
QList<SetToDownload> &getSets() { return allSets; }
const QString &getDataDir() const { return dataDir; }
QList<SetToDownload> &getSets()
{
return allSets;
}
const QString &getDataDir() const
{
return dataDir;
}
protected:
void extractColors(const QStringList & in, QStringList & out);
void extractColors(const QStringList &in, QStringList &out);
};
#endif

View file

@ -1,14 +1,11 @@
#include <QtGui>
#include <QStandardPaths>
#include <QtConcurrent>
#include <QAbstractButton>
#include <QBuffer>
#include <QCheckBox>
#include <QComboBox>
#include <QDir>
#include <QFileDialog>
#include <QGridLayout>
#include <QLabel>
#include <QComboBox>
#include <QLineEdit>
#include <QMessageBox>
#include <QNetworkAccessManager>
@ -18,11 +15,14 @@
#include <QRadioButton>
#include <QScrollArea>
#include <QScrollBar>
#include <QStandardPaths>
#include <QTextEdit>
#include <QtConcurrent>
#include <QtGui>
#include "oraclewizard.h"
#include "oracleimporter.h"
#include "main.h"
#include "oracleimporter.h"
#include "oraclewizard.h"
#include "settingscache.h"
#include "version_string.h"
@ -30,10 +30,10 @@
#define ALLSETS_URL_FALLBACK "https://mtgjson.com/json/AllSets.json"
#ifdef HAS_ZLIB
#include "zip/unzip.h"
#define ALLSETS_URL "https://mtgjson.com/json/AllSets.json.zip"
#include "zip/unzip.h"
#define ALLSETS_URL "https://mtgjson.com/json/AllSets.json.zip"
#else
#define ALLSETS_URL "https://mtgjson.com/json/AllSets.json"
#define ALLSETS_URL "https://mtgjson.com/json/AllSets.json"
#endif
#define TOKENS_URL "https://raw.githubusercontent.com/Cockatrice/Magic-Token/master/tokens.xml"
@ -41,21 +41,18 @@
OracleWizard::OracleWizard(QWidget *parent) : QWizard(parent)
{
settings = new QSettings(settingsCache->getSettingsPath()+"global.ini",QSettings::IniFormat, this);
settings = new QSettings(settingsCache->getSettingsPath() + "global.ini", QSettings::IniFormat, this);
connect(settingsCache, SIGNAL(langChanged()), this, SLOT(updateLanguage()));
importer = new OracleImporter(settingsCache->getDataPath(), this);
if (! isSpoilersOnly)
{
if (!isSpoilersOnly) {
addPage(new IntroPage);
addPage(new LoadSetsPage);
addPage(new SaveSetsPage);
addPage(new LoadTokensPage);
addPage(new SaveTokensPage);
}
else
{
} else {
addPage(new LoadSpoilersPage);
addPage(new SaveSpoilersPage);
}
@ -71,8 +68,7 @@ void OracleWizard::updateLanguage()
void OracleWizard::changeEvent(QEvent *event)
{
if (event->type() == QEvent::LanguageChange)
{
if (event->type() == QEvent::LanguageChange) {
retranslateUi();
}
@ -83,9 +79,8 @@ void OracleWizard::retranslateUi()
{
setWindowTitle(tr("Oracle Importer"));
QWizard::setButtonText(QWizard::FinishButton, tr("Save"));
for (int i = 0; i < pageIds().count(); i++)
{
for (int i = 0; i < pageIds().count(); i++) {
dynamic_cast<OracleWizardPage *>(page(i))->retranslateUi();
}
}
@ -107,17 +102,15 @@ void OracleWizard::disableButtons()
button(QWizard::BackButton)->setDisabled(true);
}
bool OracleWizard::saveTokensToFile(const QString & fileName)
bool OracleWizard::saveTokensToFile(const QString &fileName)
{
QFile file(fileName);
if (!file.open(QIODevice::WriteOnly))
{
if (!file.open(QIODevice::WriteOnly)) {
qDebug() << "File open (w) failed for" << fileName;
return false;
}
if (file.write(tokensData) == -1)
{
if (file.write(tokensData) == -1) {
qDebug() << "File write (w) failed for" << fileName;
return false;
}
@ -137,12 +130,11 @@ IntroPage::IntroPage(QWidget *parent) : OracleWizardPage(parent)
QString setLanguage = settingsCache->getLang();
QStringList qmFiles = findQmFiles();
for (int i = 0; i < qmFiles.size(); i++)
{
for (int i = 0; i < qmFiles.size(); i++) {
QString langName = languageName(qmFiles[i]);
languageBox->addItem(langName, qmFiles[i]);
if ((qmFiles[i] == setLanguage) || (setLanguage.isEmpty() && langName == QCoreApplication::translate("i18n", DEFAULT_LANG_NAME)))
{
if ((qmFiles[i] == setLanguage) ||
(setLanguage.isEmpty() && langName == QCoreApplication::translate("i18n", DEFAULT_LANG_NAME))) {
languageBox->setCurrentIndex(i);
}
}
@ -168,14 +160,13 @@ QStringList IntroPage::findQmFiles()
QString IntroPage::languageName(const QString &qmFile)
{
if (qmFile == DEFAULT_LANG_CODE)
{
if (qmFile == DEFAULT_LANG_CODE) {
return DEFAULT_LANG_NAME;
}
QTranslator translator;
translator.load(translationPrefix + "_" + qmFile + ".qm", translationPath);
return translator.translate("i18n", DEFAULT_LANG_NAME);
}
@ -257,20 +248,18 @@ void LoadSetsPage::actLoadSetsFile()
{
QFileDialog dialog(this, tr("Load sets file"));
dialog.setFileMode(QFileDialog::ExistingFile);
#ifdef HAS_ZLIB
dialog.setNameFilter(tr("Sets JSON file (*.json *.zip)"));
#else
dialog.setNameFilter(tr("Sets JSON file (*.json)"));
#endif
if (!fileLineEdit->text().isEmpty() && QFile::exists(fileLineEdit->text()))
{
if (!fileLineEdit->text().isEmpty() && QFile::exists(fileLineEdit->text())) {
dialog.selectFile(fileLineEdit->text());
}
if (!dialog.exec())
{
if (!dialog.exec()) {
return;
}
@ -280,17 +269,14 @@ void LoadSetsPage::actLoadSetsFile()
bool LoadSetsPage::validatePage()
{
// once the import is finished, we call next(); skip validation
if (wizard()->importer->getSets().count() > 0)
{
if (wizard()->importer->getSets().count() > 0) {
return true;
}
// else, try to import sets
if (urlRadioButton->isChecked())
{
if (urlRadioButton->isChecked()) {
QUrl url = QUrl::fromUserInput(urlLineEdit->text());
if (!url.isValid())
{
if (!url.isValid()) {
QMessageBox::critical(this, tr("Error"), tr("The provided URL is not valid."));
return false;
}
@ -307,18 +293,14 @@ bool LoadSetsPage::validatePage()
setEnabled(false);
downloadSetsFile(url);
}
else if (fileRadioButton->isChecked())
{
} else if (fileRadioButton->isChecked()) {
QFile setsFile(fileLineEdit->text());
if (!setsFile.exists())
{
if (!setsFile.exists()) {
QMessageBox::critical(this, tr("Error"), tr("Please choose a file."));
return false;
}
if (!setsFile.open(QIODevice::ReadOnly))
{
if (!setsFile.open(QIODevice::ReadOnly)) {
QMessageBox::critical(nullptr, tr("Error"), tr("Cannot open file '%1'.").arg(fileLineEdit->text()));
return false;
}
@ -327,7 +309,6 @@ bool LoadSetsPage::validatePage()
setEnabled(false);
readSetsFromByteArray(setsFile.readAll());
}
return false;
@ -335,8 +316,7 @@ bool LoadSetsPage::validatePage()
void LoadSetsPage::downloadSetsFile(QUrl url)
{
if (!nam)
{
if (!nam) {
nam = new QNetworkAccessManager(this);
}
QNetworkReply *reply = nam->get(QNetworkRequest(url));
@ -347,12 +327,11 @@ void LoadSetsPage::downloadSetsFile(QUrl url)
void LoadSetsPage::actDownloadProgressSetsFile(qint64 received, qint64 total)
{
if (total > 0)
{
if (total > 0) {
progressBar->setMaximum(static_cast<int>(total));
progressBar->setValue(static_cast<int>(received));
}
progressLabel->setText(tr("Downloading (%1MB)").arg((int) received / (1024 * 1024)));
progressLabel->setText(tr("Downloading (%1MB)").arg((int)received / (1024 * 1024)));
}
void LoadSetsPage::actDownloadFinishedSetsFile()
@ -360,8 +339,7 @@ void LoadSetsPage::actDownloadFinishedSetsFile()
// check for a reply
auto *reply = dynamic_cast<QNetworkReply *>(sender());
QNetworkReply::NetworkError errorCode = reply->error();
if (errorCode != QNetworkReply::NoError)
{
if (errorCode != QNetworkReply::NoError) {
QMessageBox::critical(this, tr("Error"), tr("Network error: %1.").arg(reply->errorString()));
wizard()->enableButtons();
@ -372,8 +350,7 @@ void LoadSetsPage::actDownloadFinishedSetsFile()
}
int statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
if (statusCode == 301 || statusCode == 302)
{
if (statusCode == 301 || statusCode == 302) {
QUrl redirectUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
qDebug() << "following redirect url:" << redirectUrl.toString();
downloadSetsFile(redirectUrl);
@ -385,12 +362,9 @@ void LoadSetsPage::actDownloadFinishedSetsFile()
progressBar->hide();
// save allsets.json url, but only if the user customized it and download was successfull
if (urlLineEdit->text() != QString(ALLSETS_URL))
{
if (urlLineEdit->text() != QString(ALLSETS_URL)) {
wizard()->settings->setValue("allsetsurl", urlLineEdit->text());
}
else
{
} else {
wizard()->settings->remove("allsetsurl");
}
@ -409,8 +383,7 @@ void LoadSetsPage::readSetsFromByteArray(QByteArray data)
progressBar->show();
// unzip the file if needed
if(data.startsWith(ZIP_SIGNATURE))
{
if (data.startsWith(ZIP_SIGNATURE)) {
#ifdef HAS_ZLIB
// zipped file
auto *inBuffer = new QBuffer(&data);
@ -420,23 +393,20 @@ void LoadSetsPage::readSetsFromByteArray(QByteArray data)
UnZip uz;
ec = uz.openArchive(inBuffer);
if (ec != UnZip::Ok)
{
if (ec != UnZip::Ok) {
zipDownloadFailed(tr("Failed to open Zip archive: %1.").arg(uz.formatError(ec)));
return;
}
if (uz.fileList().size() != 1)
{
if (uz.fileList().size() != 1) {
zipDownloadFailed(tr("Zip extraction failed: the Zip archive doesn't contain exactly one file."));
return;
return;
}
fileName = uz.fileList().at(0);
outBuffer->open(QBuffer::ReadWrite);
ec = uz.extractFile(fileName, outBuffer);
if (ec != UnZip::Ok)
{
if (ec != UnZip::Ok) {
zipDownloadFailed(tr("Zip extraction failed: %1.").arg(uz.formatError(ec)));
uz.closeArchive();
return;
@ -454,7 +424,7 @@ void LoadSetsPage::readSetsFromByteArray(QByteArray data)
progressBar->hide();
return;
#endif
}
}
// Start the computation.
future = QtConcurrent::run(wizard()->importer, &OracleImporter::readSetsFromByteArray, data);
watcher.setFuture(future);
@ -468,10 +438,12 @@ void LoadSetsPage::zipDownloadFailed(const QString &message)
progressBar->hide();
QMessageBox::StandardButton reply;
reply = static_cast<QMessageBox::StandardButton>(QMessageBox::question(this, tr("Error"), message + "<br/>" + tr("Do you want to try to download a fresh copy of the uncompressed file instead?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes));
reply = static_cast<QMessageBox::StandardButton>(QMessageBox::question(
this, tr("Error"),
message + "<br/>" + tr("Do you want to try to download a fresh copy of the uncompressed file instead?"),
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes));
if (reply == QMessageBox::Yes)
{
if (reply == QMessageBox::Yes) {
urlRadioButton->setChecked(true);
urlLineEdit->setText(ALLSETS_URL_FALLBACK);
@ -486,13 +458,11 @@ void LoadSetsPage::importFinished()
progressLabel->hide();
progressBar->hide();
if (watcher.future().result())
{
if (watcher.future().result()) {
wizard()->next();
}
else
{
QMessageBox::critical(this, tr("Error"), tr("The file was retrieved successfully, but it does not contain any sets data."));
} else {
QMessageBox::critical(this, tr("Error"),
tr("The file was retrieved successfully, but it does not contain any sets data."));
}
}
@ -520,10 +490,10 @@ void SaveSetsPage::initializePage()
{
messageLog->clear();
connect(wizard()->importer, SIGNAL(setIndexChanged(int, int, const QString &)), this, SLOT(updateTotalProgress(int, int, const QString &)));
connect(wizard()->importer, SIGNAL(setIndexChanged(int, int, const QString &)), this,
SLOT(updateTotalProgress(int, int, const QString &)));
if (!wizard()->importer->startImport())
{
if (!wizard()->importer->startImport()) {
QMessageBox::critical(this, tr("Error"), tr("No set has been imported."));
}
}
@ -539,13 +509,11 @@ void SaveSetsPage::retranslateUi()
void SaveSetsPage::updateTotalProgress(int cardsImported, int /* setIndex */, const QString &setName)
{
if (setName.isEmpty())
{
messageLog->append("<b>" + tr("Import finished: %1 cards.").arg(wizard()->importer->getCardList().size()) + "</b>");
}
else
{
messageLog->append(tr("%1: %2 cards imported").arg(setName).arg(cardsImported));
if (setName.isEmpty()) {
messageLog->append("<b>" + tr("Import finished: %1 cards.").arg(wizard()->importer->getCardList().size()) +
"</b>");
} else {
messageLog->append(tr("%1: %2 cards imported").arg(setName).arg(cardsImported));
}
messageLog->verticalScrollBar()->setValue(messageLog->verticalScrollBar()->maximum());
@ -558,42 +526,32 @@ bool SaveSetsPage::validatePage()
QString windowName = tr("Save card database");
QString fileType = tr("XML; card database (*.xml)");
do
{
do {
QString fileName;
if (defaultPathCheckBox->isChecked())
{
if (defaultPathCheckBox->isChecked()) {
fileName = defaultPath;
}
else
{
} else {
fileName = QFileDialog::getSaveFileName(this, windowName, defaultPath, fileType);
}
if (fileName.isEmpty())
{
if (fileName.isEmpty()) {
return false;
}
QFileInfo fi(fileName);
QDir fileDir(fi.path());
if (!fileDir.exists() && !fileDir.mkpath(fileDir.absolutePath()))
{
if (!fileDir.exists() && !fileDir.mkpath(fileDir.absolutePath())) {
return false;
}
if (wizard()->importer->saveToFile(fileName))
{
if (wizard()->importer->saveToFile(fileName)) {
ok = true;
QMessageBox::information(this,
tr("Success"),
tr("The card database has been saved successfully to\n%1").arg(fileName));
}
else
{
QMessageBox::critical(this, tr("Error"), tr("The file could not be saved to %1").arg(fileName));;
if (defaultPathCheckBox->isChecked())
{
QMessageBox::information(this, tr("Success"),
tr("The card database has been saved successfully to\n%1").arg(fileName));
} else {
QMessageBox::critical(this, tr("Error"), tr("The file could not be saved to %1").arg(fileName));
;
if (defaultPathCheckBox->isChecked()) {
defaultPathCheckBox->setChecked(false);
}
}
@ -636,13 +594,12 @@ void LoadSpoilersPage::initializePage()
void LoadSpoilersPage::actDownloadProgressSpoilersFile(qint64 received, qint64 total)
{
if (total > 0)
{
if (total > 0) {
progressBar->setMaximum(static_cast<int>(total));
progressBar->setValue(static_cast<int>(received));
}
progressLabel->setText(tr("Downloading (%1MB)").arg((int) received / (1024 * 1024)));
progressLabel->setText(tr("Downloading (%1MB)").arg((int)received / (1024 * 1024)));
}
void LoadSpoilersPage::actDownloadFinishedSpoilersFile()
@ -651,8 +608,7 @@ void LoadSpoilersPage::actDownloadFinishedSpoilersFile()
auto *reply = dynamic_cast<QNetworkReply *>(sender());
QNetworkReply::NetworkError errorCode = reply->error();
if (errorCode != QNetworkReply::NoError)
{
if (errorCode != QNetworkReply::NoError) {
QMessageBox::critical(this, tr("Error"), tr("Network error: %1.").arg(reply->errorString()));
wizard()->enableButtons();
@ -663,8 +619,7 @@ void LoadSpoilersPage::actDownloadFinishedSpoilersFile()
}
int statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
if (statusCode == 301 || statusCode == 302)
{
if (statusCode == 301 || statusCode == 302) {
QUrl redirectUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
qDebug() << "following redirect url:" << redirectUrl.toString();
downloadSpoilersFile(redirectUrl);
@ -676,12 +631,9 @@ void LoadSpoilersPage::actDownloadFinishedSpoilersFile()
progressBar->hide();
// save spoiler.xml url, but only if the user customized it and download was successful
if (urlLineEdit->text() != QString(SPOILERS_URL))
{
if (urlLineEdit->text() != QString(SPOILERS_URL)) {
wizard()->settings->setValue("spoilersurl", urlLineEdit->text());
}
else
{
} else {
wizard()->settings->remove("spoilersurl");
}
@ -698,27 +650,25 @@ void LoadSpoilersPage::actDownloadFinishedSpoilersFile()
void LoadSpoilersPage::downloadSpoilersFile(QUrl url)
{
if (!nam)
{
if (!nam) {
nam = new QNetworkAccessManager(this);
}
QNetworkReply *reply = nam->get(QNetworkRequest(url));
connect(reply, SIGNAL(finished()), this, SLOT(actDownloadFinishedSpoilersFile()));
connect(reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(actDownloadProgressSpoilersFile(qint64, qint64)));
connect(reply, SIGNAL(downloadProgress(qint64, qint64)), this,
SLOT(actDownloadProgressSpoilersFile(qint64, qint64)));
}
bool LoadSpoilersPage::validatePage()
{
// once the import is finished, we call next(); skip validation
if (wizard()->hasTokensData())
{
if (wizard()->hasTokensData()) {
return true;
}
QUrl url = QUrl::fromUserInput(urlLineEdit->text());
if (!url.isValid())
{
if (!url.isValid()) {
QMessageBox::critical(this, tr("Error"), tr("The provided URL is not valid."));
return false;
}
@ -793,14 +743,12 @@ void LoadTokensPage::actRestoreDefaultUrl()
bool LoadTokensPage::validatePage()
{
// once the import is finished, we call next(); skip validation
if (wizard()->hasTokensData())
{
if (wizard()->hasTokensData()) {
return true;
}
QUrl url = QUrl::fromUserInput(urlLineEdit->text());
if (!url.isValid())
{
if (!url.isValid()) {
QMessageBox::critical(this, tr("Error"), tr("The provided URL is not valid."));
return false;
}
@ -822,8 +770,7 @@ bool LoadTokensPage::validatePage()
void LoadTokensPage::downloadTokensFile(QUrl url)
{
if (!nam)
{
if (!nam) {
nam = new QNetworkAccessManager(this);
}
QNetworkReply *reply = nam->get(QNetworkRequest(url));
@ -834,12 +781,11 @@ void LoadTokensPage::downloadTokensFile(QUrl url)
void LoadTokensPage::actDownloadProgressTokensFile(qint64 received, qint64 total)
{
if (total > 0)
{
if (total > 0) {
progressBar->setMaximum(static_cast<int>(total));
progressBar->setValue(static_cast<int>(received));
}
progressLabel->setText(tr("Downloading (%1MB)").arg((int) received / (1024 * 1024)));
progressLabel->setText(tr("Downloading (%1MB)").arg((int)received / (1024 * 1024)));
}
void LoadTokensPage::actDownloadFinishedTokensFile()
@ -847,8 +793,7 @@ void LoadTokensPage::actDownloadFinishedTokensFile()
// check for a reply
auto *reply = dynamic_cast<QNetworkReply *>(sender());
QNetworkReply::NetworkError errorCode = reply->error();
if (errorCode != QNetworkReply::NoError)
{
if (errorCode != QNetworkReply::NoError) {
QMessageBox::critical(this, tr("Error"), tr("Network error: %1.").arg(reply->errorString()));
wizard()->enableButtons();
@ -859,8 +804,7 @@ void LoadTokensPage::actDownloadFinishedTokensFile()
}
int statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
if (statusCode == 301 || statusCode == 302)
{
if (statusCode == 301 || statusCode == 302) {
QUrl redirectUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
qDebug() << "following redirect url:" << redirectUrl.toString();
downloadTokensFile(redirectUrl);
@ -872,12 +816,9 @@ void LoadTokensPage::actDownloadFinishedTokensFile()
progressBar->hide();
// save tokens.xml url, but only if the user customized it and download was successfull
if (urlLineEdit->text() != QString(TOKENS_URL))
{
if (urlLineEdit->text() != QString(TOKENS_URL)) {
wizard()->settings->setValue("tokensurl", urlLineEdit->text());
}
else
{
} else {
wizard()->settings->remove("tokensurl");
}
@ -901,14 +842,13 @@ SaveSpoilersPage::SaveSpoilersPage(QWidget *parent) : OracleWizardPage(parent)
layout->addWidget(defaultPathCheckBox, 0, 0);
setLayout(layout);
}
void SaveSpoilersPage::retranslateUi()
{
setTitle(tr("Spoilers imported"));
setSubTitle(tr("The spoilers file has been imported. "
"Press \"Save\" to save the imported spoilers to the Cockatrice card database."));
"Press \"Save\" to save the imported spoilers to the Cockatrice card database."));
defaultPathCheckBox->setText(tr("Save to the default path (recommended)"));
}
@ -920,39 +860,30 @@ bool SaveSpoilersPage::validatePage()
QString windowName = tr("Save spoiler database");
QString fileType = tr("XML; card database (*.xml)");
do
{
do {
QString fileName;
if (defaultPathCheckBox->isChecked())
{
if (defaultPathCheckBox->isChecked()) {
fileName = defaultPath;
}
else
{
} else {
fileName = QFileDialog::getSaveFileName(this, windowName, defaultPath, fileType);
}
if (fileName.isEmpty())
{
if (fileName.isEmpty()) {
return false;
}
QFileInfo fi(fileName);
QDir fileDir(fi.path());
if (!fileDir.exists() && !fileDir.mkpath(fileDir.absolutePath()))
{
if (!fileDir.exists() && !fileDir.mkpath(fileDir.absolutePath())) {
return false;
}
if (wizard()->saveTokensToFile(fileName))
{
if (wizard()->saveTokensToFile(fileName)) {
ok = true;
}
else
{
QMessageBox::critical(this, tr("Error"), tr("The file could not be saved to %1").arg(fileName));;
if (defaultPathCheckBox->isChecked())
{
} else {
QMessageBox::critical(this, tr("Error"), tr("The file could not be saved to %1").arg(fileName));
;
if (defaultPathCheckBox->isChecked()) {
defaultPathCheckBox->setChecked(false);
}
}
@ -988,43 +919,32 @@ bool SaveTokensPage::validatePage()
QString windowName = tr("Save token database");
QString fileType = tr("XML; token database (*.xml)");
do
{
do {
QString fileName;
if (defaultPathCheckBox->isChecked())
{
if (defaultPathCheckBox->isChecked()) {
fileName = defaultPath;
}
else
{
} else {
fileName = QFileDialog::getSaveFileName(this, windowName, defaultPath, fileType);
}
if (fileName.isEmpty())
{
if (fileName.isEmpty()) {
return false;
}
QFileInfo fi(fileName);
QDir fileDir(fi.path());
if (!fileDir.exists() && !fileDir.mkpath(fileDir.absolutePath()))
{
if (!fileDir.exists() && !fileDir.mkpath(fileDir.absolutePath())) {
return false;
}
if (wizard()->saveTokensToFile(fileName))
{
if (wizard()->saveTokensToFile(fileName)) {
ok = true;
QMessageBox::information(this,
tr("Success"),
tr("The token database has been saved successfully to\n%1").arg(fileName));
}
else
{
QMessageBox::critical(this, tr("Error"), tr("The file could not be saved to %1").arg(fileName));;
if (defaultPathCheckBox->isChecked())
{
QMessageBox::information(this, tr("Success"),
tr("The token database has been saved successfully to\n%1").arg(fileName));
} else {
QMessageBox::critical(this, tr("Error"), tr("The file could not be saved to %1").arg(fileName));
;
if (defaultPathCheckBox->isChecked()) {
defaultPathCheckBox->setChecked(false);
}
}

View file

@ -1,9 +1,9 @@
#ifndef ORACLEWIZARD_H
#define ORACLEWIZARD_H
#include <QWizard>
#include <QFutureWatcher>
#include <QFuture>
#include <QFutureWatcher>
#include <QWizard>
#include <utility>
class QCheckBox;
@ -22,194 +22,203 @@ class QSettings;
class OracleWizard : public QWizard
{
Q_OBJECT
public:
explicit OracleWizard(QWidget *parent = nullptr);
void accept() override;
void enableButtons();
void disableButtons();
void retranslateUi();
void setTokensData(QByteArray _tokensData) { tokensData = std::move(_tokensData); }
bool hasTokensData() { return !tokensData.isEmpty(); }
bool saveTokensToFile(const QString & fileName);
public:
explicit OracleWizard(QWidget *parent = nullptr);
void accept() override;
void enableButtons();
void disableButtons();
void retranslateUi();
void setTokensData(QByteArray _tokensData)
{
tokensData = std::move(_tokensData);
}
bool hasTokensData()
{
return !tokensData.isEmpty();
}
bool saveTokensToFile(const QString &fileName);
public:
OracleImporter *importer;
QSettings *settings;
public:
OracleImporter *importer;
QSettings *settings;
private slots:
void updateLanguage();
private slots:
void updateLanguage();
private:
QByteArray tokensData;
private:
QByteArray tokensData;
protected:
void changeEvent(QEvent *event) override;
protected:
void changeEvent(QEvent *event) override;
};
class OracleWizardPage : public QWizardPage
{
Q_OBJECT
public:
explicit OracleWizardPage(QWidget *parent = nullptr): QWizardPage(parent) {};
virtual void retranslateUi() = 0;
public:
explicit OracleWizardPage(QWidget *parent = nullptr) : QWizardPage(parent){};
virtual void retranslateUi() = 0;
protected:
inline OracleWizard *wizard() { return (OracleWizard*) QWizardPage::wizard(); };
protected:
inline OracleWizard *wizard()
{
return (OracleWizard *)QWizardPage::wizard();
};
};
class IntroPage : public OracleWizardPage
{
Q_OBJECT
public:
explicit IntroPage(QWidget *parent = nullptr);
void retranslateUi() override;
public:
explicit IntroPage(QWidget *parent = nullptr);
void retranslateUi() override;
private:
QStringList findQmFiles();
QString languageName(const QString &qmFile);
private:
QStringList findQmFiles();
QString languageName(const QString &qmFile);
private:
QLabel *label, *languageLabel, *versionLabel;
QComboBox *languageBox;
private:
QLabel *label, *languageLabel, *versionLabel;
QComboBox *languageBox;
private slots:
void languageBoxChanged(int index);
private slots:
void languageBoxChanged(int index);
};
class LoadSetsPage : public OracleWizardPage
{
Q_OBJECT
public:
explicit LoadSetsPage(QWidget *parent = nullptr);
void retranslateUi() override;
Q_OBJECT
public:
explicit LoadSetsPage(QWidget *parent = nullptr);
void retranslateUi() override;
protected:
void initializePage() override;
bool validatePage() override;
void readSetsFromByteArray(QByteArray data);
void downloadSetsFile(QUrl url);
protected:
void initializePage() override;
bool validatePage() override;
void readSetsFromByteArray(QByteArray data);
void downloadSetsFile(QUrl url);
private:
QRadioButton *urlRadioButton;
QRadioButton *fileRadioButton;
QLineEdit *urlLineEdit;
QLineEdit *fileLineEdit;
QPushButton *urlButton;
QPushButton *fileButton;
QLabel *progressLabel;
QProgressBar *progressBar;
private:
QRadioButton *urlRadioButton;
QRadioButton *fileRadioButton;
QLineEdit *urlLineEdit;
QLineEdit *fileLineEdit;
QPushButton *urlButton;
QPushButton *fileButton;
QLabel *progressLabel;
QProgressBar *progressBar;
QNetworkAccessManager *nam;
QFutureWatcher<bool> watcher;
QFuture<bool> future;
QNetworkAccessManager *nam;
QFutureWatcher<bool> watcher;
QFuture<bool> future;
private slots:
void actLoadSetsFile();
void actRestoreDefaultUrl();
void actDownloadProgressSetsFile(qint64 received, qint64 total);
void actDownloadFinishedSetsFile();
void importFinished();
void zipDownloadFailed(const QString &message);
private slots:
void actLoadSetsFile();
void actRestoreDefaultUrl();
void actDownloadProgressSetsFile(qint64 received, qint64 total);
void actDownloadFinishedSetsFile();
void importFinished();
void zipDownloadFailed(const QString &message);
};
class SaveSetsPage : public OracleWizardPage
{
Q_OBJECT
public:
explicit SaveSetsPage(QWidget *parent = nullptr);
void retranslateUi() override;
public:
explicit SaveSetsPage(QWidget *parent = nullptr);
void retranslateUi() override;
private:
QTextEdit *messageLog;
QCheckBox *defaultPathCheckBox;
private:
QTextEdit *messageLog;
QCheckBox *defaultPathCheckBox;
protected:
void initializePage() override;
void cleanupPage() override;
bool validatePage() override;
protected:
void initializePage() override;
void cleanupPage() override;
bool validatePage() override;
private slots:
void updateTotalProgress(int cardsImported, int setIndex, const QString &setName);
private slots:
void updateTotalProgress(int cardsImported, int setIndex, const QString &setName);
};
class LoadSpoilersPage : public OracleWizardPage
{
Q_OBJECT
public:
explicit LoadSpoilersPage(QWidget *parent = nullptr);
void retranslateUi() override;
public:
explicit LoadSpoilersPage(QWidget *parent = nullptr);
void retranslateUi() override;
private:
QLabel *urlLabel;
QLineEdit *urlLineEdit;
QPushButton *urlButton;
QLabel *progressLabel;
QProgressBar *progressBar;
QNetworkAccessManager *nam;
private:
QLabel *urlLabel;
QLineEdit *urlLineEdit;
QPushButton *urlButton;
QLabel *progressLabel;
QProgressBar *progressBar;
QNetworkAccessManager *nam;
private slots:
void actRestoreDefaultUrl();
void actDownloadProgressSpoilersFile(qint64 received, qint64 total);
void actDownloadFinishedSpoilersFile();
private slots:
void actRestoreDefaultUrl();
void actDownloadProgressSpoilersFile(qint64 received, qint64 total);
void actDownloadFinishedSpoilersFile();
protected:
void initializePage() override;
bool validatePage() override;
void downloadSpoilersFile(QUrl url);
protected:
void initializePage() override;
bool validatePage() override;
void downloadSpoilersFile(QUrl url);
};
class SaveSpoilersPage : public OracleWizardPage
{
Q_OBJECT
public:
explicit SaveSpoilersPage(QWidget *parent = nullptr);
void retranslateUi() override;
public:
explicit SaveSpoilersPage(QWidget *parent = nullptr);
void retranslateUi() override;
private:
QCheckBox *defaultPathCheckBox;
private:
QCheckBox *defaultPathCheckBox;
protected:
bool validatePage() override;
protected:
bool validatePage() override;
};
class LoadTokensPage : public OracleWizardPage
{
Q_OBJECT
public:
explicit LoadTokensPage(QWidget *parent = nullptr);
void retranslateUi() override;
public:
explicit LoadTokensPage(QWidget *parent = nullptr);
void retranslateUi() override;
protected:
void initializePage() override;
bool validatePage() override;
void downloadTokensFile(QUrl url);
protected:
void initializePage() override;
bool validatePage() override;
void downloadTokensFile(QUrl url);
private:
QLabel *urlLabel;
QLineEdit *urlLineEdit;
QPushButton *urlButton;
QLabel *progressLabel;
QProgressBar *progressBar;
QNetworkAccessManager *nam;
private:
QLabel *urlLabel;
QLineEdit *urlLineEdit;
QPushButton *urlButton;
QLabel *progressLabel;
QProgressBar *progressBar;
QNetworkAccessManager *nam;
private slots:
void actRestoreDefaultUrl();
void actDownloadProgressTokensFile(qint64 received, qint64 total);
void actDownloadFinishedTokensFile();
private slots:
void actRestoreDefaultUrl();
void actDownloadProgressTokensFile(qint64 received, qint64 total);
void actDownloadFinishedTokensFile();
};
class SaveTokensPage : public OracleWizardPage
{
Q_OBJECT
public:
explicit SaveTokensPage(QWidget *parent = nullptr);
void retranslateUi() override;
public:
explicit SaveTokensPage(QWidget *parent = nullptr);
void retranslateUi() override;
private:
QCheckBox *defaultPathCheckBox;
private:
QCheckBox *defaultPathCheckBox;
protected:
bool validatePage() override;
protected:
bool validatePage() override;
};
#endif