From 44c82a16b3e2fc2d40601fd70f8253dce40dda86 Mon Sep 17 00:00:00 2001 From: Felix Ernst Date: Mon, 2 Jan 2023 16:01:49 +0100 Subject: Make space shortcut for selection mode view-local instead of global Before this commit, the "Space" keyboard shortcut was bound to triggering selection mode by default. After this commit, pressing "Space" will only trigger selection mode when the file view area has keyboard focus. Pros: + Other buttons in the UI can be triggered with Space once again just like it is expected from an accessibility point of view. + "Type-ahead" searching works once more when typing the space char for file names containing such a space char. Cons: - "Space" can no longer be used to add the currently underlined item to the selection. Instead "Ctrl+Space" needs to be used. (However, this is the current status anyway unless a user has manually unbound "Space" as a shortcut from Selection Mode.) - The Selection Mode action will no longer show "Space" as its shortcut in menus. Overall, I see solutions to all of these problems, but they seem over-engineered for the issues they are trying to solve, so I believe this somewhat small commit is the best solution for now. BUG: 458282 BUG: 458281 CCBUG: 463048 FIXED-IN: 23.04 --- src/kitemviews/kitemlistcontroller.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/kitemviews/kitemlistcontroller.cpp') diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp index 955e418e8..29a5bd87a 100644 --- a/src/kitemviews/kitemlistcontroller.cpp +++ b/src/kitemviews/kitemlistcontroller.cpp @@ -436,13 +436,10 @@ bool KItemListController::keyPressEvent(QKeyEvent* event) m_selectionManager->setSelected(index, 1, KItemListSelectionManager::Toggle); m_selectionManager->beginAnchoredSelection(index); break; - } else { - // Select the current item if it is not selected yet. - const int current = m_selectionManager->currentItem(); - if (!m_selectionManager->isSelected(current)) { - m_selectionManager->setSelected(current); - break; - } + } else if (m_keyboardManager->addKeyBeginsNewSearch()) { // File names shouldn't start with a space, + // so we can use this press as a keyboard shortcut instead. + Q_EMIT selectionModeChangeRequested(!m_selectionMode); + break; } } Q_FALLTHROUGH(); // fall through to the default case and add the Space to the current search string. -- cgit v1.3