mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-18 09:24:58 +00:00
Improve keyboard navigation in game list (#1132)
* Improve keyboard navigation * don't start game in elf viewer mode or gridview mode with empty item selected * fix eventFilter return
This commit is contained in:
parent
7b5d66e5c1
commit
dc96338c2e
6 changed files with 67 additions and 38 deletions
|
@ -22,7 +22,7 @@ GameGridFrame::GameGridFrame(std::shared_ptr<GameInfoClass> game_info_get, QWidg
|
|||
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
PopulateGameGrid(m_game_info->m_games, false);
|
||||
|
||||
connect(this, &QTableWidget::cellClicked, this, &GameGridFrame::SetGridBackgroundImage);
|
||||
connect(this, &QTableWidget::currentCellChanged, this, &GameGridFrame::onCurrentCellChanged);
|
||||
|
||||
connect(this->verticalScrollBar(), &QScrollBar::valueChanged, this,
|
||||
&GameGridFrame::RefreshGridBackgroundImage);
|
||||
|
@ -31,22 +31,33 @@ GameGridFrame::GameGridFrame(std::shared_ptr<GameInfoClass> game_info_get, QWidg
|
|||
connect(this, &QTableWidget::customContextMenuRequested, this, [=, this](const QPoint& pos) {
|
||||
m_gui_context_menus.RequestGameMenu(pos, m_game_info->m_games, this, false);
|
||||
});
|
||||
connect(this, &QTableWidget::cellClicked, this, [&]() {
|
||||
cellClicked = true;
|
||||
crtRow = this->currentRow();
|
||||
crtColumn = this->currentColumn();
|
||||
columnCnt = this->columnCount();
|
||||
});
|
||||
}
|
||||
|
||||
void GameGridFrame::PlayBackgroundMusic(QTableWidgetItem* item) {
|
||||
if (!item) {
|
||||
void GameGridFrame::onCurrentCellChanged(int currentRow, int currentColumn, int previousRow,
|
||||
int previousColumn) {
|
||||
cellClicked = true;
|
||||
crtRow = currentRow;
|
||||
crtColumn = currentColumn;
|
||||
columnCnt = this->columnCount();
|
||||
|
||||
auto itemID = (crtRow * columnCnt) + currentColumn;
|
||||
if (itemID > m_game_info->m_games.count() - 1) {
|
||||
validCellSelected = false;
|
||||
BackgroundMusicPlayer::getInstance().stopMusic();
|
||||
return;
|
||||
}
|
||||
QString snd0path;
|
||||
Common::FS::PathToQString(snd0path, m_game_info->m_games[item->row()].snd0_path);
|
||||
BackgroundMusicPlayer::getInstance().playMusic(snd0path);
|
||||
validCellSelected = true;
|
||||
SetGridBackgroundImage(crtRow, crtColumn);
|
||||
auto snd0Path = QString::fromStdString(m_game_info->m_games[itemID].snd0_path.string());
|
||||
PlayBackgroundMusic(snd0Path);
|
||||
}
|
||||
|
||||
void GameGridFrame::PlayBackgroundMusic(QString path) {
|
||||
if (path.isEmpty()) {
|
||||
BackgroundMusicPlayer::getInstance().stopMusic();
|
||||
return;
|
||||
}
|
||||
BackgroundMusicPlayer::getInstance().playMusic(path);
|
||||
}
|
||||
|
||||
void GameGridFrame::PopulateGameGrid(QVector<GameInfo> m_games_search, bool fromSearch) {
|
||||
|
@ -157,3 +168,7 @@ void GameGridFrame::RefreshGridBackgroundImage() {
|
|||
this->setPalette(palette);
|
||||
}
|
||||
}
|
||||
|
||||
bool GameGridFrame::IsValidCellSelected() {
|
||||
return validCellSelected;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue