Move task to another thread
I don't know whether this is the prefered method. Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
parent
f28a7b9d08
commit
adcdf28d64
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ModrinthPackExportTask.h"
|
#include "ModrinthPackExportTask.h"
|
||||||
|
#include <qtconcurrentrun.h>
|
||||||
#include <QFileInfoList>
|
#include <QFileInfoList>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include "MMCZip.h"
|
#include "MMCZip.h"
|
||||||
@ -34,6 +35,7 @@ ModrinthPackExportTask::ModrinthPackExportTask(const QString& name,
|
|||||||
|
|
||||||
void ModrinthPackExportTask::executeTask()
|
void ModrinthPackExportTask::executeTask()
|
||||||
{
|
{
|
||||||
|
QtConcurrent::run(QThreadPool::globalInstance(), [this] {
|
||||||
QFileInfoList files;
|
QFileInfoList files;
|
||||||
if (!MMCZip::collectFileListRecursively(instance->gameRoot(), nullptr, &files, filter)) {
|
if (!MMCZip::collectFileListRecursively(instance->gameRoot(), nullptr, &files, filter)) {
|
||||||
emitFailed(tr("Could not collect list of files"));
|
emitFailed(tr("Could not collect list of files"));
|
||||||
@ -85,6 +87,7 @@ void ModrinthPackExportTask::executeTask()
|
|||||||
}
|
}
|
||||||
|
|
||||||
emitSucceeded();
|
emitSucceeded();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray ModrinthPackExportTask::generateIndex()
|
QByteArray ModrinthPackExportTask::generateIndex()
|
||||||
|
@ -56,14 +56,7 @@ ExportMrPackDialog::~ExportMrPackDialog()
|
|||||||
|
|
||||||
void ExportMrPackDialog::done(int result)
|
void ExportMrPackDialog::done(int result)
|
||||||
{
|
{
|
||||||
if (result == Accepted)
|
if (result == Accepted) {
|
||||||
runExport();
|
|
||||||
|
|
||||||
QDialog::done(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExportMrPackDialog::runExport()
|
|
||||||
{
|
|
||||||
const QString filename = FS::RemoveInvalidFilenameChars(ui->name->text());
|
const QString filename = FS::RemoveInvalidFilenameChars(ui->name->text());
|
||||||
const QString output =
|
const QString output =
|
||||||
QFileDialog::getSaveFileName(this, tr("Export %1").arg(ui->name->text()), FS::PathCombine(QDir::homePath(), filename + ".mrpack"),
|
QFileDialog::getSaveFileName(this, tr("Export %1").arg(ui->name->text()), FS::PathCombine(QDir::homePath(), filename + ".mrpack"),
|
||||||
@ -78,4 +71,7 @@ void ExportMrPackDialog::runExport()
|
|||||||
ProgressDialog progress(this);
|
ProgressDialog progress(this);
|
||||||
progress.setSkipButton(true, tr("Abort"));
|
progress.setSkipButton(true, tr("Abort"));
|
||||||
progress.execWithTask(&task);
|
progress.execWithTask(&task);
|
||||||
|
}
|
||||||
|
|
||||||
|
QDialog::done(result);
|
||||||
}
|
}
|
@ -39,6 +39,4 @@ class ExportMrPackDialog : public QDialog {
|
|||||||
const InstancePtr instance;
|
const InstancePtr instance;
|
||||||
Ui::ExportMrPackDialog* ui;
|
Ui::ExportMrPackDialog* ui;
|
||||||
PackIgnoreProxy* proxy;
|
PackIgnoreProxy* proxy;
|
||||||
|
|
||||||
void runExport();
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user