mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-28 00:42:19 -07:00
Merge 687a012d9b into 815c5987b4
This commit is contained in:
commit
85f024ee65
7 changed files with 43 additions and 9 deletions
|
|
@ -1027,7 +1027,7 @@ void MainWindow::createCardUpdateProcess(bool background)
|
||||||
if (updaterCmd.isEmpty()) {
|
if (updaterCmd.isEmpty()) {
|
||||||
QMessageBox::warning(this, tr("Error"),
|
QMessageBox::warning(this, tr("Error"),
|
||||||
tr("Unable to run the card database updater: ") + dir.absoluteFilePath(binaryName));
|
tr("Unable to run the card database updater: ") + dir.absoluteFilePath(binaryName));
|
||||||
exitCardDatabaseUpdate();
|
exitCardDatabaseUpdate(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1039,14 +1039,16 @@ void MainWindow::createCardUpdateProcess(bool background)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::exitCardDatabaseUpdate()
|
void MainWindow::exitCardDatabaseUpdate(bool reload)
|
||||||
{
|
{
|
||||||
cardUpdateProcess->deleteLater();
|
cardUpdateProcess->deleteLater();
|
||||||
cardUpdateProcess = nullptr;
|
cardUpdateProcess = nullptr;
|
||||||
statusBar()->clearMessage();
|
statusBar()->clearMessage();
|
||||||
|
|
||||||
|
if (reload) {
|
||||||
const auto reloadOk1 = QtConcurrent::run([] { CardDatabaseManager::getInstance()->loadCardDatabases(); });
|
const auto reloadOk1 = QtConcurrent::run([] { CardDatabaseManager::getInstance()->loadCardDatabases(); });
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::cardUpdateError(QProcess::ProcessError err)
|
void MainWindow::cardUpdateError(QProcess::ProcessError err)
|
||||||
{
|
{
|
||||||
|
|
@ -1076,16 +1078,21 @@ void MainWindow::cardUpdateError(QProcess::ProcessError err)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
exitCardDatabaseUpdate();
|
exitCardDatabaseUpdate(false);
|
||||||
QMessageBox::warning(this, tr("Error"), tr("The card database updater exited with an error:\n%1").arg(error));
|
QMessageBox::warning(this, tr("Error"), tr("The card database updater exited with an error:\n%1").arg(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::cardUpdateFinished(int, QProcess::ExitStatus exitStatus)
|
void MainWindow::cardUpdateFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||||
{
|
{
|
||||||
if (exitStatus == QProcess::NormalExit) {
|
if (exitStatus == QProcess::NormalExit && exitCode == 0) {
|
||||||
SettingsCache::instance().updates().setLastCardUpdateCheck(QDateTime::currentDateTime().date());
|
SettingsCache::instance().updates().setLastCardUpdateCheck(QDateTime::currentDateTime().date());
|
||||||
|
exitCardDatabaseUpdate(true);
|
||||||
|
} else {
|
||||||
|
exitCardDatabaseUpdate(false);
|
||||||
|
if (exitStatus == QProcess::NormalExit && exitCode != 0) {
|
||||||
|
statusBar()->showMessage(tr("Card database update cancelled."), 10000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
exitCardDatabaseUpdate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::actCheckServerUpdates()
|
void MainWindow::actCheckServerUpdates()
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ private:
|
||||||
return "oracle";
|
return "oracle";
|
||||||
}
|
}
|
||||||
void createCardUpdateProcess(bool background = false);
|
void createCardUpdateProcess(bool background = false);
|
||||||
void exitCardDatabaseUpdate();
|
void exitCardDatabaseUpdate(bool reload);
|
||||||
|
|
||||||
void startLocalGame(const LocalGameOptions &options);
|
void startLocalGame(const LocalGameOptions &options);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,5 +91,6 @@ int main(int argc, char *argv[])
|
||||||
QTimer::singleShot(0, &wizard, [&wizard]() { wizard.runInBackground(); });
|
QTimer::singleShot(0, &wizard, [&wizard]() { wizard.runInBackground(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
return app.exec();
|
const int execResult = app.exec();
|
||||||
|
return wizard.wasCancelled() ? 1 : execResult;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,18 @@ void OracleWizard::accept()
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OracleWizard::reject()
|
||||||
|
{
|
||||||
|
cancelled = true;
|
||||||
|
|
||||||
|
const auto replies = nam->findChildren<QNetworkReply *>();
|
||||||
|
for (QNetworkReply *reply : replies) {
|
||||||
|
reply->abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
QDialog::reject();
|
||||||
|
}
|
||||||
|
|
||||||
void OracleWizard::enableButtons()
|
void OracleWizard::enableButtons()
|
||||||
{
|
{
|
||||||
button(QWizard::NextButton)->setDisabled(false);
|
button(QWizard::NextButton)->setDisabled(false);
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,11 @@ class OracleWizard : public QWizard
|
||||||
public:
|
public:
|
||||||
explicit OracleWizard(QWidget *parent = nullptr);
|
explicit OracleWizard(QWidget *parent = nullptr);
|
||||||
void accept() override;
|
void accept() override;
|
||||||
|
void reject() override;
|
||||||
|
bool wasCancelled()
|
||||||
|
{
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
void enableButtons();
|
void enableButtons();
|
||||||
void disableButtons();
|
void disableButtons();
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
|
|
@ -74,6 +79,7 @@ private:
|
||||||
QByteArray tokensData;
|
QByteArray tokensData;
|
||||||
QString cardSourceUrl;
|
QString cardSourceUrl;
|
||||||
QString cardSourceVersion;
|
QString cardSourceVersion;
|
||||||
|
bool cancelled = false;
|
||||||
|
|
||||||
void migrateOracleSettings();
|
void migrateOracleSettings();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -350,6 +350,10 @@ void LoadSetsPage::actDownloadFinishedSetsFile()
|
||||||
{
|
{
|
||||||
// check for a reply
|
// check for a reply
|
||||||
auto *reply = dynamic_cast<QNetworkReply *>(sender());
|
auto *reply = dynamic_cast<QNetworkReply *>(sender());
|
||||||
|
if (wizard()->wasCancelled()) {
|
||||||
|
reply->deleteLater();
|
||||||
|
return;
|
||||||
|
}
|
||||||
auto errorCode = reply->error();
|
auto errorCode = reply->error();
|
||||||
if (errorCode != QNetworkReply::NoError) {
|
if (errorCode != QNetworkReply::NoError) {
|
||||||
QMessageBox::critical(this, tr("Error"), tr("Network error: %1.").arg(reply->errorString()));
|
QMessageBox::critical(this, tr("Error"), tr("Network error: %1.").arg(reply->errorString()));
|
||||||
|
|
|
||||||
|
|
@ -163,6 +163,10 @@ void SimpleDownloadFilePage::actDownloadFinished()
|
||||||
{
|
{
|
||||||
// check for a reply
|
// check for a reply
|
||||||
auto *reply = dynamic_cast<QNetworkReply *>(sender());
|
auto *reply = dynamic_cast<QNetworkReply *>(sender());
|
||||||
|
if (wizard()->wasCancelled()) {
|
||||||
|
reply->deleteLater();
|
||||||
|
return;
|
||||||
|
}
|
||||||
QNetworkReply::NetworkError errorCode = reply->error();
|
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()));
|
QMessageBox::critical(this, tr("Error"), tr("Network error: %1.").arg(reply->errorString()));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue