From dcaee9b87e8f1baded413839c4516b705ab1261d Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 14 Dec 2024 14:04:42 +1000 Subject: [PATCH] Qt: Add ISO Browser to Tools menu --- src/duckstation-qt/isobrowserwindow.cpp | 11 +++++++++++ src/duckstation-qt/isobrowserwindow.h | 1 + src/duckstation-qt/isobrowserwindow.ui | 2 +- src/duckstation-qt/mainwindow.cpp | 8 ++++++++ src/duckstation-qt/mainwindow.h | 1 + src/duckstation-qt/mainwindow.ui | 6 ++++++ 6 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/duckstation-qt/isobrowserwindow.cpp b/src/duckstation-qt/isobrowserwindow.cpp index 82dc2f8ca..b06475727 100644 --- a/src/duckstation-qt/isobrowserwindow.cpp +++ b/src/duckstation-qt/isobrowserwindow.cpp @@ -26,6 +26,7 @@ ISOBrowserWindow::ISOBrowserWindow(QWidget* parent) : QWidget(parent) m_ui.setupUi(this); m_ui.splitter->setSizes({200, 600}); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + enableUi(false); connect(m_ui.openFile, &QAbstractButton::clicked, this, &ISOBrowserWindow::onOpenFileClicked); connect(m_ui.extract, &QAbstractButton::clicked, this, &ISOBrowserWindow::onExtractClicked); @@ -69,6 +70,7 @@ bool ISOBrowserWindow::tryOpenFile(const QString& path, Error* error /*= nullptr m_iso = std::move(new_reader); m_ui.openPath->setText(QString::fromStdString(native_path)); setWindowTitle(tr("ISO Browser - %1").arg(QtUtils::StringViewToQString(Path::GetFileName(native_path)))); + enableUi(true); populateDirectories(); populateFiles(QString()); return true; @@ -248,6 +250,15 @@ QTreeWidgetItem* ISOBrowserWindow::findDirectoryItemForPath(const QString& path, return nullptr; } +void ISOBrowserWindow::enableUi(bool enabled) +{ + m_ui.directoryView->setEnabled(enabled); + m_ui.fileView->setEnabled(enabled); + + if (!enabled) + m_ui.extract->setEnabled(enabled); +} + void ISOBrowserWindow::populateDirectories() { m_ui.directoryView->clear(); diff --git a/src/duckstation-qt/isobrowserwindow.h b/src/duckstation-qt/isobrowserwindow.h index c13141bbb..d681f8801 100644 --- a/src/duckstation-qt/isobrowserwindow.h +++ b/src/duckstation-qt/isobrowserwindow.h @@ -33,6 +33,7 @@ private Q_SLOTS: void resizeFileListColumns(); private: + void enableUi(bool enabled); void populateDirectories(); void populateSubdirectories(std::string_view dir, QTreeWidgetItem* parent); void populateFiles(const QString& path); diff --git a/src/duckstation-qt/isobrowserwindow.ui b/src/duckstation-qt/isobrowserwindow.ui index 5dd42e5fc..5fe32dd6f 100644 --- a/src/duckstation-qt/isobrowserwindow.ui +++ b/src/duckstation-qt/isobrowserwindow.ui @@ -11,7 +11,7 @@ - Form + ISO Browser diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index 63b3c8053..efb7fe603 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -2008,6 +2008,7 @@ void MainWindow::connectSignals() connect(m_ui.actionCheckForUpdates, &QAction::triggered, this, &MainWindow::onCheckForUpdatesActionTriggered); connect(m_ui.actionMemoryCardEditor, &QAction::triggered, this, &MainWindow::onToolsMemoryCardEditorTriggered); connect(m_ui.actionMemoryScanner, &QAction::triggered, this, &MainWindow::onToolsMemoryScannerTriggered); + connect(m_ui.actionISOBrowser, &QAction::triggered, this, &MainWindow::onToolsISOBrowserTriggered); connect(m_ui.actionCoverDownloader, &QAction::triggered, this, &MainWindow::onToolsCoverDownloaderTriggered); connect(m_ui.actionMediaCapture, &QAction::toggled, this, &MainWindow::onToolsMediaCaptureToggled); connect(m_ui.actionCaptureGPUFrame, &QAction::triggered, g_emu_thread, &EmuThread::captureGPUFrameDump); @@ -2710,6 +2711,13 @@ void MainWindow::onToolsMemoryScannerTriggered() QtUtils::ShowOrRaiseWindow(m_memory_scanner_window); } +void MainWindow::onToolsISOBrowserTriggered() +{ + ISOBrowserWindow* ib = new ISOBrowserWindow(); + ib->setAttribute(Qt::WA_DeleteOnClose); + ib->show(); +} + void MainWindow::openCPUDebugger() { if (!m_debugger_window) diff --git a/src/duckstation-qt/mainwindow.h b/src/duckstation-qt/mainwindow.h index 1f8e573c6..2a7c2656f 100644 --- a/src/duckstation-qt/mainwindow.h +++ b/src/duckstation-qt/mainwindow.h @@ -186,6 +186,7 @@ private Q_SLOTS: void onCheckForUpdatesActionTriggered(); void onToolsMemoryCardEditorTriggered(); void onToolsMemoryScannerTriggered(); + void onToolsISOBrowserTriggered(); void onToolsCoverDownloaderTriggered(); void onToolsMediaCaptureToggled(bool checked); void onToolsOpenDataDirectoryTriggered(); diff --git a/src/duckstation-qt/mainwindow.ui b/src/duckstation-qt/mainwindow.ui index 704f51509..f4a8e9395 100644 --- a/src/duckstation-qt/mainwindow.ui +++ b/src/duckstation-qt/mainwindow.ui @@ -229,6 +229,7 @@ + @@ -961,6 +962,11 @@ Log To File + + + ISO Browser + +