Skip to content

Commit

Permalink
Qt: Hook up extract button in ISO browser
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Dec 5, 2024
1 parent ea63266 commit 3670c13
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/duckstation-qt/isobrowserwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -102,6 +103,16 @@ void ISOBrowserWindow::onOpenFileClicked()
}
}

void ISOBrowserWindow::onExtractClicked()
{
const QList<QTreeWidgetItem*> 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());
Expand Down Expand Up @@ -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")));
Expand Down
1 change: 1 addition & 0 deletions src/duckstation-qt/isobrowserwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class ISOBrowserWindow : public QWidget

private Q_SLOTS:
void onOpenFileClicked();
void onExtractClicked();
void onDirectoryItemClicked(QTreeWidgetItem* item, int column);
void onFileItemActivated(QTreeWidgetItem* item, int column);
void onFileItemSelectionChanged();
Expand Down

0 comments on commit 3670c13

Please sign in to comment.