From 7255530d8757f611607e0af130ef92cb94808413 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Wed, 30 Sep 2020 01:10:13 +1000 Subject: [PATCH] Qt: Minor improvements to auto-updater (icon, show download size) --- src/duckstation-qt/autoupdaterdialog.cpp | 9 ++-- src/duckstation-qt/autoupdaterdialog.h | 1 + src/duckstation-qt/autoupdaterdialog.ui | 67 ++++++++++++++---------- 3 files changed, 46 insertions(+), 31 deletions(-) diff --git a/src/duckstation-qt/autoupdaterdialog.cpp b/src/duckstation-qt/autoupdaterdialog.cpp index 7cd21d6f4..9e1dce0d3 100644 --- a/src/duckstation-qt/autoupdaterdialog.cpp +++ b/src/duckstation-qt/autoupdaterdialog.cpp @@ -53,9 +53,6 @@ AutoUpdaterDialog::AutoUpdaterDialog(QtHostInterface* host_interface, QWidget* p setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); - // m_ui.description->setTextInteractionFlags(Qt::TextBrowserInteraction); - // m_ui.description->setOpenExternalLinks(true); - connect(m_ui.downloadAndInstall, &QPushButton::clicked, this, &AutoUpdaterDialog::downloadUpdateClicked); connect(m_ui.skipThisUpdate, &QPushButton::clicked, this, &AutoUpdaterDialog::skipThisUpdateClicked); connect(m_ui.remindMeLater, &QPushButton::clicked, this, &AutoUpdaterDialog::remindMeLaterClicked); @@ -197,6 +194,7 @@ void AutoUpdaterDialog::getLatestReleaseComplete(QNetworkReply* reply) m_download_url = asset_obj["browser_download_url"].toString(); if (!m_download_url.isEmpty()) { + m_download_size = asset_obj["size"].toInt(); 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())); @@ -269,8 +267,10 @@ void AutoUpdaterDialog::getChangesComplete(QNetworkReply* reply) if (first_line_terminator >= 0) message.remove(first_line_terminator, message.size() - first_line_terminator); if (!message.isEmpty()) + { changes_html += QStringLiteral("
  • %1 (%2)
  • ").arg(message.toHtmlEscaped()).arg(author.toHtmlEscaped()); + } if (message.contains(QStringLiteral("[SAVEVERSION+]"))) update_will_break_save_states = true; @@ -285,6 +285,9 @@ void AutoUpdaterDialog::getChangesComplete(QNetworkReply* reply) "before installing this update or you will lose progress.

    ")); } + changes_html += tr("

    Installing this update will download %1 MB through your internet connection.

    ") + .arg(static_cast(m_download_size) / 1000000.0, 0, 'f', 2); + m_ui.updateNotes->setText(changes_html); } else diff --git a/src/duckstation-qt/autoupdaterdialog.h b/src/duckstation-qt/autoupdaterdialog.h index 9b2ca4808..6fede9e85 100644 --- a/src/duckstation-qt/autoupdaterdialog.h +++ b/src/duckstation-qt/autoupdaterdialog.h @@ -53,6 +53,7 @@ private: QNetworkAccessManager* m_network_access_mgr = nullptr; QString m_latest_sha; QString m_download_url; + int m_download_size = 0; bool m_display_messages = false; bool m_update_will_break_save_states = false; diff --git a/src/duckstation-qt/autoupdaterdialog.ui b/src/duckstation-qt/autoupdaterdialog.ui index 50dcd238c..f7a73e427 100644 --- a/src/duckstation-qt/autoupdaterdialog.ui +++ b/src/duckstation-qt/autoupdaterdialog.ui @@ -21,18 +21,38 @@ - - - - 16 - 75 - true - - - - Update Available - - + + + + + + 0 + 0 + + + + + + + :/icons/software-update-available.png + + + + + + + + 16 + 75 + true + + + + Update Available + + + + @@ -49,18 +69,7 @@ - - - Update Notes: - - - - - - - true - - + @@ -79,12 +88,12 @@ - - Download and Install... - false + + Download and Install... + @@ -108,6 +117,8 @@ - + + +