From 0200b9ffc147ed60dddedfc86e50a1e08ba3da30 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Fri, 24 Jan 2020 14:50:53 +1000 Subject: [PATCH] Qt: Hook up 'Add Game List Directory' function --- src/duckstation-qt/gamelistsettingswidget.cpp | 9 ++++++-- src/duckstation-qt/gamelistsettingswidget.h | 3 +++ src/duckstation-qt/mainwindow.cpp | 23 +++++++++++-------- src/duckstation-qt/mainwindow.h | 2 +- src/duckstation-qt/mainwindow.ui | 7 +++--- src/duckstation-qt/settingsdialog.h | 7 ++++++ 6 files changed, 35 insertions(+), 16 deletions(-) diff --git a/src/duckstation-qt/gamelistsettingswidget.cpp b/src/duckstation-qt/gamelistsettingswidget.cpp index f75911aea..91d4ec442 100644 --- a/src/duckstation-qt/gamelistsettingswidget.cpp +++ b/src/duckstation-qt/gamelistsettingswidget.cpp @@ -232,9 +232,9 @@ void GameListSettingsWidget::onDirectoryListItemClicked(const QModelIndex& index m_search_directories_model->setEntryRecursive(row, !m_search_directories_model->isEntryRecursive(row)); } -void GameListSettingsWidget::onAddSearchDirectoryButtonPressed() +void GameListSettingsWidget::addSearchDirectory(QWidget* parent_widget) { - QString dir = QFileDialog::getExistingDirectory(this, tr("Select Search Directory")); + QString dir = QFileDialog::getExistingDirectory(parent_widget, tr("Select Search Directory")); if (dir.isEmpty()) return; @@ -251,6 +251,11 @@ void GameListSettingsWidget::onAddSearchDirectoryButtonPressed() m_search_directories_model->addEntry(dir, recursive); } +void GameListSettingsWidget::onAddSearchDirectoryButtonPressed() +{ + addSearchDirectory(this); +} + void GameListSettingsWidget::onRemoveSearchDirectoryButtonPressed() { QModelIndexList selection = m_ui.searchDirectoryList->selectionModel()->selectedIndexes(); diff --git a/src/duckstation-qt/gamelistsettingswidget.h b/src/duckstation-qt/gamelistsettingswidget.h index e3f343fc2..a4b6b9045 100644 --- a/src/duckstation-qt/gamelistsettingswidget.h +++ b/src/duckstation-qt/gamelistsettingswidget.h @@ -16,6 +16,9 @@ public: GameListSettingsWidget(QtHostInterface* host_interface, QWidget* parent = nullptr); ~GameListSettingsWidget(); +public Q_SLOTS: + void addSearchDirectory(QWidget* parent_widget); + private Q_SLOTS: void onDirectoryListItemClicked(const QModelIndex& index); void onAddSearchDirectoryButtonPressed(); diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index d5723f3e4..05081d2c9 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -1,6 +1,7 @@ #include "mainwindow.h" #include "core/game_list.h" #include "core/settings.h" +#include "gamelistsettingswidget.h" #include "gamelistwidget.h" #include "qthostinterface.h" #include "qtsettingsinterface.h" @@ -160,8 +161,6 @@ void MainWindow::onStartBiosActionTriggered() m_host_interface->bootSystem(QString(), QString()); } -void MainWindow::onOpenDirectoryActionTriggered() {} - void MainWindow::onExitActionTriggered() {} void MainWindow::onGitHubRepositoryActionTriggered() {} @@ -213,7 +212,6 @@ void MainWindow::updateEmulationActions(bool starting, bool running) { m_ui.actionStartDisc->setDisabled(starting || running); m_ui.actionStartBios->setDisabled(starting || running); - m_ui.actionOpenDirectory->setDisabled(starting || running); m_ui.actionPowerOff->setDisabled(starting || running); m_ui.actionPowerOff->setDisabled(starting || !running); @@ -271,7 +269,8 @@ void MainWindow::connectSignals() connect(m_ui.actionChangeDiscFromFile, &QAction::triggered, this, &MainWindow::onChangeDiscFromFileActionTriggered); connect(m_ui.actionChangeDiscFromGameList, &QAction::triggered, this, &MainWindow::onChangeDiscFromGameListActionTriggered); - connect(m_ui.actionOpenDirectory, &QAction::triggered, this, &MainWindow::onOpenDirectoryActionTriggered); + connect(m_ui.actionAddGameDirectory, &QAction::triggered, + [this]() { getSettingsDialog()->getGameListSettingsWidget()->addSearchDirectory(this); }); connect(m_ui.actionPowerOff, &QAction::triggered, m_host_interface, &QtHostInterface::powerOffSystem); connect(m_ui.actionReset, &QAction::triggered, m_host_interface, &QtHostInterface::resetSystem); connect(m_ui.actionPause, &QAction::toggled, m_host_interface, &QtHostInterface::pauseSystem); @@ -333,19 +332,25 @@ void MainWindow::connectSignals() }); } -void MainWindow::doSettings(SettingsDialog::Category category) +SettingsDialog* MainWindow::getSettingsDialog() { if (!m_settings_dialog) m_settings_dialog = new SettingsDialog(m_host_interface, this); - if (!m_settings_dialog->isVisible()) + return m_settings_dialog; +} + +void MainWindow::doSettings(SettingsDialog::Category category) +{ + SettingsDialog* dlg = getSettingsDialog(); + if (!dlg->isVisible()) { - m_settings_dialog->setModal(false); - m_settings_dialog->show(); + dlg->setModal(false); + dlg->show(); } if (category != SettingsDialog::Category::Count) - m_settings_dialog->setCategory(category); + dlg->setCategory(category); } void MainWindow::updateDebugMenuGPURenderer() diff --git a/src/duckstation-qt/mainwindow.h b/src/duckstation-qt/mainwindow.h index e195c41e1..da296786c 100644 --- a/src/duckstation-qt/mainwindow.h +++ b/src/duckstation-qt/mainwindow.h @@ -35,7 +35,6 @@ private Q_SLOTS: void onChangeDiscFromFileActionTriggered(); void onChangeDiscFromGameListActionTriggered(); void onStartBiosActionTriggered(); - void onOpenDirectoryActionTriggered(); void onExitActionTriggered(); void onGitHubRepositoryActionTriggered(); void onIssueTrackerActionTriggered(); @@ -47,6 +46,7 @@ private: void updateEmulationActions(bool starting, bool running); void switchToGameListView(); void switchToEmulationView(); + SettingsDialog* getSettingsDialog(); void doSettings(SettingsDialog::Category category = SettingsDialog::Category::Count); void updateDebugMenuGPURenderer(); void populateLoadSaveStateMenus(QString game_code); diff --git a/src/duckstation-qt/mainwindow.ui b/src/duckstation-qt/mainwindow.ui index ac2883e18..e9ca9abb3 100644 --- a/src/duckstation-qt/mainwindow.ui +++ b/src/duckstation-qt/mainwindow.ui @@ -92,7 +92,7 @@ - + @@ -150,7 +150,6 @@ - @@ -351,13 +350,13 @@ Game List Settings... - + :/icons/edit-find.png:/icons/edit-find.png - Open Directory... + Add Game Directory... diff --git a/src/duckstation-qt/settingsdialog.h b/src/duckstation-qt/settingsdialog.h index 167e46168..ddb44fee3 100644 --- a/src/duckstation-qt/settingsdialog.h +++ b/src/duckstation-qt/settingsdialog.h @@ -30,6 +30,13 @@ public: SettingsDialog(QtHostInterface* host_interface, QWidget* parent = nullptr); ~SettingsDialog(); + ConsoleSettingsWidget* getConsoleSettingsWidget() const { return m_console_settings; } + GameListSettingsWidget* getGameListSettingsWidget() const { return m_game_list_settings; } + HotkeySettingsWidget* getHotkeySettingsWidget() const { return m_hotkey_settings; } + PortSettingsWidget* getPortSettingsWidget() const { return m_port_settings; } + GPUSettingsWidget* getGPUSettingsWidget() const { return m_gpu_settings; } + QWidget* getAudioSettingsWidget() const { return m_audio_settings; } + public Q_SLOTS: void setCategory(Category category);