From 3670c131e3379ea0f9a796264268315181563eb0 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Thu, 5 Dec 2024 18:59:32 +1000 Subject: [PATCH] Qt: Hook up extract button in ISO browser --- src/duckstation-qt/isobrowserwindow.cpp | 13 +++++++++++-- src/duckstation-qt/isobrowserwindow.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/duckstation-qt/isobrowserwindow.cpp b/src/duckstation-qt/isobrowserwindow.cpp index cb15c820c..82dc2f8ca 100644 --- a/src/duckstation-qt/isobrowserwindow.cpp +++ b/src/duckstation-qt/isobrowserwindow.cpp @@ -28,6 +28,7 @@ ISOBrowserWindow::ISOBrowserWindow(QWidget* parent) : QWidget(parent) setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); connect(m_ui.openFile, &QAbstractButton::clicked, this, &ISOBrowserWindow::onOpenFileClicked); + connect(m_ui.extract, &QAbstractButton::clicked, this, &ISOBrowserWindow::onExtractClicked); connect(m_ui.directoryView, &QTreeWidget::itemClicked, this, &ISOBrowserWindow::onDirectoryItemClicked); connect(m_ui.fileView, &QTreeWidget::itemActivated, this, &ISOBrowserWindow::onFileItemActivated); connect(m_ui.fileView, &QTreeWidget::itemSelectionChanged, this, &ISOBrowserWindow::onFileItemSelectionChanged); @@ -102,6 +103,16 @@ void ISOBrowserWindow::onOpenFileClicked() } } +void ISOBrowserWindow::onExtractClicked() +{ + const QList items = m_ui.fileView->selectedItems(); + if (items.isEmpty()) + return; + + const QString path = items.front()->data(0, Qt::UserRole).toString(); + extractFile(path); +} + void ISOBrowserWindow::onDirectoryItemClicked(QTreeWidgetItem* item, int column) { populateFiles(item->data(0, Qt::UserRole).toString()); @@ -295,8 +306,6 @@ void ISOBrowserWindow::populateFiles(const QString& path) } const auto add_entry = [this](const std::string& full_path, const IsoReader::ISODirectoryEntry& entry) { - const std::string_view filename = Path::GetFileName(full_path); - QTreeWidgetItem* item = new QTreeWidgetItem; item->setIcon( 0, QIcon::fromTheme(entry.IsDirectory() ? QStringLiteral("folder-open-line") : QStringLiteral("file-line"))); diff --git a/src/duckstation-qt/isobrowserwindow.h b/src/duckstation-qt/isobrowserwindow.h index 6e67c8c03..c13141bbb 100644 --- a/src/duckstation-qt/isobrowserwindow.h +++ b/src/duckstation-qt/isobrowserwindow.h @@ -25,6 +25,7 @@ protected: private Q_SLOTS: void onOpenFileClicked(); + void onExtractClicked(); void onDirectoryItemClicked(QTreeWidgetItem* item, int column); void onFileItemActivated(QTreeWidgetItem* item, int column); void onFileItemSelectionChanged();