Skip to content

Commit

Permalink
Merge pull request #4237 from ronso0/sidebar-pageup
Browse files Browse the repository at this point in the history
Library sidebar: also activate items on PageUp/Down events
  • Loading branch information
daschuer authored Aug 30, 2021
2 parents 0b72fc6 + 7a6be47 commit e215bd7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/widget/wlibrarysidebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,18 @@ void WLibrarySidebar::keyPressEvent(QKeyEvent* event) {
if (event->key() == Qt::Key_Return) {
toggleSelectedItem();
return;
} else if (event->key() == Qt::Key_Down || event->key() == Qt::Key_Up) {
} else if (event->key() == Qt::Key_Down ||
event->key() == Qt::Key_Up ||
event->key() == Qt::Key_PageDown ||
event->key() == Qt::Key_PageUp ||
event->key() == Qt::Key_End ||
event->key() == Qt::Key_Home) {
// Let the tree view move up and down for us.
QTreeView::keyPressEvent(event);

// But force the index to be activated/clicked after the selection
// changes. (Saves you from having to push "enter" after changing the
// selection.)
QModelIndexList selectedIndices = this->selectionModel()->selectedRows();

QModelIndexList selectedIndices = selectionModel()->selectedRows();
//Note: have to get the selected indices _after_ QTreeView::keyPressEvent()
if (selectedIndices.size() > 0) {
QModelIndex index = selectedIndices.at(0);
Expand Down

0 comments on commit e215bd7

Please sign in to comment.