mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-11 16:49:28 +02:00
DolphinQt: Run tasks that use progress dialogs on separate threads
This commit is contained in:
@ -87,6 +87,7 @@
|
||||
#include "DolphinQt/NetPlay/NetPlaySetupDialog.h"
|
||||
#include "DolphinQt/QtUtils/FileOpenEventFilter.h"
|
||||
#include "DolphinQt/QtUtils/ModalMessageBox.h"
|
||||
#include "DolphinQt/QtUtils/ParallelProgressDialog.h"
|
||||
#include "DolphinQt/QtUtils/QueueOnObject.h"
|
||||
#include "DolphinQt/QtUtils/RunOnObject.h"
|
||||
#include "DolphinQt/QtUtils/WindowActivationEventFilter.h"
|
||||
@ -1510,23 +1511,21 @@ void MainWindow::OnImportNANDBackup()
|
||||
if (file.isEmpty())
|
||||
return;
|
||||
|
||||
QProgressDialog* dialog = new QProgressDialog(this);
|
||||
dialog->setMinimum(0);
|
||||
dialog->setMaximum(0);
|
||||
dialog->setLabelText(tr("Importing NAND backup"));
|
||||
dialog->setCancelButton(nullptr);
|
||||
ParallelProgressDialog dialog(this);
|
||||
dialog.GetRaw()->setMinimum(0);
|
||||
dialog.GetRaw()->setMaximum(0);
|
||||
dialog.GetRaw()->setLabelText(tr("Importing NAND backup"));
|
||||
dialog.GetRaw()->setCancelButton(nullptr);
|
||||
|
||||
auto beginning = QDateTime::currentDateTime().toMSecsSinceEpoch();
|
||||
|
||||
auto result = std::async(std::launch::async, [&] {
|
||||
std::future<void> result = std::async(std::launch::async, [&] {
|
||||
DiscIO::NANDImporter().ImportNANDBin(
|
||||
file.toStdString(),
|
||||
[&dialog, beginning] {
|
||||
QueueOnObject(dialog, [&dialog, beginning] {
|
||||
dialog->setLabelText(
|
||||
tr("Importing NAND backup\n Time elapsed: %1s")
|
||||
.arg((QDateTime::currentDateTime().toMSecsSinceEpoch() - beginning) / 1000));
|
||||
});
|
||||
dialog.SetLabelText(
|
||||
tr("Importing NAND backup\n Time elapsed: %1s")
|
||||
.arg((QDateTime::currentDateTime().toMSecsSinceEpoch() - beginning) / 1000));
|
||||
},
|
||||
[this] {
|
||||
std::optional<std::string> keys_file = RunOnObject(this, [this] {
|
||||
@ -1540,10 +1539,10 @@ void MainWindow::OnImportNANDBackup()
|
||||
return *keys_file;
|
||||
return std::string("");
|
||||
});
|
||||
QueueOnObject(dialog, &QProgressDialog::close);
|
||||
dialog.Reset();
|
||||
});
|
||||
|
||||
dialog->exec();
|
||||
dialog.GetRaw()->exec();
|
||||
|
||||
result.wait();
|
||||
|
||||
|
Reference in New Issue
Block a user