Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library sidebar: also activate items on PageUp/Down events #4237

Merged
merged 1 commit into from
Aug 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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