summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinQt/Config/VerifyWidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/DolphinQt/Config/VerifyWidget.cpp')
-rw-r--r--Source/Core/DolphinQt/Config/VerifyWidget.cpp73
1 files changed, 43 insertions, 30 deletions
diff --git a/Source/Core/DolphinQt/Config/VerifyWidget.cpp b/Source/Core/DolphinQt/Config/VerifyWidget.cpp
index 925409a81c..ce221bce8f 100644
--- a/Source/Core/DolphinQt/Config/VerifyWidget.cpp
+++ b/Source/Core/DolphinQt/Config/VerifyWidget.cpp
@@ -4,7 +4,9 @@
#include "DolphinQt/Config/VerifyWidget.h"
+#include <future>
#include <memory>
+#include <optional>
#include <tuple>
#include <vector>
@@ -12,12 +14,12 @@
#include <QHBoxLayout>
#include <QHeaderView>
#include <QLabel>
-#include <QProgressDialog>
#include <QVBoxLayout>
#include "Common/CommonTypes.h"
#include "DiscIO/Volume.h"
#include "DiscIO/VolumeVerifier.h"
+#include "DolphinQt/QtUtils/ParallelProgressDialog.h"
VerifyWidget::VerifyWidget(std::shared_ptr<DiscIO::Volume> volume) : m_volume(std::move(volume))
{
@@ -131,33 +133,44 @@ void VerifyWidget::Verify()
// We have to divide the number of processed bytes with something so it won't make ints overflow
constexpr int DIVISOR = 0x100;
- QProgressDialog progress(tr("Verifying"), tr("Cancel"), 0, verifier.GetTotalBytes() / DIVISOR,
- this);
- progress.setWindowTitle(tr("Verifying"));
- progress.setWindowFlags(progress.windowFlags() & ~Qt::WindowContextHelpButtonHint);
- progress.setMinimumDuration(500);
- progress.setWindowModality(Qt::WindowModal);
-
- verifier.Start();
- while (verifier.GetBytesProcessed() != verifier.GetTotalBytes())
- {
- progress.setValue(verifier.GetBytesProcessed() / DIVISOR);
- if (progress.wasCanceled())
- return;
-
- verifier.Process();
- }
- verifier.Finish();
-
- DiscIO::VolumeVerifier::Result result = verifier.GetResult();
- progress.setValue(verifier.GetBytesProcessed() / DIVISOR);
-
- m_summary_text->setText(QString::fromStdString(result.summary_text));
-
- m_problems->setRowCount(static_cast<int>(result.problems.size()));
+ ParallelProgressDialog progress(tr("Verifying"), tr("Cancel"), 0,
+ static_cast<int>(verifier.GetTotalBytes() / DIVISOR), this);
+ progress.GetRaw()->setWindowTitle(tr("Verifying"));
+ progress.GetRaw()->setMinimumDuration(500);
+ progress.GetRaw()->setWindowModality(Qt::WindowModal);
+
+ auto future =
+ std::async(std::launch::async,
+ [&verifier, &progress]() -> std::optional<DiscIO::VolumeVerifier::Result> {
+ progress.SetValue(0);
+ verifier.Start();
+ while (verifier.GetBytesProcessed() != verifier.GetTotalBytes())
+ {
+ progress.SetValue(static_cast<int>(verifier.GetBytesProcessed() / DIVISOR));
+ if (progress.WasCanceled())
+ return std::nullopt;
+
+ verifier.Process();
+ }
+ verifier.Finish();
+
+ const DiscIO::VolumeVerifier::Result result = verifier.GetResult();
+ progress.Reset();
+
+ return result;
+ });
+ progress.GetRaw()->exec();
+
+ std::optional<DiscIO::VolumeVerifier::Result> result = future.get();
+ if (!result)
+ return;
+
+ m_summary_text->setText(QString::fromStdString(result->summary_text));
+
+ m_problems->setRowCount(static_cast<int>(result->problems.size()));
for (int i = 0; i < m_problems->rowCount(); ++i)
{
- const DiscIO::VolumeVerifier::Problem problem = result.problems[i];
+ const DiscIO::VolumeVerifier::Problem problem = result->problems[i];
QString severity;
switch (problem.severity)
@@ -179,12 +192,12 @@ void VerifyWidget::Verify()
SetProblemCellText(i, 1, severity);
}
- SetHash(m_crc32_line_edit, result.hashes.crc32);
- SetHash(m_md5_line_edit, result.hashes.md5);
- SetHash(m_sha1_line_edit, result.hashes.sha1);
+ SetHash(m_crc32_line_edit, result->hashes.crc32);
+ SetHash(m_md5_line_edit, result->hashes.md5);
+ SetHash(m_sha1_line_edit, result->hashes.sha1);
if (m_redump_line_edit)
- m_redump_line_edit->setText(QString::fromStdString(result.redump.message));
+ m_redump_line_edit->setText(QString::fromStdString(result->redump.message));
}
void VerifyWidget::SetProblemCellText(int row, int column, QString text)