Skip to content

Commit

Permalink
WLibraryTableView: on FocusIn, select the first item if there is no p…
Browse files Browse the repository at this point in the history
…revious selection (focused item)
  • Loading branch information
ronso0 committed Aug 31, 2020
1 parent 62eff5e commit de62420
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/widget/wlibrarytableview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,18 @@ void WLibraryTableView::setSelectedClick(bool enable) {
setEditTriggers(QAbstractItemView::EditKeyPressed);
}
}

bool WLibraryTableView::event(QEvent* e) {
// On FocusIn, with no focused item, select the first track which can then
// instantly be loaded to a deck.
// This is especially helpful if the table has only one track, which can not
// be selected with up/down buttons, either physical or emulated via
// [Library],MoveVertical controls. See lp:1808632
if (e->type() == QEvent::FocusIn &&
model()->rowCount() > 0 &&
currentIndex().row() == -1) {
selectRow(0);
}

return QTableView::event(e);
}
1 change: 1 addition & 0 deletions src/widget/wlibrarytableview.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class WLibraryTableView : public QTableView, public virtual LibraryView {
private:
void loadVScrollBarPosState();
void saveVScrollBarPosState();
bool event(QEvent* e);

const UserSettingsPointer m_pConfig;
const ConfigKey m_vScrollBarPosKey;
Expand Down

0 comments on commit de62420

Please sign in to comment.