Qt: Use appropriate update dialog for if stuff can auto-update

This commit is contained in:
Vicki Pfau 2022-01-09 19:38:06 -08:00
parent 3402c151e6
commit 9335a82afb
2 changed files with 9 additions and 5 deletions

View File

@ -23,8 +23,15 @@ ApplicationUpdatePrompt::ApplicationUpdatePrompt(QWidget* parent)
ApplicationUpdater* updater = GBAApp::app()->updater();
ApplicationUpdater::UpdateInfo info = updater->updateInfo();
m_ui.text->setText(tr("An update to %1 is available.\nDo you want to download and install it now? You will need to restart the emulator when the download is complete.")
.arg(QLatin1String(projectName)));
QString updateText(tr("An update to %1 is available.\n").arg(QLatin1String(projectName)));
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
updateText += tr("\nDo you want to download and install it now? You will need to restart the emulator when the download is complete.");
m_okDownload = connect(m_ui.buttonBox, &QDialogButtonBox::accepted, this, &ApplicationUpdatePrompt::startUpdate);
#else
updateText += tr("\nAuto-update is not available on this platform. If you wish to update you will need to do it manually.");
connect(m_ui.buttonBox, &QDialogButtonBox::accepted, this, &QWidget::close);
#endif
m_ui.text->setText(updateText);
m_ui.details->setText(tr("Current version: %1\nNew version: %2\nDownload size: %3")
.arg(QLatin1String(projectVersion))
.arg(info)
@ -34,7 +41,6 @@ ApplicationUpdatePrompt::ApplicationUpdatePrompt(QWidget* parent)
connect(updater, &AbstractUpdater::updateProgress, this, [this](float progress) {
m_ui.progressBar->setValue(progress * 100);
});
m_okDownload = connect(m_ui.buttonBox, &QDialogButtonBox::accepted, this, &ApplicationUpdatePrompt::startUpdate);
connect(updater, &AbstractUpdater::updateDone, this, &ApplicationUpdatePrompt::promptRestart);
}

View File

@ -44,12 +44,10 @@ ApplicationUpdater::ApplicationUpdater(ConfigController* config, QObject* parent
config->setQtOption("lastUpdateCheck", m_lastCheck);
if (available && currentVersion() < updateInfo()) {
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
ApplicationUpdatePrompt* prompt = new ApplicationUpdatePrompt;
connect(prompt, &QDialog::accepted, GBAApp::app(), &GBAApp::restartForUpdate);
prompt->setAttribute(Qt::WA_DeleteOnClose);
prompt->show();
#endif
}
});