diff --git a/rpcs3/rpcs3qt/update_manager.cpp b/rpcs3/rpcs3qt/update_manager.cpp index 69c5bcc7e1..ea713c42e7 100644 --- a/rpcs3/rpcs3qt/update_manager.cpp +++ b/rpcs3/rpcs3qt/update_manager.cpp @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include #include #include @@ -39,6 +41,7 @@ LOG_CHANNEL(update_log, "UPDATER"); void update_manager::check_for_updates(bool automatic, bool check_only, bool auto_accept, QWidget* parent) { m_update_message.clear(); + m_changelog.clear(); #ifdef __linux__ if (automatic && !::getenv("APPIMAGE")) @@ -77,7 +80,7 @@ void update_manager::check_for_updates(bool automatic, bool check_only, bool aut Q_EMIT signal_update_available(result_json && !m_update_message.isEmpty()); }); - const std::string url = "https://update.rpcs3.net/?api=v1&c=" + rpcs3::get_commit_and_hash().second; + const std::string url = "https://update.rpcs3.net/?api=v2&c=" + rpcs3::get_commit_and_hash().second; m_downloader->start(url, true, !automatic, tr("Checking For Updates"), true); } @@ -218,6 +221,56 @@ bool update_manager::handle_json(bool automatic, bool check_only, bool auto_acce return true; } + if (!auto_accept) + { + const auto& changelog = json_data["changelog"]; + + if (changelog.isArray()) + { + for (const QJsonValue& changelog_entry : changelog.toArray()) + { + if (changelog_entry.isObject()) + { + changelog_data entry; + + if (QJsonValue version = changelog_entry["version"]; version.isString()) + { + entry.version = version.toString(); + } + else + { + entry.version = tr("N/A"); + update_log.notice("JSON changelog entry does not contain a version string."); + } + + if (QJsonValue title = changelog_entry["title"]; title.isString()) + { + entry.title = title.toString(); + } + else + { + entry.title = tr("N/A"); + update_log.notice("JSON changelog entry does not contain a title string."); + } + + m_changelog.push_back(entry); + } + else + { + update_log.error("JSON changelog entry is not an object."); + } + } + } + else if (changelog.isObject()) + { + update_log.error("JSON changelog is not an array."); + } + else + { + update_log.notice("JSON does not contain a changelog section."); + } + } + update(auto_accept); return true; } @@ -226,11 +279,44 @@ void update_manager::update(bool auto_accept) { ensure(m_downloader); - if (!auto_accept && (m_update_message.isEmpty() || - QMessageBox::question(m_downloader->get_progress_dialog() ? m_downloader->get_progress_dialog() : m_parent, tr("Update Available"), m_update_message, QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)) + if (!auto_accept) { - m_downloader->close_progress_dialog(); - return; + if (m_update_message.isEmpty()) + { + m_downloader->close_progress_dialog(); + return; + } + + QString changelog_content; + + for (const changelog_data& entry : m_changelog) + { + if (!changelog_content.isEmpty()) + changelog_content.append('\n'); + changelog_content.append(tr("• %0: %1").arg(entry.version, entry.title)); + } + + QMessageBox mb(QMessageBox::Icon::Question, tr("Update Available"), m_update_message, QMessageBox::Yes | QMessageBox::No,m_downloader->get_progress_dialog() ? m_downloader->get_progress_dialog() : m_parent); + + if (!changelog_content.isEmpty()) + { + mb.setInformativeText(tr("To see the changelog, please click \"Show Details\".")); + mb.setDetailedText(tr("Changelog:\n\n%0").arg(changelog_content)); + + // Smartass hack to make the unresizeable message box wide enough for the changelog + const int changelog_width = QLabel(changelog_content).sizeHint().width(); + while (QLabel(m_update_message).sizeHint().width() < changelog_width) + { + m_update_message += " "; + } + mb.setText(m_update_message); + } + + if (mb.exec() == QMessageBox::No) + { + m_downloader->close_progress_dialog(); + return; + } } if (!Emu.IsStopped()) diff --git a/rpcs3/rpcs3qt/update_manager.h b/rpcs3/rpcs3qt/update_manager.h index 146c470d20..75df7d6c10 100644 --- a/rpcs3/rpcs3qt/update_manager.h +++ b/rpcs3/rpcs3qt/update_manager.h @@ -19,6 +19,13 @@ private: // This message is empty if there is no download available QString m_update_message; + struct changelog_data + { + QString version; + QString title; + }; + std::vector m_changelog; + std::string m_request_url; std::string m_expected_hash; u64 m_expected_size = 0;