MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / checkForUpdates

Method checkForUpdates

pj_app/src/MainWindow.cpp:1688–1725  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1686}
1687
1688void MainWindow::checkForUpdates(bool interactive) {
1689 if (!update_checker_) {
1690 update_checker_ = new UpdateChecker(this);
1691 }
1692
1693 // Rebind the outcome handlers so this call's `interactive` is captured
1694 // per-request: checkLatestRelease() aborts any prior in-flight check (whose
1695 // handlers are disconnected here regardless), so the "up to date" / "couldn't
1696 // check" toasts can never be attributed to the wrong request.
1697 disconnect(update_available_conn_);
1698 disconnect(up_to_date_conn_);
1699 disconnect(check_failed_conn_);
1700
1701 update_available_conn_ =
1702 connect(update_checker_, &UpdateChecker::updateAvailable, this, [this](const ReleaseInfo& release) {
1703 QString message = tr("New release available: <b>%1</b>").arg(release.name.toHtmlEscaped());
1704 if (!release.html_url.isEmpty()) {
1705 message += QStringLiteral("<br>") + tr("<a href=\"%1\">View on GitHub</a>").arg(release.html_url);
1706 }
1707 showToast(message, QPixmap(QStringLiteral(":/resources/success_kid.png")));
1708 });
1709
1710 up_to_date_conn_ = connect(update_checker_, &UpdateChecker::upToDate, this, [this, interactive]() {
1711 if (interactive) {
1712 showToast(tr("PlotJuggler is up to date."));
1713 }
1714 });
1715
1716 check_failed_conn_ =
1717 connect(update_checker_, &UpdateChecker::checkFailed, this, [this, interactive](const QString& reason) {
1718 qWarning("Update check failed: %s", qUtf8Printable(reason));
1719 if (interactive) {
1720 showToast(tr("Could not check for updates. Please try again later."));
1721 }
1722 });
1723
1724 update_checker_->checkLatestRelease();
1725}
1726
1727void MainWindow::onCheckForUpdates() {
1728 checkForUpdates(/*interactive=*/true);

Callers 1

mainFunction · 0.80

Calls 4

trFunction · 0.85
checkLatestReleaseMethod · 0.80
QPixmapClass · 0.50
isEmptyMethod · 0.45

Tested by

no test coverage detected