mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
Add a Verify tab to game properties
This commit is contained in:
@ -40,8 +40,8 @@ enum class EntryType
|
||||
};
|
||||
Q_DECLARE_METATYPE(EntryType);
|
||||
|
||||
FilesystemWidget::FilesystemWidget(const UICommon::GameFile& game)
|
||||
: m_game(game), m_volume(DiscIO::CreateVolumeFromFilename(game.GetFilePath()))
|
||||
FilesystemWidget::FilesystemWidget(std::shared_ptr<DiscIO::Volume> volume)
|
||||
: m_volume(std::move(volume))
|
||||
{
|
||||
CreateWidgets();
|
||||
ConnectWidgets();
|
||||
|
@ -8,8 +8,6 @@
|
||||
#include <QIcon>
|
||||
#include <memory>
|
||||
|
||||
#include "UICommon/GameFile.h"
|
||||
|
||||
class QStandardItem;
|
||||
class QStandardItemModel;
|
||||
class QTreeView;
|
||||
@ -26,7 +24,7 @@ class FilesystemWidget final : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FilesystemWidget(const UICommon::GameFile& game);
|
||||
explicit FilesystemWidget(std::shared_ptr<DiscIO::Volume> volume);
|
||||
~FilesystemWidget() override;
|
||||
|
||||
private:
|
||||
@ -52,8 +50,7 @@ private:
|
||||
QStandardItemModel* m_tree_model;
|
||||
QTreeView* m_tree_view;
|
||||
|
||||
UICommon::GameFile m_game;
|
||||
std::unique_ptr<DiscIO::Volume> m_volume;
|
||||
std::shared_ptr<DiscIO::Volume> m_volume;
|
||||
|
||||
QIcon m_folder_icon;
|
||||
QIcon m_file_icon;
|
||||
|
@ -2,12 +2,15 @@
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
#include <QTabWidget>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "DiscIO/Enums.h"
|
||||
#include "DiscIO/Volume.h"
|
||||
|
||||
#include "DolphinQt/Config/ARCodeWidget.h"
|
||||
#include "DolphinQt/Config/FilesystemWidget.h"
|
||||
@ -16,6 +19,7 @@
|
||||
#include "DolphinQt/Config/InfoWidget.h"
|
||||
#include "DolphinQt/Config/PatchesWidget.h"
|
||||
#include "DolphinQt/Config/PropertiesDialog.h"
|
||||
#include "DolphinQt/Config/VerifyWidget.h"
|
||||
#include "DolphinQt/QtUtils/WrapInScrollArea.h"
|
||||
|
||||
#include "UICommon/GameFile.h"
|
||||
@ -54,11 +58,22 @@ PropertiesDialog::PropertiesDialog(QWidget* parent, const UICommon::GameFile& ga
|
||||
tr("Gecko Codes"));
|
||||
tab_widget->addTab(GetWrappedWidget(info, this, padding_width, padding_height), tr("Info"));
|
||||
|
||||
if (DiscIO::IsDisc(game.GetPlatform()))
|
||||
if (game.GetPlatform() != DiscIO::Platform::ELFOrDOL)
|
||||
{
|
||||
FilesystemWidget* filesystem = new FilesystemWidget(game);
|
||||
tab_widget->addTab(GetWrappedWidget(filesystem, this, padding_width, padding_height),
|
||||
tr("Filesystem"));
|
||||
std::shared_ptr<DiscIO::Volume> volume = DiscIO::CreateVolumeFromFilename(game.GetFilePath());
|
||||
if (volume)
|
||||
{
|
||||
VerifyWidget* verify = new VerifyWidget(volume);
|
||||
tab_widget->addTab(GetWrappedWidget(verify, this, padding_width, padding_height),
|
||||
tr("Verify"));
|
||||
|
||||
if (DiscIO::IsDisc(game.GetPlatform()))
|
||||
{
|
||||
FilesystemWidget* filesystem = new FilesystemWidget(volume);
|
||||
tab_widget->addTab(GetWrappedWidget(filesystem, this, padding_width, padding_height),
|
||||
tr("Filesystem"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
layout->addWidget(tab_widget);
|
||||
|
116
Source/Core/DolphinQt/Config/VerifyWidget.cpp
Normal file
116
Source/Core/DolphinQt/Config/VerifyWidget.cpp
Normal file
@ -0,0 +1,116 @@
|
||||
// Copyright 2019 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "DolphinQt/Config/VerifyWidget.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QHeaderView>
|
||||
#include <QLabel>
|
||||
#include <QProgressDialog>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "DiscIO/Volume.h"
|
||||
#include "DiscIO/VolumeVerifier.h"
|
||||
|
||||
VerifyWidget::VerifyWidget(std::shared_ptr<DiscIO::Volume> volume) : m_volume(std::move(volume))
|
||||
{
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
|
||||
CreateWidgets();
|
||||
ConnectWidgets();
|
||||
|
||||
layout->addWidget(m_problems);
|
||||
layout->addWidget(m_summary_text);
|
||||
layout->addWidget(m_verify_button);
|
||||
|
||||
layout->setStretchFactor(m_problems, 5);
|
||||
layout->setStretchFactor(m_summary_text, 2);
|
||||
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
void VerifyWidget::CreateWidgets()
|
||||
{
|
||||
m_problems = new QTableWidget(0, 2, this);
|
||||
m_problems->setHorizontalHeaderLabels({tr("Problem"), tr("Severity")});
|
||||
m_problems->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
m_problems->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
|
||||
m_problems->horizontalHeader()->setHighlightSections(false);
|
||||
m_problems->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
m_problems->verticalHeader()->hide();
|
||||
|
||||
m_summary_text = new QTextEdit(this);
|
||||
m_summary_text->setReadOnly(true);
|
||||
|
||||
m_verify_button = new QPushButton(tr("Verify Integrity"), this);
|
||||
}
|
||||
|
||||
void VerifyWidget::ConnectWidgets()
|
||||
{
|
||||
connect(m_verify_button, &QPushButton::clicked, this, &VerifyWidget::Verify);
|
||||
}
|
||||
|
||||
void VerifyWidget::Verify()
|
||||
{
|
||||
DiscIO::VolumeVerifier verifier(*m_volume);
|
||||
|
||||
// We have to divide the number of processed bytes with something so it won't make ints overflow
|
||||
constexpr int DIVISOR = 0x100;
|
||||
|
||||
QProgressDialog* progress = new QProgressDialog(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()));
|
||||
for (int i = 0; i < m_problems->rowCount(); ++i)
|
||||
{
|
||||
const DiscIO::VolumeVerifier::Problem problem = result.problems[i];
|
||||
|
||||
QString severity;
|
||||
switch (problem.severity)
|
||||
{
|
||||
case DiscIO::VolumeVerifier::Severity::Low:
|
||||
severity = tr("Low");
|
||||
break;
|
||||
case DiscIO::VolumeVerifier::Severity::Medium:
|
||||
severity = tr("Medium");
|
||||
break;
|
||||
case DiscIO::VolumeVerifier::Severity::High:
|
||||
severity = tr("High");
|
||||
break;
|
||||
}
|
||||
|
||||
SetProblemCellText(i, 0, QString::fromStdString(problem.text));
|
||||
SetProblemCellText(i, 1, severity);
|
||||
}
|
||||
}
|
||||
|
||||
void VerifyWidget::SetProblemCellText(int row, int column, QString text)
|
||||
{
|
||||
QLabel* label = new QLabel(text);
|
||||
label->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
label->setWordWrap(true);
|
||||
label->setMargin(4);
|
||||
m_problems->setCellWidget(row, column, label);
|
||||
}
|
37
Source/Core/DolphinQt/Config/VerifyWidget.h
Normal file
37
Source/Core/DolphinQt/Config/VerifyWidget.h
Normal file
@ -0,0 +1,37 @@
|
||||
// Copyright 2019 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QTableWidget>
|
||||
#include <QTextEdit>
|
||||
#include <QWidget>
|
||||
|
||||
namespace DiscIO
|
||||
{
|
||||
class Volume;
|
||||
}
|
||||
|
||||
class VerifyWidget final : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit VerifyWidget(std::shared_ptr<DiscIO::Volume> volume);
|
||||
|
||||
private:
|
||||
void CreateWidgets();
|
||||
void ConnectWidgets();
|
||||
|
||||
void Verify();
|
||||
void SetProblemCellText(int row, int column, QString text);
|
||||
|
||||
std::shared_ptr<DiscIO::Volume> m_volume;
|
||||
QTableWidget* m_problems;
|
||||
QTextEdit* m_summary_text;
|
||||
QPushButton* m_verify_button;
|
||||
};
|
Reference in New Issue
Block a user