MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / downloadUpdateClicked

Method downloadUpdateClicked

pcsx2-qt/AutoUpdaterDialog.cpp:458–532  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

456}
457
458void 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();

Callers

nothing calls this directly

Calls 12

setWindowTitleMethod · 0.80
argMethod · 0.80
CreateRequestMethod · 0.80
HasAnyRequestsMethod · 0.80
PollRequestsMethod · 0.80
rowCountMethod · 0.45
columnCountMethod · 0.45
SetTitleMethod · 0.45
SetStatusTextMethod · 0.45
SetCancellableMethod · 0.45
emptyMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected