mirror of
https://github.com/Dark98/threeSD.git
synced 2026-07-02 16:49:04 +00:00
Update UI to display details on error
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <chrono>
|
||||
#include "common/logging/log.h"
|
||||
#include "frontend/helpers/multi_job.h"
|
||||
|
||||
MultiJob::MultiJob(QObject* parent, Core::SDMCImporter& importer_,
|
||||
@@ -45,7 +46,7 @@ void MultiJob::run() {
|
||||
content, eta);
|
||||
if (!execute_func(importer, content, wrapper.Wrap(Callback))) {
|
||||
if (!cancelled) {
|
||||
failed_contents.emplace_back(content);
|
||||
failed_contents.emplace_back(content, Common::Logging::GetLastErrors());
|
||||
}
|
||||
}
|
||||
count++;
|
||||
@@ -62,6 +63,6 @@ void MultiJob::Cancel() {
|
||||
abort_func(importer);
|
||||
}
|
||||
|
||||
std::vector<Core::ContentSpecifier> MultiJob::GetFailedContents() const {
|
||||
MultiJob::FailedContentList MultiJob::GetFailedContents() const {
|
||||
return failed_contents;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ public:
|
||||
using ExecuteFunc = std::function<bool(Core::SDMCImporter&, const Core::ContentSpecifier&,
|
||||
const Common::ProgressCallback&)>;
|
||||
using AbortFunc = std::function<void(Core::SDMCImporter&)>;
|
||||
// (content, error log)
|
||||
using FailedContentList = std::vector<std::pair<Core::ContentSpecifier, std::string>>;
|
||||
|
||||
explicit MultiJob(QObject* parent, Core::SDMCImporter& importer,
|
||||
std::vector<Core::ContentSpecifier> contents, ExecuteFunc execute_func,
|
||||
@@ -26,7 +28,7 @@ public:
|
||||
void run() override;
|
||||
void Cancel();
|
||||
|
||||
std::vector<Core::ContentSpecifier> GetFailedContents() const;
|
||||
FailedContentList GetFailedContents() const;
|
||||
|
||||
signals:
|
||||
/**
|
||||
@@ -48,7 +50,7 @@ private:
|
||||
std::atomic_bool cancelled{false};
|
||||
Core::SDMCImporter& importer;
|
||||
std::vector<Core::ContentSpecifier> contents;
|
||||
std::vector<Core::ContentSpecifier> failed_contents;
|
||||
FailedContentList failed_contents;
|
||||
ExecuteFunc execute_func;
|
||||
AbortFunc abort_func;
|
||||
};
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <QMessageBox>
|
||||
#include "common/logging/log.h"
|
||||
#include "frontend/helpers/frontend_common.h"
|
||||
#include "frontend/helpers/rate_limited_progress_dialog.h"
|
||||
#include "frontend/helpers/simple_job.h"
|
||||
@@ -43,8 +44,11 @@ void SimpleJob::StartWithProgressDialog(QWidget* widget) {
|
||||
tr("%1 / %2").arg(ReadableByteSize(current), ReadableByteSize(total)));
|
||||
});
|
||||
connect(this, &SimpleJob::ErrorOccured, this, [widget, dialog] {
|
||||
QMessageBox::critical(widget, tr("threeSD"),
|
||||
tr("Operation failed. Please refer to the log."));
|
||||
QMessageBox message_box(QMessageBox::Critical, tr("threeSD"),
|
||||
tr("Operation failed. Refer to the log for details."),
|
||||
QMessageBox::Ok, widget);
|
||||
message_box.setDetailedText(QString::fromStdString(Common::Logging::GetLastErrors()));
|
||||
message_box.exec();
|
||||
dialog->hide();
|
||||
});
|
||||
connect(this, &SimpleJob::Completed, dialog, &QProgressDialog::hide);
|
||||
|
||||
@@ -209,9 +209,12 @@ void ImportDialog::RelistContent() {
|
||||
if (importer->IsGood()) {
|
||||
RepopulateContent();
|
||||
} else {
|
||||
QMessageBox::critical(
|
||||
this, tr("Importer Error"),
|
||||
tr("Failed to initalize the importer.\nRefer to the log for details."));
|
||||
QMessageBox message_box(
|
||||
QMessageBox::Critical, tr("Importer Error"),
|
||||
tr("Failed to initalize the importer. Refer to the log for details."),
|
||||
QMessageBox::Ok, this);
|
||||
message_box.setDetailedText(QString::fromStdString(Common::Logging::GetLastErrors()));
|
||||
message_box.exec();
|
||||
reject();
|
||||
}
|
||||
});
|
||||
@@ -713,13 +716,22 @@ void ImportDialog::RunMultiJob(MultiJob* job, std::size_t total_count, u64 total
|
||||
QMessageBox::information(this, tr("threeSD"), tr("All contents done successfully."));
|
||||
} else {
|
||||
QString list_content;
|
||||
for (const auto& content : failed_contents) {
|
||||
list_content.append(QStringLiteral("<li>%1 (%2)</li>")
|
||||
.arg(GetContentName(content))
|
||||
.arg(GetDisplayGroupName<false>(content)));
|
||||
QString details;
|
||||
for (const auto& [content, error] : failed_contents) {
|
||||
const QString full_name = QStringLiteral("%1 (%2)").arg(
|
||||
GetContentName(content), GetDisplayGroupName<false>(content));
|
||||
|
||||
list_content.append(QStringLiteral("<li>%1</li>").arg(full_name));
|
||||
details.append(
|
||||
QStringLiteral("%1:\n%2\n").arg(full_name, QString::fromStdString(error)));
|
||||
}
|
||||
QMessageBox::critical(this, tr("threeSD"),
|
||||
tr("List of failed contents:<ul>%1</ul>").arg(list_content));
|
||||
QMessageBox message_box(
|
||||
QMessageBox::Critical, tr("threeSD"),
|
||||
tr("List of failed contents (see the log for details):<ul>%1</ul>")
|
||||
.arg(list_content),
|
||||
QMessageBox::Ok, this);
|
||||
message_box.setDetailedText(details);
|
||||
message_box.exec();
|
||||
}
|
||||
|
||||
RelistContent();
|
||||
|
||||
@@ -258,7 +258,10 @@ void UtilitiesDialog::ShowResult() {
|
||||
if (result) {
|
||||
QMessageBox::information(this, tr("Success"), tr("Operation completed successfully."));
|
||||
} else {
|
||||
QMessageBox::critical(this, tr("Error"),
|
||||
tr("An error occured while performing the operation."));
|
||||
QMessageBox message_box(QMessageBox::Critical, tr("threeSD"),
|
||||
tr("Operation failed. Refer to the log for details."),
|
||||
QMessageBox::Ok, this);
|
||||
message_box.setDetailedText(QString::fromStdString(Common::Logging::GetLastErrors()));
|
||||
message_box.exec();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user