Qt: Hook up extract button in ISO browser

This commit is contained in:
Stenzek 2024-12-05 18:59:32 +10:00
parent ea632665c1
commit 3670c131e3
No known key found for this signature in database
2 changed files with 12 additions and 2 deletions

View File

@ -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<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());
@ -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")));

View File

@ -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();