mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-27 16:32:20 -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()) {
|
||||
QMessageBox::warning(this, tr("Error"),
|
||||
tr("Unable to run the card database updater: ") + dir.absoluteFilePath(binaryName));
|
||||
exitCardDatabaseUpdate();
|
||||
exitCardDatabaseUpdate(false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1039,13 +1039,15 @@ void MainWindow::createCardUpdateProcess(bool background)
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::exitCardDatabaseUpdate()
|
||||
void MainWindow::exitCardDatabaseUpdate(bool reload)
|
||||
{
|
||||
cardUpdateProcess->deleteLater();
|
||||
cardUpdateProcess = nullptr;
|
||||
statusBar()->clearMessage();
|
||||
|
||||
const auto reloadOk1 = QtConcurrent::run([] { CardDatabaseManager::getInstance()->loadCardDatabases(); });
|
||||
if (reload) {
|
||||
const auto reloadOk1 = QtConcurrent::run([] { CardDatabaseManager::getInstance()->loadCardDatabases(); });
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::cardUpdateError(QProcess::ProcessError err)
|
||||
|
|
@ -1076,16 +1078,21 @@ void MainWindow::cardUpdateError(QProcess::ProcessError err)
|
|||
break;
|
||||
}
|
||||
|
||||
exitCardDatabaseUpdate();
|
||||
exitCardDatabaseUpdate(false);
|
||||
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());
|
||||
exitCardDatabaseUpdate(true);
|
||||
} else {
|
||||
exitCardDatabaseUpdate(false);
|
||||
if (exitStatus == QProcess::NormalExit && exitCode != 0) {
|
||||
statusBar()->showMessage(tr("Card database update cancelled."), 10000);
|
||||
}
|
||||
}
|
||||
exitCardDatabaseUpdate();
|
||||
}
|
||||
|
||||
void MainWindow::actCheckServerUpdates()
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ private:
|
|||
return "oracle";
|
||||
}
|
||||
void createCardUpdateProcess(bool background = false);
|
||||
void exitCardDatabaseUpdate();
|
||||
void exitCardDatabaseUpdate(bool reload);
|
||||
|
||||
void startLocalGame(const LocalGameOptions &options);
|
||||
|
||||
|
|
|
|||
|
|
@ -91,5 +91,6 @@ int main(int argc, char *argv[])
|
|||
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();
|
||||
}
|
||||
|
||||
void OracleWizard::reject()
|
||||
{
|
||||
cancelled = true;
|
||||
|
||||
const auto replies = nam->findChildren<QNetworkReply *>();
|
||||
for (QNetworkReply *reply : replies) {
|
||||
reply->abort();
|
||||
}
|
||||
|
||||
QDialog::reject();
|
||||
}
|
||||
|
||||
void OracleWizard::enableButtons()
|
||||
{
|
||||
button(QWizard::NextButton)->setDisabled(false);
|
||||
|
|
|
|||
|
|
@ -23,6 +23,11 @@ class OracleWizard : public QWizard
|
|||
public:
|
||||
explicit OracleWizard(QWidget *parent = nullptr);
|
||||
void accept() override;
|
||||
void reject() override;
|
||||
bool wasCancelled()
|
||||
{
|
||||
return cancelled;
|
||||
}
|
||||
void enableButtons();
|
||||
void disableButtons();
|
||||
void retranslateUi();
|
||||
|
|
@ -74,6 +79,7 @@ private:
|
|||
QByteArray tokensData;
|
||||
QString cardSourceUrl;
|
||||
QString cardSourceVersion;
|
||||
bool cancelled = false;
|
||||
|
||||
void migrateOracleSettings();
|
||||
|
||||
|
|
|
|||
|
|
@ -350,6 +350,10 @@ void LoadSetsPage::actDownloadFinishedSetsFile()
|
|||
{
|
||||
// check for a reply
|
||||
auto *reply = dynamic_cast<QNetworkReply *>(sender());
|
||||
if (wizard()->wasCancelled()) {
|
||||
reply->deleteLater();
|
||||
return;
|
||||
}
|
||||
auto errorCode = reply->error();
|
||||
if (errorCode != QNetworkReply::NoError) {
|
||||
QMessageBox::critical(this, tr("Error"), tr("Network error: %1.").arg(reply->errorString()));
|
||||
|
|
|
|||
|
|
@ -163,6 +163,10 @@ void SimpleDownloadFilePage::actDownloadFinished()
|
|||
{
|
||||
// check for a reply
|
||||
auto *reply = dynamic_cast<QNetworkReply *>(sender());
|
||||
if (wizard()->wasCancelled()) {
|
||||
reply->deleteLater();
|
||||
return;
|
||||
}
|
||||
QNetworkReply::NetworkError errorCode = reply->error();
|
||||
if (errorCode != QNetworkReply::NoError) {
|
||||
QMessageBox::critical(this, tr("Error"), tr("Network error: %1.").arg(reply->errorString()));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue