aboutsummaryrefslogtreecommitdiff
path: root/launcher
diff options
context:
space:
mode:
authorTheKodeToad <TheKodeToad@proton.me>2023-03-18 12:21:13 +0000
committerTheKodeToad <TheKodeToad@proton.me>2023-03-18 12:24:18 +0000
commitddca838e46d2d147cbc5965be31895dd73676c79 (patch)
tree529cb0c1f96596a078efa75e38a809515d5aaa41 /launcher
parent2cc9b0df068ace61c60217973d4d66412cb53968 (diff)
downloadPrismLauncher-ddca838e46d2d147cbc5965be31895dd73676c79.tar.gz
PrismLauncher-ddca838e46d2d147cbc5965be31895dd73676c79.tar.bz2
PrismLauncher-ddca838e46d2d147cbc5965be31895dd73676c79.zip
Info and error dialogs
TODO: is there a better approach? Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
Diffstat (limited to 'launcher')
-rw-r--r--launcher/modplatform/modrinth/ModrinthPackExportTask.cpp21
-rw-r--r--launcher/ui/dialogs/ExportMrPackDialog.cpp16
2 files changed, 28 insertions, 9 deletions
diff --git a/launcher/modplatform/modrinth/ModrinthPackExportTask.cpp b/launcher/modplatform/modrinth/ModrinthPackExportTask.cpp
index e12ee923..e8bc3673 100644
--- a/launcher/modplatform/modrinth/ModrinthPackExportTask.cpp
+++ b/launcher/modplatform/modrinth/ModrinthPackExportTask.cpp
@@ -18,8 +18,7 @@
#include "ModrinthPackExportTask.h"
-#include <qcryptographichash.h>
-#include <qtconcurrentrun.h>
+#include <QCryptographicHash>
#include <QFileInfo>
#include <QFileInfoList>
#include <QMessageBox>
@@ -28,7 +27,6 @@
#include "MMCZip.h"
#include "minecraft/MinecraftInstance.h"
#include "minecraft/PackProfile.h"
-#include "minecraft/mod/Mod.h"
#include "modplatform/modrinth/ModrinthAPI.h"
const QStringList ModrinthPackExportTask::PREFIXES = QStringList({ "mods", "coremods", "resourcepacks", "texturepacks", "shaderpacks" });
@@ -62,7 +60,7 @@ bool ModrinthPackExportTask::abort()
return false;
task = nullptr;
- emitFailed(tr("Aborted"));
+ emitAborted();
return true;
}
@@ -154,14 +152,16 @@ void ModrinthPackExportTask::buildZip()
}
if (pendingAbort) {
- emitFailed(tr("Aborted"));
+ QMetaObject::invokeMethod(
+ this, [this]() { emitAborted(); }, Qt::QueuedConnection);
return;
}
QuaZipFile indexFile(&zip);
if (!indexFile.open(QIODevice::WriteOnly, QuaZipNewInfo("modrinth.index.json"))) {
QFile::remove(output);
- emitFailed(tr("Could not create index"));
+ QMetaObject::invokeMethod(
+ this, [this]() { emitFailed(tr("Could not create index")); }, Qt::QueuedConnection);
return;
}
indexFile.write(generateIndex());
@@ -171,7 +171,8 @@ void ModrinthPackExportTask::buildZip()
for (const QFileInfo& file : files) {
if (pendingAbort) {
QFile::remove(output);
- emitFailed(tr("Aborted"));
+ QMetaObject::invokeMethod(
+ this, [this]() { emitAborted(); }, Qt::QueuedConnection);
return;
}
@@ -186,11 +187,13 @@ void ModrinthPackExportTask::buildZip()
if (zip.getZipError() != 0) {
QFile::remove(output);
- emitFailed(tr("A zip error occured"));
+ QMetaObject::invokeMethod(
+ this, [this]() { emitFailed(tr("A zip error occurred")); }, Qt::QueuedConnection);
return;
}
- emitSucceeded();
+ QMetaObject::invokeMethod(
+ this, [this]() { emitSucceeded(); }, Qt::QueuedConnection);
});
}
diff --git a/launcher/ui/dialogs/ExportMrPackDialog.cpp b/launcher/ui/dialogs/ExportMrPackDialog.cpp
index 03238ec4..8a49f314 100644
--- a/launcher/ui/dialogs/ExportMrPackDialog.cpp
+++ b/launcher/ui/dialogs/ExportMrPackDialog.cpp
@@ -17,6 +17,8 @@
*/
#include "ExportMrPackDialog.h"
+#include "Application.h"
+#include "ui/dialogs/CustomMessageBox.h"
#include "ui/dialogs/ProgressDialog.h"
#include "ui_ExportMrPackDialog.h"
@@ -82,6 +84,20 @@ void ExportMrPackDialog::done(int result)
ModrinthPackExportTask task(ui->name->text(), ui->version->text(), ui->summary->text(), instance, output,
[this](const QString& path) { return proxy->blockedPaths().covers(path); });
+
+ connect(&task, &Task::failed,
+ [this](const QString reason) { CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show(); });
+
+ connect(&task, &Task::succeeded, [this, &task]() {
+ QStringList warnings = task.warnings();
+ if (warnings.count() > 0)
+ CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'), QMessageBox::Warning)->show();
+ });
+ connect(&task, &Task::aborted, [this] {
+ CustomMessageBox::selectable(this, tr("Task aborted"), tr("The task has been aborted by the user."), QMessageBox::Information)
+ ->show();
+ });
+
ProgressDialog progress(this);
progress.setSkipButton(true, tr("Abort"));
if (progress.execWithTask(&task) != QDialog::Accepted)