Qt: Hook up 'Add Game List Directory' function

This commit is contained in:
Connor McLaughlin 2020-01-24 14:50:53 +10:00
parent 98eb71aa3f
commit 0200b9ffc1
6 changed files with 35 additions and 16 deletions

View file

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

View file

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

View file

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

View file

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

View file

@ -92,7 +92,7 @@
<addaction name="actionGPUSettings"/>
<addaction name="actionAudioSettings"/>
<addaction name="separator"/>
<addaction name="actionOpenDirectory"/>
<addaction name="actionAddGameDirectory"/>
<addaction name="separator"/>
</widget>
<widget class="QMenu" name="menuHelp">
@ -150,7 +150,6 @@
</attribute>
<addaction name="actionStartDisc"/>
<addaction name="actionStartBios"/>
<addaction name="actionOpenDirectory"/>
<addaction name="separator"/>
<addaction name="actionPowerOff"/>
<addaction name="actionReset"/>
@ -351,13 +350,13 @@
<string>Game List Settings...</string>
</property>
</action>
<action name="actionOpenDirectory">
<action name="actionAddGameDirectory">
<property name="icon">
<iconset resource="resources/icons.qrc">
<normaloff>:/icons/edit-find.png</normaloff>:/icons/edit-find.png</iconset>
</property>
<property name="text">
<string>Open Directory...</string>
<string>Add Game Directory...</string>
</property>
</action>
<action name="actionSettings">

View file

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