MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / setUpdateAvailable

Method setUpdateAvailable

lib/QSimpleUpdater/src/Updater.cpp:468–529  ·  view source on GitHub ↗

* @brief Prompts the user based on the value of the @a available parameter and * the notification settings of this Updater instance. */

Source from the content-addressed store, hash-verified

466 * the notification settings of this Updater instance.
467 */
468void Updater::setUpdateAvailable(const bool available)
469{
470 m_updateAvailable = available;
471
472 QMessageBox box;
473 box.setTextFormat(Qt::RichText);
474 box.setIcon(QMessageBox::Information);
475
476 if (updateAvailable() && (notifyOnUpdate() || notifyOnFinish())) {
477 QString text = tr("Would you like to download the update now?");
478 if (m_mandatoryUpdate) {
479 text = tr("Would you like to download the update now?<br />This is a "
480 "mandatory update, exiting now will close the application.");
481 }
482
483 text += "<br/><br/>";
484 if (!m_changelog.isEmpty())
485 text += tr("<strong>Change log:</strong><br/>%1").arg(m_changelog);
486
487 QString title = "<h3>"
488 + tr("Version %1 of %2 has been released!").arg(latestVersion(), moduleName())
489 + "</h3>";
490
491 box.setText(title);
492 box.setInformativeText(text);
493 box.setStandardButtons(QMessageBox::No | QMessageBox::Yes);
494 box.setDefaultButton(QMessageBox::Yes);
495
496 if (box.exec() == QMessageBox::Yes) {
497 if (!openUrl().isEmpty())
498 QDesktopServices::openUrl(QUrl(openUrl()));
499
500 else if (downloaderEnabled()) {
501 m_downloader->setUrlId(url());
502 m_downloader->setFileName(downloadUrl().split("/").last());
503 m_downloader->setMandatoryUpdate(m_mandatoryUpdate);
504 auto download_url = QUrl(downloadUrl());
505 download_url.setUserName(m_downloadUserName);
506 download_url.setPassword(m_downloadPassword);
507 m_downloader->startDownload(download_url);
508 }
509
510 else
511 QDesktopServices::openUrl(QUrl(downloadUrl()));
512 } else {
513 if (m_mandatoryUpdate)
514 QApplication::quit();
515 }
516 }
517
518 else if (notifyOnFinish()) {
519 box.setStandardButtons(QMessageBox::Close);
520 box.setInformativeText(tr("No updates are available for the moment"));
521 box.setText("<h3>"
522 + tr("Congratulations! You are running the latest version "
523 "of %1")
524 .arg(moduleName())
525 + "</h3>");

Callers

nothing calls this directly

Calls 10

isEmptyMethod · 0.80
execMethod · 0.80
setUrlIdMethod · 0.80
lastMethod · 0.80
setUserNameMethod · 0.80
startDownloadMethod · 0.80
QUrlClass · 0.50
setFileNameMethod · 0.45
setMandatoryUpdateMethod · 0.45
setPasswordMethod · 0.45

Tested by

no test coverage detected