| 456 | } |
| 457 | |
| 458 | void AutoUpdaterDialog::downloadUpdateClicked() |
| 459 | { |
| 460 | if (m_update_will_break_save_states) |
| 461 | { |
| 462 | QMessageBox msgbox; |
| 463 | msgbox.setIcon(QMessageBox::Critical); |
| 464 | msgbox.setWindowModality(Qt::ApplicationModal); |
| 465 | msgbox.setWindowIcon(QtHost::GetAppIcon()); |
| 466 | msgbox.setWindowTitle(tr("Savestate Warning")); |
| 467 | msgbox.setText(tr("<h1>WARNING</h1><p style='font-size:12pt;'>Installing this update will make your <b>save states incompatible</b>, <i>be sure to save any progress to your memory cards before proceeding</i>.</p><p>Do you wish to continue?</p>")); |
| 468 | msgbox.addButton(QMessageBox::Yes); |
| 469 | msgbox.addButton(QMessageBox::No); |
| 470 | msgbox.setDefaultButton(QMessageBox::No); |
| 471 | // This makes the box wider, for some reason sizing boxes in Qt is hard - Source: The internet. |
| 472 | QSpacerItem* horizontalSpacer = new QSpacerItem(500, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); |
| 473 | QGridLayout* layout = (QGridLayout*)msgbox.layout(); |
| 474 | layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount()); |
| 475 | if (msgbox.exec() != QMessageBox::Yes) |
| 476 | return; |
| 477 | } |
| 478 | |
| 479 | m_display_messages = true; |
| 480 | |
| 481 | std::optional<bool> download_result; |
| 482 | QtModalProgressCallback progress(this); |
| 483 | progress.SetTitle(tr("Automatic Updater").toUtf8().constData()); |
| 484 | progress.SetStatusText(tr("Downloading %1...").arg(m_latest_version).toUtf8().constData()); |
| 485 | progress.GetDialog().setWindowIcon(windowIcon()); |
| 486 | progress.SetCancellable(true); |
| 487 | |
| 488 | m_http->CreateRequest( |
| 489 | m_download_url.toStdString(), |
| 490 | [this, &download_result, &progress](s32 status_code, const std::string&, std::vector<u8> data) { |
| 491 | if (status_code == HTTPDownloader::HTTP_STATUS_CANCELLED) |
| 492 | return; |
| 493 | |
| 494 | if (status_code != HTTPDownloader::HTTP_STATUS_OK) |
| 495 | { |
| 496 | reportError("Download failed: %d", status_code); |
| 497 | download_result = false; |
| 498 | return; |
| 499 | } |
| 500 | |
| 501 | if (data.empty()) |
| 502 | { |
| 503 | reportError("Download failed: Update is empty"); |
| 504 | download_result = false; |
| 505 | return; |
| 506 | } |
| 507 | |
| 508 | download_result = processUpdate(data, progress.GetDialog()); |
| 509 | }, |
| 510 | &progress); |
| 511 | |
| 512 | |
| 513 | // Since we're going to block, don't allow the timer to poll, otherwise the progress callback can cause the timer to |
| 514 | // run, and recursively poll again. |
| 515 | m_http_poll_timer->stop(); |
nothing calls this directly
no test coverage detected