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.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include "common/logging/log.h"
|
||||||
#include "frontend/helpers/multi_job.h"
|
#include "frontend/helpers/multi_job.h"
|
||||||
|
|
||||||
MultiJob::MultiJob(QObject* parent, Core::SDMCImporter& importer_,
|
MultiJob::MultiJob(QObject* parent, Core::SDMCImporter& importer_,
|
||||||
@@ -45,7 +46,7 @@ void MultiJob::run() {
|
|||||||
content, eta);
|
content, eta);
|
||||||
if (!execute_func(importer, content, wrapper.Wrap(Callback))) {
|
if (!execute_func(importer, content, wrapper.Wrap(Callback))) {
|
||||||
if (!cancelled) {
|
if (!cancelled) {
|
||||||
failed_contents.emplace_back(content);
|
failed_contents.emplace_back(content, Common::Logging::GetLastErrors());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
count++;
|
count++;
|
||||||
@@ -62,6 +63,6 @@ void MultiJob::Cancel() {
|
|||||||
abort_func(importer);
|
abort_func(importer);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Core::ContentSpecifier> MultiJob::GetFailedContents() const {
|
MultiJob::FailedContentList MultiJob::GetFailedContents() const {
|
||||||
return failed_contents;
|
return failed_contents;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ public:
|
|||||||
using ExecuteFunc = std::function<bool(Core::SDMCImporter&, const Core::ContentSpecifier&,
|
using ExecuteFunc = std::function<bool(Core::SDMCImporter&, const Core::ContentSpecifier&,
|
||||||
const Common::ProgressCallback&)>;
|
const Common::ProgressCallback&)>;
|
||||||
using AbortFunc = std::function<void(Core::SDMCImporter&)>;
|
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,
|
explicit MultiJob(QObject* parent, Core::SDMCImporter& importer,
|
||||||
std::vector<Core::ContentSpecifier> contents, ExecuteFunc execute_func,
|
std::vector<Core::ContentSpecifier> contents, ExecuteFunc execute_func,
|
||||||
@@ -26,7 +28,7 @@ public:
|
|||||||
void run() override;
|
void run() override;
|
||||||
void Cancel();
|
void Cancel();
|
||||||
|
|
||||||
std::vector<Core::ContentSpecifier> GetFailedContents() const;
|
FailedContentList GetFailedContents() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
@@ -48,7 +50,7 @@ private:
|
|||||||
std::atomic_bool cancelled{false};
|
std::atomic_bool cancelled{false};
|
||||||
Core::SDMCImporter& importer;
|
Core::SDMCImporter& importer;
|
||||||
std::vector<Core::ContentSpecifier> contents;
|
std::vector<Core::ContentSpecifier> contents;
|
||||||
std::vector<Core::ContentSpecifier> failed_contents;
|
FailedContentList failed_contents;
|
||||||
ExecuteFunc execute_func;
|
ExecuteFunc execute_func;
|
||||||
AbortFunc abort_func;
|
AbortFunc abort_func;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include "common/logging/log.h"
|
||||||
#include "frontend/helpers/frontend_common.h"
|
#include "frontend/helpers/frontend_common.h"
|
||||||
#include "frontend/helpers/rate_limited_progress_dialog.h"
|
#include "frontend/helpers/rate_limited_progress_dialog.h"
|
||||||
#include "frontend/helpers/simple_job.h"
|
#include "frontend/helpers/simple_job.h"
|
||||||
@@ -43,8 +44,11 @@ void SimpleJob::StartWithProgressDialog(QWidget* widget) {
|
|||||||
tr("%1 / %2").arg(ReadableByteSize(current), ReadableByteSize(total)));
|
tr("%1 / %2").arg(ReadableByteSize(current), ReadableByteSize(total)));
|
||||||
});
|
});
|
||||||
connect(this, &SimpleJob::ErrorOccured, this, [widget, dialog] {
|
connect(this, &SimpleJob::ErrorOccured, this, [widget, dialog] {
|
||||||
QMessageBox::critical(widget, tr("threeSD"),
|
QMessageBox message_box(QMessageBox::Critical, tr("threeSD"),
|
||||||
tr("Operation failed. Please refer to the log."));
|
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();
|
dialog->hide();
|
||||||
});
|
});
|
||||||
connect(this, &SimpleJob::Completed, dialog, &QProgressDialog::hide);
|
connect(this, &SimpleJob::Completed, dialog, &QProgressDialog::hide);
|
||||||
|
|||||||
@@ -209,9 +209,12 @@ void ImportDialog::RelistContent() {
|
|||||||
if (importer->IsGood()) {
|
if (importer->IsGood()) {
|
||||||
RepopulateContent();
|
RepopulateContent();
|
||||||
} else {
|
} else {
|
||||||
QMessageBox::critical(
|
QMessageBox message_box(
|
||||||
this, tr("Importer Error"),
|
QMessageBox::Critical, tr("Importer Error"),
|
||||||
tr("Failed to initalize the importer.\nRefer to the log for details."));
|
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();
|
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."));
|
QMessageBox::information(this, tr("threeSD"), tr("All contents done successfully."));
|
||||||
} else {
|
} else {
|
||||||
QString list_content;
|
QString list_content;
|
||||||
for (const auto& content : failed_contents) {
|
QString details;
|
||||||
list_content.append(QStringLiteral("<li>%1 (%2)</li>")
|
for (const auto& [content, error] : failed_contents) {
|
||||||
.arg(GetContentName(content))
|
const QString full_name = QStringLiteral("%1 (%2)").arg(
|
||||||
.arg(GetDisplayGroupName<false>(content)));
|
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"),
|
QMessageBox message_box(
|
||||||
tr("List of failed contents:<ul>%1</ul>").arg(list_content));
|
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();
|
RelistContent();
|
||||||
|
|||||||
@@ -258,7 +258,10 @@ void UtilitiesDialog::ShowResult() {
|
|||||||
if (result) {
|
if (result) {
|
||||||
QMessageBox::information(this, tr("Success"), tr("Operation completed successfully."));
|
QMessageBox::information(this, tr("Success"), tr("Operation completed successfully."));
|
||||||
} else {
|
} else {
|
||||||
QMessageBox::critical(this, tr("Error"),
|
QMessageBox message_box(QMessageBox::Critical, tr("threeSD"),
|
||||||
tr("An error occured while performing the operation."));
|
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