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.cpp37
1 files changed, 36 insertions, 1 deletions
diff --git a/Source/Core/DolphinQt/Config/VerifyWidget.cpp b/Source/Core/DolphinQt/Config/VerifyWidget.cpp
index 488343fc76..f688c38932 100644
--- a/Source/Core/DolphinQt/Config/VerifyWidget.cpp
+++ b/Source/Core/DolphinQt/Config/VerifyWidget.cpp
@@ -29,6 +29,7 @@ VerifyWidget::VerifyWidget(std::shared_ptr<DiscIO::Volume> volume) : m_volume(st
layout->addWidget(m_problems);
layout->addWidget(m_summary_text);
layout->addLayout(m_hash_layout);
+ layout->addLayout(m_redump_layout);
layout->addWidget(m_verify_button);
layout->setStretchFactor(m_problems, 5);
@@ -55,8 +56,21 @@ void VerifyWidget::CreateWidgets()
std::tie(m_md5_checkbox, m_md5_line_edit) = AddHashLine(m_hash_layout, tr("MD5:"));
std::tie(m_sha1_checkbox, m_sha1_line_edit) = AddHashLine(m_hash_layout, tr("SHA-1:"));
+ m_redump_layout = new QFormLayout;
+ if (DiscIO::IsDisc(m_volume->GetVolumeType()))
+ {
+ std::tie(m_redump_checkbox, m_redump_line_edit) =
+ AddHashLine(m_redump_layout, tr("Redump.org Status:"));
+ }
+ else
+ {
+ m_redump_checkbox = nullptr;
+ m_redump_line_edit = nullptr;
+ }
+
// Extend line edits to their maximum possible widths (needed on macOS)
m_hash_layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
+ m_redump_layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
m_verify_button = new QPushButton(tr("Verify Integrity"), this);
}
@@ -80,6 +94,9 @@ std::pair<QCheckBox*, QLineEdit*> VerifyWidget::AddHashLine(QFormLayout* layout,
void VerifyWidget::ConnectWidgets()
{
connect(m_verify_button, &QPushButton::clicked, this, &VerifyWidget::Verify);
+
+ connect(m_md5_checkbox, &QCheckBox::stateChanged, this, &VerifyWidget::UpdateRedumpEnabled);
+ connect(m_sha1_checkbox, &QCheckBox::stateChanged, this, &VerifyWidget::UpdateRedumpEnabled);
}
static void SetHash(QLineEdit* line_edit, const std::vector<u8>& hash)
@@ -89,10 +106,25 @@ static void SetHash(QLineEdit* line_edit, const std::vector<u8>& hash)
line_edit->setText(QString::fromLatin1(byte_array.toHex()));
}
+bool VerifyWidget::CanVerifyRedump() const
+{
+ // We don't allow Redump verification with CRC32 only since generating a collision is too easy
+ return m_md5_checkbox->isChecked() || m_sha1_checkbox->isChecked();
+}
+
+void VerifyWidget::UpdateRedumpEnabled()
+{
+ if (m_redump_checkbox)
+ m_redump_checkbox->setEnabled(CanVerifyRedump());
+}
+
void VerifyWidget::Verify()
{
+ const bool redump_verification =
+ CanVerifyRedump() && m_redump_checkbox && m_redump_checkbox->isChecked();
+
DiscIO::VolumeVerifier verifier(
- *m_volume,
+ *m_volume, redump_verification,
{m_crc32_checkbox->isChecked(), m_md5_checkbox->isChecked(), m_sha1_checkbox->isChecked()});
// We have to divide the number of processed bytes with something so it won't make ints overflow
@@ -147,6 +179,9 @@ void VerifyWidget::Verify()
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));
}
void VerifyWidget::SetProblemCellText(int row, int column, QString text)