From 6c91dfa47ee703b2fbf2f7ad3e0bec6f32a6d5e8 Mon Sep 17 00:00:00 2001 From: Felix Ernst Date: Wed, 20 Apr 2022 21:44:05 +0000 Subject: [PATCH] Don't deselect on Ctrl+Right-Click (Part of my work towards !273) Currently, when items are selected and a user right-clicks a selected item while having the Ctrl key pressed down, the item is first deselected and then a context menu is opened that doesn't involve the item that was just deselected. This is slightly confusing because normally one right-clicks an item to see its context menu. Right-click being able to deselect an item seems like unintended functionality in the first place but in this scenario it also means that the intended opening of a context menu for the pressed item doesn't even happen. There is a good chance that nobody is even aware of this behaviour because the normal way to deselect an item would be to Ctrl+Left-Click if anything. Why would someone choose to open a context menu and deselect items in a single step? Why would they have selected an item they don't want to open a context menu for in the first place? Because of a discussion in this merge request deselecting on Ctrl+Middle-Click was also removed for consistency with Ctrl+Right-Click and Ctrl+Shift+Middle-Click. This commit also makes a later implementation of a selection mode more straightforward. --- src/kitemviews/kitemlistcontroller.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp index ba4047dbe..994812b1f 100644 --- a/src/kitemviews/kitemlistcontroller.cpp +++ b/src/kitemviews/kitemlistcontroller.cpp @@ -1497,6 +1497,7 @@ bool KItemListController::onPress(const QPoint& screenPos, const QPointF& pos, c const bool shiftPressed = modifiers & Qt::ShiftModifier; const bool controlPressed = modifiers & Qt::ControlModifier; + const bool leftClick = buttons & Qt::LeftButton; const bool rightClick = buttons & Qt::RightButton; // The previous selection is cleared if either @@ -1600,8 +1601,8 @@ bool KItemListController::onPress(const QPoint& screenPos, const QPointF& pos, c break; case MultiSelection: - if (controlPressed && !shiftPressed) { - // A mouse button press is happening on an item while control is pressed. This either means a user wants to: + if (controlPressed && !shiftPressed && leftClick) { + // A left mouse button press is happening on an item while control is pressed. This either means a user wants to: // - toggle the selection of item(s) or // - they want to begin a drag on the item(s) to copy them. // We rule out the latter, if the item is not clicked directly and was unselected previously. -- 2.47.3