diff --git a/src/duckstation-qt/gamelistwidget.cpp b/src/duckstation-qt/gamelistwidget.cpp index f36afeed4..9b045e6a2 100644 --- a/src/duckstation-qt/gamelistwidget.cpp +++ b/src/duckstation-qt/gamelistwidget.cpp @@ -269,6 +269,8 @@ void GameListWidget::initialize(QtHostInterface* host_interface) m_table_view->resizeColumnsToContents(); connect(m_table_view, &QTableView::doubleClicked, this, &GameListWidget::onTableViewItemDoubleClicked); + connect(m_table_view->selectionModel(), &QItemSelectionModel::currentChanged, this, + &GameListWidget::onSelectionModelCurrentChanged); insertWidget(0, m_table_view); setCurrentIndex(0); @@ -289,6 +291,19 @@ void GameListWidget::onTableViewItemDoubleClicked(const QModelIndex& index) emit bootEntryRequested(&entry); } +void GameListWidget::onSelectionModelCurrentChanged(const QModelIndex& current, const QModelIndex& previous) +{ + const QModelIndex source_index = m_table_sort_model->mapToSource(current); + if (!source_index.isValid() || source_index.row() >= static_cast(m_game_list->GetEntryCount())) + { + emit entrySelected(nullptr); + return; + } + + const GameList::GameListEntry& entry = m_game_list->GetEntries().at(source_index.row()); + emit entrySelected(&entry); +} + void GameListWidget::resizeEvent(QResizeEvent* event) { QStackedWidget::resizeEvent(event); diff --git a/src/duckstation-qt/gamelistwidget.h b/src/duckstation-qt/gamelistwidget.h index ebe9ec720..b59c3d76b 100644 --- a/src/duckstation-qt/gamelistwidget.h +++ b/src/duckstation-qt/gamelistwidget.h @@ -19,11 +19,13 @@ public: void initialize(QtHostInterface* host_interface); Q_SIGNALS: - void bootEntryRequested(const GameList::GameListEntry& entry); + void entrySelected(const GameList::GameListEntry* entry); + void bootEntryRequested(const GameList::GameListEntry* entry); private Q_SLOTS: void onGameListRefreshed(); void onTableViewItemDoubleClicked(const QModelIndex& index); + void onSelectionModelCurrentChanged(const QModelIndex& current, const QModelIndex& previous); protected: void resizeEvent(QResizeEvent* event); diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index ed3d776e4..b855e3d6b 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -260,9 +260,9 @@ void MainWindow::connectSignals() connect(m_host_interface, &QtHostInterface::emulationPaused, this, &MainWindow::onEmulationPaused); connect(m_host_interface, &QtHostInterface::toggleFullscreenRequested, this, &MainWindow::toggleFullscreen); - connect(m_game_list_widget, &GameListWidget::bootEntryRequested, [this](const GameList::GameListEntry& entry) { + connect(m_game_list_widget, &GameListWidget::bootEntryRequested, [this](const GameList::GameListEntry* entry) { // if we're not running, boot the system, otherwise swap discs - QString path = QString::fromStdString(entry.path); + QString path = QString::fromStdString(entry->path); if (!m_emulation_running) { m_host_interface->bootSystem(path, QString());