Deselect currently selected item if user clicks outside the list

Signed-off-by: crueter <crueter@eden-emu.dev>
This commit is contained in:
crueter 2026-02-06 19:33:19 -05:00
parent ec8f3b6964
commit 1de431f915
No known key found for this signature in database
GPG Key ID: 425ACD2D4830EBC6
1 changed files with 11 additions and 0 deletions

View File

@ -1277,6 +1277,17 @@ bool GameList::eventFilter(QObject* obj, QEvent* event) {
return true;
}
if (obj == m_currentView->viewport() && event->type() == QEvent::MouseButtonPress) {
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
// if the user clicks outside of the list, deselect the current item.
QModelIndex index = m_currentView->indexAt(mouseEvent->pos());
if (!index.isValid()) {
m_currentView->selectionModel()->clearSelection();
m_currentView->setCurrentIndex(QModelIndex());
}
}
return QWidget::eventFilter(obj, event);
}