mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 16:24:45 -07:00
Automatic Spoiler Season (#2991)
* oracle now can be run in spoiler or normal mode * tests for travis * only run on relaunch * spoilers in client (not oracle now) and tray icon shows when done * spoiler status will be checked before downloading spoiler file * only download if they care about spoilers * reload db on spoiler download * manual update button, code cleanup, and fix enabling sets when new * cleanup, nullchecks, and fixes to spoiler * reload DB even if not in spoiler season; necessary as we have a check elsewhere to prevent the reload if spoiler check happens * Implement changes from 2991#issuecomment-356169374 * Change implicit nullptrs, alert on file deletion, minor changes * make reload thread safe and minor changes from 2991#issuecomment-356450302 * Fix locking * Disable update now button while process running
This commit is contained in:
parent
51ec593759
commit
d19744236e
23 changed files with 2106 additions and 913 deletions
|
|
@ -4,6 +4,7 @@
|
|||
#include <QWizard>
|
||||
#include <QFutureWatcher>
|
||||
#include <QFuture>
|
||||
#include <utility>
|
||||
|
||||
class QCheckBox;
|
||||
class QGroupBox;
|
||||
|
|
@ -20,139 +21,195 @@ class QSettings;
|
|||
|
||||
class OracleWizard : public QWizard
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
OracleWizard(QWidget *parent = 0);
|
||||
void accept();
|
||||
void enableButtons();
|
||||
void disableButtons();
|
||||
void retranslateUi();
|
||||
void setTokensData(QByteArray _tokensData) { tokensData = _tokensData; }
|
||||
bool hasTokensData() { return !tokensData.isEmpty(); }
|
||||
bool saveTokensToFile(const QString & fileName);
|
||||
public:
|
||||
OracleImporter *importer;
|
||||
QSettings * settings;
|
||||
private slots:
|
||||
void updateLanguage();
|
||||
private:
|
||||
QStringList findQmFiles();
|
||||
QString languageName(const QString &qmFile);
|
||||
QByteArray tokensData;
|
||||
protected:
|
||||
void changeEvent(QEvent *event);
|
||||
};
|
||||
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:
|
||||
OracleImporter *importer;
|
||||
QSettings *settings;
|
||||
|
||||
private slots:
|
||||
void updateLanguage();
|
||||
|
||||
private:
|
||||
QByteArray tokensData;
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *event) override;
|
||||
};
|
||||
|
||||
class OracleWizardPage : public QWizardPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
OracleWizardPage(QWidget *parent = 0): QWizardPage(parent) {};
|
||||
virtual void retranslateUi() = 0;
|
||||
protected:
|
||||
inline OracleWizard *wizard() { return (OracleWizard*) QWizardPage::wizard(); };
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit OracleWizardPage(QWidget *parent = nullptr): QWizardPage(parent) {};
|
||||
virtual void retranslateUi() = 0;
|
||||
|
||||
protected:
|
||||
inline OracleWizard *wizard() { return (OracleWizard*) QWizardPage::wizard(); };
|
||||
};
|
||||
|
||||
class IntroPage : public OracleWizardPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
IntroPage(QWidget *parent = 0);
|
||||
void retranslateUi();
|
||||
private:
|
||||
QStringList findQmFiles();
|
||||
QString languageName(const QString &qmFile);
|
||||
private:
|
||||
QLabel *label, *languageLabel, *versionLabel;
|
||||
QComboBox *languageBox;
|
||||
private slots:
|
||||
void languageBoxChanged(int index);
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit IntroPage(QWidget *parent = nullptr);
|
||||
void retranslateUi() override;
|
||||
|
||||
private:
|
||||
QStringList findQmFiles();
|
||||
QString languageName(const QString &qmFile);
|
||||
|
||||
private:
|
||||
QLabel *label, *languageLabel, *versionLabel;
|
||||
QComboBox *languageBox;
|
||||
|
||||
private slots:
|
||||
void languageBoxChanged(int index);
|
||||
};
|
||||
|
||||
class LoadSetsPage : public OracleWizardPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
LoadSetsPage(QWidget *parent = 0);
|
||||
void retranslateUi();
|
||||
protected:
|
||||
void initializePage();
|
||||
bool validatePage();
|
||||
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;
|
||||
public:
|
||||
explicit LoadSetsPage(QWidget *parent = nullptr);
|
||||
void retranslateUi() override;
|
||||
|
||||
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);
|
||||
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;
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
class SaveSetsPage : public OracleWizardPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SaveSetsPage(QWidget *parent = 0);
|
||||
void retranslateUi();
|
||||
private:
|
||||
QTextEdit *messageLog;
|
||||
QCheckBox * defaultPathCheckBox;
|
||||
protected:
|
||||
void initializePage();
|
||||
void cleanupPage();
|
||||
bool validatePage();
|
||||
private slots:
|
||||
void updateTotalProgress(int cardsImported, int setIndex, const QString &setName);
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SaveSetsPage(QWidget *parent = nullptr);
|
||||
void retranslateUi() override;
|
||||
|
||||
private:
|
||||
QTextEdit *messageLog;
|
||||
QCheckBox *defaultPathCheckBox;
|
||||
|
||||
protected:
|
||||
void initializePage() override;
|
||||
void cleanupPage() override;
|
||||
bool validatePage() override;
|
||||
|
||||
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;
|
||||
|
||||
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();
|
||||
|
||||
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;
|
||||
|
||||
private:
|
||||
QCheckBox *defaultPathCheckBox;
|
||||
|
||||
protected:
|
||||
bool validatePage() override;
|
||||
};
|
||||
|
||||
class LoadTokensPage : public OracleWizardPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
LoadTokensPage(QWidget *parent = 0);
|
||||
void retranslateUi();
|
||||
protected:
|
||||
void initializePage();
|
||||
bool validatePage();
|
||||
void downloadTokensFile(QUrl url);
|
||||
private:
|
||||
QLabel *urlLabel;
|
||||
QLineEdit *urlLineEdit;
|
||||
QPushButton *urlButton;
|
||||
QLabel *progressLabel;
|
||||
QProgressBar * progressBar;
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LoadTokensPage(QWidget *parent = nullptr);
|
||||
void retranslateUi() override;
|
||||
|
||||
QNetworkAccessManager *nam;
|
||||
private slots:
|
||||
void actRestoreDefaultUrl();
|
||||
void actDownloadProgressTokensFile(qint64 received, qint64 total);
|
||||
void actDownloadFinishedTokensFile();
|
||||
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 slots:
|
||||
void actRestoreDefaultUrl();
|
||||
void actDownloadProgressTokensFile(qint64 received, qint64 total);
|
||||
void actDownloadFinishedTokensFile();
|
||||
};
|
||||
|
||||
class SaveTokensPage : public OracleWizardPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SaveTokensPage(QWidget *parent = 0);
|
||||
void retranslateUi();
|
||||
private:
|
||||
QCheckBox * defaultPathCheckBox;
|
||||
protected:
|
||||
bool validatePage();
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SaveTokensPage(QWidget *parent = nullptr);
|
||||
void retranslateUi() override;
|
||||
|
||||
private:
|
||||
QCheckBox *defaultPathCheckBox;
|
||||
|
||||
protected:
|
||||
bool validatePage() override;
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue