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

Fix toggling current item selection #2867

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
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
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
Loading