Skip to content

Commit

Permalink
Fix toggling current item selection
Browse files Browse the repository at this point in the history
Fixes #2850
  • Loading branch information
hluk committed Oct 21, 2024
1 parent ec3c2b7 commit 0fd9602
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/gui/clipboardbrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1390,6 +1390,16 @@ void ClipboardBrowser::keyPressEvent(QKeyEvent *event)

const int key = event->key();

// WORKAROUND: Avoid triggering search with Ctrl+Space toggle selection action.
if (mods.testFlag(Qt::ControlModifier) && key == Qt::Key_Space) {
const QModelIndex current = currentIndex();
if (!edit(current, AnyKeyPressed, event)) {
selectionModel()->select(current, selectionCommand(current, event));
event->accept();
return;
}
}

// This fixes few issues with default navigation and item selections.
switch (key) {
case Qt::Key_Up:
Expand Down
11 changes: 11 additions & 0 deletions src/tests/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2606,6 +2606,17 @@ void Tests::selectItems()

RUN("keys" << "CTRL+A", "");
RUN("testSelected", tab + " 1 0 1 2\n");

// CTRL+SPACE toggles current item selection
RUN("add" << "D", "");
RUN("keys" << "PGUP" << "CTRL+SHIFT+DOWN" << "CTRL+SHIFT+DOWN", "");
RUN("testSelected", tab + " 2 0\n");
RUN("keys" << "CTRL+SPACE", "");
RUN("testSelected", tab + " 2 0 2\n");
RUN("keys" << "SHIFT+DOWN", "");
RUN("testSelected", tab + " 3 0 2 3\n");
RUN("keys" << "CTRL+SPACE", "");
RUN("testSelected", tab + " 3 0 2\n");
}

void Tests::moveItems()
Expand Down

0 comments on commit 0fd9602

Please sign in to comment.