mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-17 22:25:37 +00:00
Qt: Add a signal when the game list selection is changed
This commit is contained in:
parent
99af858562
commit
67710ca184
|
@ -269,6 +269,8 @@ void GameListWidget::initialize(QtHostInterface* host_interface)
|
||||||
m_table_view->resizeColumnsToContents();
|
m_table_view->resizeColumnsToContents();
|
||||||
|
|
||||||
connect(m_table_view, &QTableView::doubleClicked, this, &GameListWidget::onTableViewItemDoubleClicked);
|
connect(m_table_view, &QTableView::doubleClicked, this, &GameListWidget::onTableViewItemDoubleClicked);
|
||||||
|
connect(m_table_view->selectionModel(), &QItemSelectionModel::currentChanged, this,
|
||||||
|
&GameListWidget::onSelectionModelCurrentChanged);
|
||||||
|
|
||||||
insertWidget(0, m_table_view);
|
insertWidget(0, m_table_view);
|
||||||
setCurrentIndex(0);
|
setCurrentIndex(0);
|
||||||
|
@ -289,6 +291,19 @@ void GameListWidget::onTableViewItemDoubleClicked(const QModelIndex& index)
|
||||||
emit bootEntryRequested(&entry);
|
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<int>(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)
|
void GameListWidget::resizeEvent(QResizeEvent* event)
|
||||||
{
|
{
|
||||||
QStackedWidget::resizeEvent(event);
|
QStackedWidget::resizeEvent(event);
|
||||||
|
|
|
@ -19,11 +19,13 @@ public:
|
||||||
void initialize(QtHostInterface* host_interface);
|
void initialize(QtHostInterface* host_interface);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void bootEntryRequested(const GameList::GameListEntry& entry);
|
void entrySelected(const GameList::GameListEntry* entry);
|
||||||
|
void bootEntryRequested(const GameList::GameListEntry* entry);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onGameListRefreshed();
|
void onGameListRefreshed();
|
||||||
void onTableViewItemDoubleClicked(const QModelIndex& index);
|
void onTableViewItemDoubleClicked(const QModelIndex& index);
|
||||||
|
void onSelectionModelCurrentChanged(const QModelIndex& current, const QModelIndex& previous);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent* event);
|
void resizeEvent(QResizeEvent* event);
|
||||||
|
|
|
@ -260,9 +260,9 @@ void MainWindow::connectSignals()
|
||||||
connect(m_host_interface, &QtHostInterface::emulationPaused, this, &MainWindow::onEmulationPaused);
|
connect(m_host_interface, &QtHostInterface::emulationPaused, this, &MainWindow::onEmulationPaused);
|
||||||
connect(m_host_interface, &QtHostInterface::toggleFullscreenRequested, this, &MainWindow::toggleFullscreen);
|
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
|
// 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)
|
if (!m_emulation_running)
|
||||||
{
|
{
|
||||||
m_host_interface->bootSystem(path, QString());
|
m_host_interface->bootSystem(path, QString());
|
||||||
|
|
Loading…
Reference in a new issue