From 5fc4fbcf3662a0f305b6d9926cd57dfdf9c181d3 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Fri, 8 Aug 2025 23:32:26 +1000 Subject: [PATCH] Qt: Improve display of version in updater --- src/duckstation-qt/autoupdaterwindow.cpp | 30 ++++++++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/duckstation-qt/autoupdaterwindow.cpp b/src/duckstation-qt/autoupdaterwindow.cpp index 4b8523c95..e47a15615 100644 --- a/src/duckstation-qt/autoupdaterwindow.cpp +++ b/src/duckstation-qt/autoupdaterwindow.cpp @@ -54,13 +54,11 @@ static constexpr u32 HTTP_POLL_INTERVAL = 10; // Requires that the channel be defined by the buildbot. #if __has_include("scmversion/tag.h") #include "scmversion/tag.h" -#if defined(SCM_RELEASE_TAGS) && defined(SCM_RELEASE_TAG) #define UPDATE_CHECKER_SUPPORTED #ifdef SCM_RELEASE_ASSET #define AUTO_UPDATER_SUPPORTED #endif #endif -#endif #ifdef UPDATE_CHECKER_SUPPORTED @@ -383,9 +381,31 @@ void AutoUpdaterWindow::getLatestReleaseComplete(s32 status_code, const Error& e { const QJsonObject doc_object(doc.object()); - m_ui.currentVersion->setText(tr("Current Version: %1 (%2)").arg(g_scm_hash_str).arg(g_scm_date_str)); - m_ui.newVersion->setText(tr("New Version: %1 (%2)").arg(m_latest_sha).arg(doc_object["published_at"].toString())); - m_ui.downloadSize->setText(tr("Download Size: %1 MB").arg(static_cast(m_download_size) / 1000000.0, 0, 'f', 2)); + const QString current_date = QtHost::FormatNumber( + Host::NumberFormatType::ShortDateTime, + static_cast( + QDateTime::fromString(QString::fromUtf8(g_scm_date_str), Qt::DateFormat::ISODate).toSecsSinceEpoch())); + const QString release_date = QtHost::FormatNumber( + Host::NumberFormatType::ShortDateTime, + static_cast( + QDateTime::fromString(doc_object["published_at"].toString(), Qt::DateFormat::ISODate).toSecsSinceEpoch())); + + // strip sha off the version + std::string_view current_version = g_scm_tag_str; + if (std::string_view::size_type pos = current_version.find('-'); pos != std::string_view::npos) + { + if (std::string_view::size_type pos2 = current_version.find('-', pos + 1); pos2 != std::string_view::npos) + current_version = current_version.substr(0, pos2); + } + + m_ui.currentVersion->setText( + tr("Current Version: %1 (%2)") + .arg(QtUtils::StringViewToQString(TinyString::from_format("{}/{}", current_version, THIS_RELEASE_TAG))) + .arg(current_date)); + m_ui.newVersion->setText( + tr("New Version: %1 (%2)").arg(QString::fromStdString(getCurrentUpdateTag())).arg(release_date)); + m_ui.downloadSize->setText( + tr("Download Size: %1 MB").arg(static_cast(m_download_size) / 1000000.0, 0, 'f', 2)); #ifdef AUTO_UPDATER_SUPPORTED // search for the correct file