summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinQt/MainWindow.cpp
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2020-03-30 00:28:16 +0200
committerJosJuice <josjuice@gmail.com>2020-04-03 12:53:38 +0200
commitc6ee767851dee68bfc67bcbe7f176512080b7e7c (patch)
treed25bcfa590c6038b00b591832469c5bf554ddb4b /Source/Core/DolphinQt/MainWindow.cpp
parent4ff855921e221f944d5ce22074e86096474d4ea6 (diff)
DolphinQt: Run tasks that use progress dialogs on separate threads
Diffstat (limited to 'Source/Core/DolphinQt/MainWindow.cpp')
-rw-r--r--Source/Core/DolphinQt/MainWindow.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp
index 6080457c5a..1cd6eb4c6f 100644
--- a/Source/Core/DolphinQt/MainWindow.cpp
+++ b/Source/Core/DolphinQt/MainWindow.cpp
@@ -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();