From 3dd05ff869e5113fc9a5f474786c226dd556fc1b Mon Sep 17 00:00:00 2001 From: Chris Bessent Date: Mon, 8 Feb 2021 08:24:51 -0700 Subject: Create a new dialog for the update window The idea here is to be able to resize the window and better handle markdown formatting. Everything was stolen from the LOOT dialog. --- src/selfupdater.cpp | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'src/selfupdater.cpp') diff --git a/src/selfupdater.cpp b/src/selfupdater.cpp index 70ab9090..68aecc46 100644 --- a/src/selfupdater.cpp +++ b/src/selfupdater.cpp @@ -32,6 +32,7 @@ along with Mod Organizer. If not, see . #include #include #include "shared/util.h" +#include "updatedialog.h" #include #include @@ -164,10 +165,9 @@ void SelfUpdater::startUpdate() auto latestRelease = m_UpdateCandidates.begin()->second; - QMessageBox query(QMessageBox::Question, - tr("New update available (%1)") - .arg(latestRelease["tag_name"].toString()), tr("Do you want to install update? All your mods and setup will be left untouched.\nSelect Show Details option to see the full change-log."), - QMessageBox::Yes | QMessageBox::Cancel, m_Parent); + UpdateDialog dialog(m_Parent, tr("New update available (%1 -> %2)") + .arg(MOShared::createVersionInfo().displayString(3)) + .arg(latestRelease["tag_name"].toString())); // We concatenate release details. We only include pre-release if those are // the latest release: @@ -186,24 +186,16 @@ void SelfUpdater::startUpdate() includePreRelease = false; } - details += "\n# " + release["tag_name"].toString() + "\n---\n"; + details += "\n## " + release["tag_name"].toString() + "\n---\n"; details += release["body"].toString(); } // Need to call setDetailedText to create the QTextEdit and then be able to retrieve it: - query.setDetailedText(details); - QTextEdit* textEdit = query.findChild(); + dialog.setChangeLogs(details); - // If we have the text edit, we can call setMarkdown to get proper formatting. - if (textEdit) { - textEdit->setMarkdown(details); - } - - query.button(QMessageBox::Yes)->setText(tr("Install")); - - int res = query.exec(); + int res = dialog.exec(); - if (query.result() == QMessageBox::Yes) { + if (dialog.result() == QDialog::Accepted) { bool found = false; for (const QJsonValue &assetVal : latestRelease["assets"].toArray()) { QJsonObject asset = assetVal.toObject(); -- cgit v1.3.1