From 351f2e10737b26bc2f82e44f770e051a354dbf8b Mon Sep 17 00:00:00 2001 From: ElBread3 <92335081+ElBread3@users.noreply.github.com> Date: Thu, 8 Aug 2024 13:23:44 -0500 Subject: [PATCH] double click to open games --- src/qt_gui/main_window.cpp | 58 +++++++++++++++++++++----------------- src/qt_gui/main_window.h | 1 + 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/src/qt_gui/main_window.cpp b/src/qt_gui/main_window.cpp index 0b88a84f..29d7c15f 100644 --- a/src/qt_gui/main_window.cpp +++ b/src/qt_gui/main_window.cpp @@ -179,32 +179,11 @@ void MainWindow::CreateConnects() { } }); - connect(ui->playButton, &QPushButton::clicked, this, [this]() { - QString gamePath = ""; - int table_mode = Config::getTableMode(); - if (table_mode == 0) { - if (m_game_list_frame->currentItem()) { - int itemID = m_game_list_frame->currentItem()->row(); - gamePath = QString::fromStdString(m_game_info->m_games[itemID].path + "/eboot.bin"); - } - } else if (table_mode == 1) { - if (m_game_grid_frame->cellClicked) { - int itemID = (m_game_grid_frame->crtRow * m_game_grid_frame->columnCnt) + - m_game_grid_frame->crtColumn; - gamePath = QString::fromStdString(m_game_info->m_games[itemID].path + "/eboot.bin"); - } - } else { - if (m_elf_viewer->currentItem()) { - int itemID = m_elf_viewer->currentItem()->row(); - gamePath = QString::fromStdString(m_elf_viewer->m_elf_list[itemID].toStdString()); - } - } - if (gamePath != "") { - AddRecentFiles(gamePath); - Core::Emulator emulator; - emulator.Run(gamePath.toUtf8().constData()); - } - }); + connect(ui->playButton, &QPushButton::clicked, this, &MainWindow::StartGame); + connect(m_game_grid_frame.get(), &QTableWidget::cellDoubleClicked, this, + &MainWindow::StartGame); + connect(m_game_list_frame.get(), &QTableWidget::cellDoubleClicked, this, + &MainWindow::StartGame); connect(ui->setIconSizeTinyAct, &QAction::triggered, this, [this]() { if (isTableList) { @@ -386,6 +365,33 @@ void MainWindow::CreateConnects() { }); } +void MainWindow::StartGame() { + QString gamePath = ""; + int table_mode = Config::getTableMode(); + if (table_mode == 0) { + if (m_game_list_frame->currentItem()) { + int itemID = m_game_list_frame->currentItem()->row(); + gamePath = QString::fromStdString(m_game_info->m_games[itemID].path + "/eboot.bin"); + } + } else if (table_mode == 1) { + if (m_game_grid_frame->cellClicked) { + int itemID = (m_game_grid_frame->crtRow * m_game_grid_frame->columnCnt) + + m_game_grid_frame->crtColumn; + gamePath = QString::fromStdString(m_game_info->m_games[itemID].path + "/eboot.bin"); + } + } else { + if (m_elf_viewer->currentItem()) { + int itemID = m_elf_viewer->currentItem()->row(); + gamePath = QString::fromStdString(m_elf_viewer->m_elf_list[itemID].toStdString()); + } + } + if (gamePath != "") { + AddRecentFiles(gamePath); + Core::Emulator emulator; + emulator.Run(gamePath.toUtf8().constData()); + } +} + void MainWindow::SearchGameTable(const QString& text) { if (isTableList) { for (int row = 0; row < m_game_list_frame->rowCount(); row++) { diff --git a/src/qt_gui/main_window.h b/src/qt_gui/main_window.h index d1ef48dc..39a5d049 100644 --- a/src/qt_gui/main_window.h +++ b/src/qt_gui/main_window.h @@ -39,6 +39,7 @@ public: bool Init(); void InstallDragDropPkg(std::filesystem::path file, int pkgNum, int nPkg); void InstallDirectory(); + void StartGame(); private Q_SLOTS: void ConfigureGuiFromSettings();