mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-06 23:11:25 +12:00
UI: Focus to game searchbar on load
Make return key press focus to game list's first entry.
This commit is contained in:
parent
6ff04ec91b
commit
9778322d99
5 changed files with 40 additions and 0 deletions
|
@ -45,3 +45,13 @@ void game_list::leaveEvent(QEvent */*event*/)
|
|||
m_last_hover_item = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void game_list::FocusAndSelectFirstEntryIfNoneIs()
|
||||
{
|
||||
if (QTableWidgetItem* item = itemAt(0, 0); item && selectedIndexes().isEmpty())
|
||||
{
|
||||
setCurrentItem(item);
|
||||
}
|
||||
|
||||
setFocus();
|
||||
}
|
||||
|
|
|
@ -35,6 +35,9 @@ class game_list : public QTableWidget
|
|||
public:
|
||||
void clear_list(); // Use this instead of clearContents
|
||||
|
||||
public Q_SLOTS:
|
||||
void FocusAndSelectFirstEntryIfNoneIs();
|
||||
|
||||
protected:
|
||||
movie_item* m_last_hover_item = nullptr;
|
||||
|
||||
|
|
|
@ -2422,6 +2422,28 @@ void game_list_frame::SetSearchText(const QString& text)
|
|||
Refresh();
|
||||
}
|
||||
|
||||
void game_list_frame::FocusAndSelectFirstEntryIfNoneIs()
|
||||
{
|
||||
if (m_is_list_layout)
|
||||
{
|
||||
if (!m_game_list)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_game_list->FocusAndSelectFirstEntryIfNoneIs();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_game_grid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_game_grid->FocusAndSelectFirstEntryIfNoneIs();
|
||||
}
|
||||
}
|
||||
|
||||
void game_list_frame::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
QDockWidget::closeEvent(event);
|
||||
|
|
|
@ -77,6 +77,7 @@ public Q_SLOTS:
|
|||
void SetShowCompatibilityInGrid(bool show);
|
||||
void SetShowCustomIcons(bool show);
|
||||
void SetPlayHoverGifs(bool play);
|
||||
void FocusAndSelectFirstEntryIfNoneIs();
|
||||
|
||||
private Q_SLOTS:
|
||||
void OnRefreshFinished();
|
||||
|
|
|
@ -276,6 +276,9 @@ bool main_window::Init([[maybe_unused]] bool with_cli_boot)
|
|||
// Disable vsh if not present.
|
||||
ui->bootVSHAct->setEnabled(fs::is_file(g_cfg_vfs.get_dev_flash() + "vsh/module/vsh.self"));
|
||||
|
||||
// Focus to search bar by default
|
||||
ui->mw_searchbar->setFocus();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2784,6 +2787,7 @@ void main_window::CreateConnects()
|
|||
});
|
||||
|
||||
connect(ui->mw_searchbar, &QLineEdit::textChanged, m_game_list_frame, &game_list_frame::SetSearchText);
|
||||
connect(ui->mw_searchbar, &QLineEdit::returnPressed, m_game_list_frame, &game_list_frame::FocusAndSelectFirstEntryIfNoneIs);
|
||||
}
|
||||
|
||||
void main_window::CreateDockWindows()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue