Qt/WiiPane: Add progress window for SD card conversion.

This commit is contained in:
Admiral H. Curtiss 2023-02-26 20:21:11 +01:00
parent 435d8c39ee
commit fe26b54efd
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB
1 changed files with 25 additions and 2 deletions

View File

@ -3,6 +3,8 @@
#include "DolphinQt/Settings/WiiPane.h" #include "DolphinQt/Settings/WiiPane.h"
#include <future>
#include <QCheckBox> #include <QCheckBox>
#include <QComboBox> #include <QComboBox>
#include <QDir> #include <QDir>
@ -30,6 +32,7 @@
#include "DolphinQt/QtUtils/DolphinFileDialog.h" #include "DolphinQt/QtUtils/DolphinFileDialog.h"
#include "DolphinQt/QtUtils/ModalMessageBox.h" #include "DolphinQt/QtUtils/ModalMessageBox.h"
#include "DolphinQt/QtUtils/NonDefaultQPushButton.h" #include "DolphinQt/QtUtils/NonDefaultQPushButton.h"
#include "DolphinQt/QtUtils/ParallelProgressDialog.h"
#include "DolphinQt/QtUtils/SignalBlocking.h" #include "DolphinQt/QtUtils/SignalBlocking.h"
#include "DolphinQt/Settings.h" #include "DolphinQt/Settings.h"
#include "DolphinQt/Settings/USBDeviceAddToWhitelistDialog.h" #include "DolphinQt/Settings/USBDeviceAddToWhitelistDialog.h"
@ -228,7 +231,17 @@ void WiiPane::CreateSDCard()
QMessageBox::Yes | QMessageBox::No); QMessageBox::Yes | QMessageBox::No);
if (result == QMessageBox::Yes) if (result == QMessageBox::Yes)
{ {
if (!Common::SyncSDFolderToSDImage([]() { return false; }, false)) ParallelProgressDialog progress_dialog(tr("Converting..."), tr("Cancel"), 0, 0, this);
progress_dialog.GetRaw()->setWindowModality(Qt::WindowModal);
progress_dialog.GetRaw()->setWindowTitle(tr("Progress"));
auto success = std::async(std::launch::async, [&] {
const bool good = Common::SyncSDFolderToSDImage(
[&progress_dialog]() { return progress_dialog.WasCanceled(); }, false);
progress_dialog.Reset();
return good;
});
progress_dialog.GetRaw()->exec();
if (!success.get())
ModalMessageBox::warning(this, tr("Convert Folder to File Now"), tr("Conversion failed.")); ModalMessageBox::warning(this, tr("Convert Folder to File Now"), tr("Conversion failed."));
} }
}); });
@ -242,7 +255,17 @@ void WiiPane::CreateSDCard()
QMessageBox::Yes | QMessageBox::No); QMessageBox::Yes | QMessageBox::No);
if (result == QMessageBox::Yes) if (result == QMessageBox::Yes)
{ {
if (!Common::SyncSDImageToSDFolder([]() { return false; })) ParallelProgressDialog progress_dialog(tr("Converting..."), tr("Cancel"), 0, 0, this);
progress_dialog.GetRaw()->setWindowModality(Qt::WindowModal);
progress_dialog.GetRaw()->setWindowTitle(tr("Progress"));
auto success = std::async(std::launch::async, [&] {
const bool good = Common::SyncSDImageToSDFolder(
[&progress_dialog]() { return progress_dialog.WasCanceled(); });
progress_dialog.Reset();
return good;
});
progress_dialog.GetRaw()->exec();
if (!success.get())
ModalMessageBox::warning(this, tr("Convert File to Folder Now"), tr("Conversion failed.")); ModalMessageBox::warning(this, tr("Convert File to Folder Now"), tr("Conversion failed."));
} }
}); });