From 1a74de6462c7fc3d242190e4be02189b8b265b53 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 5 May 2018 16:27:36 +0200 Subject: [PATCH 1/3] DolphinQt2: Fix the file structure of extracted discs Now all the partitions won't be all jumbled up in one folder, and the filesystem contents won't be mixed with system data. --- Source/Core/DolphinQt2/Config/FilesystemWidget.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Source/Core/DolphinQt2/Config/FilesystemWidget.cpp b/Source/Core/DolphinQt2/Config/FilesystemWidget.cpp index 950833eb72..a8b3ddc220 100644 --- a/Source/Core/DolphinQt2/Config/FilesystemWidget.cpp +++ b/Source/Core/DolphinQt2/Config/FilesystemWidget.cpp @@ -181,8 +181,15 @@ void FilesystemWidget::ShowContextMenu(const QPoint&) } else { - for (auto& p : m_volume->GetPartitions()) - ExtractPartition(p, folder); + for (DiscIO::Partition& p : m_volume->GetPartitions()) + { + if (const std::optional partition_type = m_volume->GetPartitionType(p)) + { + const std::string partition_name = + DiscIO::DirectoryNameForPartitionType(*partition_type); + ExtractPartition(p, folder + QChar(u'/') + QString::fromStdString(partition_name)); + } + } } }); break; @@ -224,7 +231,7 @@ DiscIO::Partition FilesystemWidget::GetPartitionFromID(int id) void FilesystemWidget::ExtractPartition(const DiscIO::Partition& partition, const QString& out) { - ExtractDirectory(partition, QStringLiteral(""), out); + ExtractDirectory(partition, QStringLiteral(""), out + QStringLiteral("/files")); ExtractSystemData(partition, out); } From f48fac5b55fbcc422bc2e66a1df023d606fb8a72 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 5 May 2018 16:39:51 +0200 Subject: [PATCH 2/3] DolphinQt2: Allow picking "Extract Files..." on disc/partition DolphinWX already does this. --- .../DolphinQt2/Config/FilesystemWidget.cpp | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/Source/Core/DolphinQt2/Config/FilesystemWidget.cpp b/Source/Core/DolphinQt2/Config/FilesystemWidget.cpp index a8b3ddc220..5c8126c219 100644 --- a/Source/Core/DolphinQt2/Config/FilesystemWidget.cpp +++ b/Source/Core/DolphinQt2/Config/FilesystemWidget.cpp @@ -155,8 +155,20 @@ void FilesystemWidget::ShowContextMenu(const QPoint&) GetPartitionFromID(item->data(ENTRY_PARTITION).toInt()); QString path = item->data(ENTRY_NAME).toString(); - if ((type == EntryType::Disc && m_volume->GetPartitions().empty()) || - type == EntryType::Partition) + const bool is_filesystem_root = (type == EntryType::Disc && m_volume->GetPartitions().empty()) || + type == EntryType::Partition; + + if (type == EntryType::Dir || is_filesystem_root) + { + AddAction(menu, tr("Extract Files..."), this, [this, partition, path] { + auto folder = SelectFolder(); + + if (!folder.isEmpty()) + ExtractDirectory(partition, path, folder); + }); + } + + if (is_filesystem_root) { AddAction(menu, tr("Extract System Data..."), this, [this, partition] { auto folder = SelectFolder(); @@ -203,14 +215,6 @@ void FilesystemWidget::ShowContextMenu(const QPoint&) AddAction(menu, tr("Check Partition Integrity"), this, [this, partition] { CheckIntegrity(partition); }); break; - case EntryType::Dir: - AddAction(menu, tr("Extract Files..."), this, [this, partition, path] { - auto folder = SelectFolder(); - - if (!folder.isEmpty()) - ExtractDirectory(partition, path, folder); - }); - break; case EntryType::File: AddAction(menu, tr("Extract File..."), this, [this, partition, path] { auto dest = QFileDialog::getSaveFileName(this, tr("Save File to")); @@ -219,6 +223,9 @@ void FilesystemWidget::ShowContextMenu(const QPoint&) ExtractFile(partition, path, dest); }); break; + case EntryType::Dir: + // Handled above the switch statement + break; } menu->exec(QCursor::pos()); From 33211d86903869e7bb23fa7b3d2f8e42fd592ba8 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 5 May 2018 16:59:21 +0200 Subject: [PATCH 3/3] DolphinQt2: Don't show pop-ups in the middle of extracting a whole disc --- .../DolphinQt2/Config/FilesystemWidget.cpp | 18 +++++++++--------- .../Core/DolphinQt2/Config/FilesystemWidget.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Source/Core/DolphinQt2/Config/FilesystemWidget.cpp b/Source/Core/DolphinQt2/Config/FilesystemWidget.cpp index 5c8126c219..dc27b9df91 100644 --- a/Source/Core/DolphinQt2/Config/FilesystemWidget.cpp +++ b/Source/Core/DolphinQt2/Config/FilesystemWidget.cpp @@ -173,8 +173,13 @@ void FilesystemWidget::ShowContextMenu(const QPoint&) AddAction(menu, tr("Extract System Data..."), this, [this, partition] { auto folder = SelectFolder(); - if (!folder.isEmpty()) - ExtractSystemData(partition, folder); + if (folder.isEmpty()) + return; + + if (ExtractSystemData(partition, folder)) + QMessageBox::information(nullptr, tr("Success"), tr("Successfully extracted system data.")); + else + QMessageBox::critical(nullptr, tr("Error"), tr("Failed to extract system data.")); }); } @@ -242,14 +247,9 @@ void FilesystemWidget::ExtractPartition(const DiscIO::Partition& partition, cons ExtractSystemData(partition, out); } -void FilesystemWidget::ExtractSystemData(const DiscIO::Partition& partition, const QString& out) +bool FilesystemWidget::ExtractSystemData(const DiscIO::Partition& partition, const QString& out) { - bool success = DiscIO::ExportSystemData(*m_volume, partition, out.toStdString()); - - if (success) - QMessageBox::information(nullptr, tr("Success"), tr("Successfully extracted system data.")); - else - QMessageBox::critical(nullptr, tr("Error"), tr("Failed to extract system data.")); + return DiscIO::ExportSystemData(*m_volume, partition, out.toStdString()); } void FilesystemWidget::ExtractDirectory(const DiscIO::Partition& partition, const QString& path, diff --git a/Source/Core/DolphinQt2/Config/FilesystemWidget.h b/Source/Core/DolphinQt2/Config/FilesystemWidget.h index b06892f811..925672c49a 100644 --- a/Source/Core/DolphinQt2/Config/FilesystemWidget.h +++ b/Source/Core/DolphinQt2/Config/FilesystemWidget.h @@ -39,7 +39,7 @@ private: void ExtractDirectory(const DiscIO::Partition& partition, const QString& path, const QString& out); void ExtractFile(const DiscIO::Partition& partition, const QString& path, const QString& out); - void ExtractSystemData(const DiscIO::Partition& partition, const QString& out); + bool ExtractSystemData(const DiscIO::Partition& partition, const QString& out); void CheckIntegrity(const DiscIO::Partition& partition); DiscIO::Partition GetPartitionFromID(int id);