summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Zach Hilman2018-08-10 15:07:06 -0400
committerGravatar Zach Hilman2018-08-11 22:50:48 -0400
commitf78a6e752f70150f930eb66fe735723f3ffe5654 (patch)
tree6a5b1b12a47c3b190b31326cb6df415c7d6c9371 /src
parentregistration: Take RawCopy function as parameter (diff)
downloadyuzu-f78a6e752f70150f930eb66fe735723f3ffe5654.tar.gz
yuzu-f78a6e752f70150f930eb66fe735723f3ffe5654.tar.xz
yuzu-f78a6e752f70150f930eb66fe735723f3ffe5654.zip
qt: Use custom RawCopy with progress bar for installs
Diffstat (limited to 'src')
-rw-r--r--src/yuzu/main.cpp30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 1f5a9bb02..e8254c30f 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -624,6 +624,32 @@ void GMainWindow::OnMenuInstallToNAND() {
624 "Image (*.xci)"); 624 "Image (*.xci)");
625 QString filename = QFileDialog::getOpenFileName(this, tr("Install File"), 625 QString filename = QFileDialog::getOpenFileName(this, tr("Install File"),
626 UISettings::values.roms_path, file_filter); 626 UISettings::values.roms_path, file_filter);
627
628 const auto qt_raw_copy = [this](FileSys::VirtualFile src, FileSys::VirtualFile dest) {
629 if (src == nullptr || dest == nullptr)
630 return false;
631 if (!dest->Resize(src->GetSize()))
632 return false;
633
634 QProgressDialog progress(fmt::format("Installing file \"{}\"...", src->GetName()).c_str(),
635 "Cancel", 0, src->GetSize() / 0x1000, this);
636 progress.setWindowModality(Qt::WindowModal);
637
638 std::array<u8, 0x1000> buffer{};
639 for (size_t i = 0; i < src->GetSize(); i += 0x1000) {
640 if (progress.wasCanceled()) {
641 dest->Resize(0);
642 return false;
643 }
644
645 progress.setValue(i / 0x1000);
646 const auto read = src->Read(buffer.data(), buffer.size(), i);
647 dest->Write(buffer.data(), read, i);
648 }
649
650 return true;
651 };
652
627 if (!filename.isEmpty()) { 653 if (!filename.isEmpty()) {
628 if (filename.endsWith("xci", Qt::CaseInsensitive)) { 654 if (filename.endsWith("xci", Qt::CaseInsensitive)) {
629 const auto xci = std::make_shared<FileSys::XCI>( 655 const auto xci = std::make_shared<FileSys::XCI>(
@@ -635,7 +661,7 @@ void GMainWindow::OnMenuInstallToNAND() {
635 "keys and the file and try again.")); 661 "keys and the file and try again."));
636 return; 662 return;
637 } 663 }
638 if (Service::FileSystem::GetUserNANDContents()->InstallEntry(xci)) { 664 if (Service::FileSystem::GetUserNANDContents()->InstallEntry(xci, qt_raw_copy)) {
639 QMessageBox::information(this, tr("Successfully Installed XCI"), 665 QMessageBox::information(this, tr("Successfully Installed XCI"),
640 tr("The file was successfully installed.")); 666 tr("The file was successfully installed."));
641 game_list->PopulateAsync(UISettings::values.gamedir, 667 game_list->PopulateAsync(UISettings::values.gamedir,
@@ -685,7 +711,7 @@ void GMainWindow::OnMenuInstallToNAND() {
685 index += 0x7B; 711 index += 0x7B;
686 712
687 if (Service::FileSystem::GetUserNANDContents()->InstallEntry( 713 if (Service::FileSystem::GetUserNANDContents()->InstallEntry(
688 nca, static_cast<FileSys::TitleType>(index))) { 714 nca, static_cast<FileSys::TitleType>(index), qt_raw_copy)) {
689 QMessageBox::information(this, tr("Successfully Installed NCA"), 715 QMessageBox::information(this, tr("Successfully Installed NCA"),
690 tr("The file was successfully installed.")); 716 tr("The file was successfully installed."));
691 game_list->PopulateAsync(UISettings::values.gamedir, 717 game_list->PopulateAsync(UISettings::values.gamedir,