From: Felix Ernst Date: Fri, 4 Mar 2022 10:41:50 +0000 (+0000) Subject: Always select items on activation X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/cd369a151932e7076c24b01f94c5d6c5fe15ecef Always select items on activation There is an unintended side-effect in d3839617193e92463806580699caa595c892b8a6 which this MR fixes. Normally in Dolphin, when clicking on an item to open/activate it, it is both selected by the click and opened/activated. Prior to this MR, the item wasn't selected when all of these conditions were met: - Use ActivateItemOnSingleClick also knwon as single-click mode - Have more than one item selected already - Click on an item that was previously not selected Prior to this MR, the click would deselect all items and activate the clicked item but not select it. With this MR, the click will deselect all items, activate the clicked item and also select it and move the anchor there. When testing this with folders, make sure to navigate back after activating the folder. The folder should then still be selected. This is then consistent with the behaviour when the specific conditions mentioned above are not met. --- diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp index 80c28f25c..2422e9110 100644 --- a/src/kitemviews/kitemlistcontroller.cpp +++ b/src/kitemviews/kitemlistcontroller.cpp @@ -1521,6 +1521,12 @@ bool KItemListController::onPress(const QPoint& screenPos, const QPointF& pos, c // and short-circuit for single-click activation (it will then propagate to onRelease and activate the item) // or we just keep going for double-click activation if (m_view->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) || m_singleClickActivationEnforced) { + if (!pressedItemAlreadySelected) { + // An unselected item was clicked directly while deselecting multiple other items so we select it. + m_selectionManager->setSelected(m_pressedIndex.value(), 1, KItemListSelectionManager::Toggle); + m_selectionManager->setCurrentItem(m_pressedIndex.value()); + m_selectionManager->beginAnchoredSelection(m_pressedIndex.value()); + } return true; // event handled, don't create rubber band } } else {