Improve NAND import progress dialog
Now with cancel button and an actual progress bar. For simplicity, we do two passes on the progress bar, one for loading the NAND into memory and one for extracting it. The user directory is likely on an SSD, making the extraction pass invisibly fast.
This commit is contained in:
1 parent
2b6ca92146
commit
f06aef4f83
4 files changed
+56
-28
No files matched your search
@@ -1881,20 +1881,24 @@ void MainWindow::OnImportNANDBackup()
|
||||
return;
|
||||
|
||||
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();
|
||||
dialog.GetRaw()->setWindowTitle(tr("Importing NAND backup"));
|
||||
|
||||
std::future<void> result = std::async(std::launch::async, [&] {
|
||||
DiscIO::NANDImporter().ImportNANDBin(
|
||||
file.toStdString(),
|
||||
[&dialog, beginning] {
|
||||
dialog.SetLabelText(
|
||||
tr("Importing NAND backup\n Time elapsed: %1s")
|
||||
.arg((QDateTime::currentDateTime().toMSecsSinceEpoch() - beginning) / 1000));
|
||||
[&dialog](DiscIO::NANDImporter::Step step, u32 cur, u32 max) {
|
||||
switch (step)
|
||||
{
|
||||
case DiscIO::NANDImporter::Step::Loading:
|
||||
dialog.SetLabelText(tr("Loading NAND..."));
|
||||
break;
|
||||
case DiscIO::NANDImporter::Step::Extracting:
|
||||
dialog.SetLabelText(tr("Extracting NAND..."));
|
||||
break;
|
||||
}
|
||||
dialog.SetValue(cur);
|
||||
dialog.SetMaximum(max);
|
||||
return dialog.WasCanceled();
|
||||
},
|
||||
[this] {
|
||||
std::optional<std::string> keys_file = RunOnObject(this, [this] {
|
||||
|
||||
Reference in new issue
Block a user