]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Merge branch 'release/22.04'
authorFelix Ernst <fe.a.ernst@gmail.com>
Mon, 4 Apr 2022 12:42:02 +0000 (14:42 +0200)
committerFelix Ernst <fe.a.ernst@gmail.com>
Mon, 4 Apr 2022 12:42:02 +0000 (14:42 +0200)
1  2 
src/kitemviews/kitemlistcontroller.cpp

index 02b0ccfebda174527325854c2ab1b1f902e7d8b3,7ef37481d49d65c8994ba67691bbabfb40a3fe0c..ba4047dbe8c85661f50ec3a7e311b451f06872c2
  #include "kitemlistview.h"
  #include "private/kitemlistkeyboardsearchmanager.h"
  #include "private/kitemlistrubberband.h"
 -#include "private/ktwofingerswipe.h"
 -#include "private/ktwofingertap.h"
  #include "views/draganddrophelper.h"
  
 +#include <KTwoFingerSwipe>
 +#include <KTwoFingerTap>
 +
  #include <QAccessible>
  #include <QApplication>
  #include <QDrag>
@@@ -1601,9 -1600,20 +1601,20 @@@ bool KItemListController::onPress(cons
  
          case MultiSelection:
              if (controlPressed && !shiftPressed) {
-                 m_selectionManager->setSelected(m_pressedIndex.value(), 1, KItemListSelectionManager::Toggle);
-                 m_selectionManager->beginAnchoredSelection(m_pressedIndex.value());
-                 createRubberBand = false; // multi selection, don't propagate any further
+                 // A 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.
+                 const auto row = m_view->m_visibleItems.value(m_pressedIndex.value());
+                 const auto mappedPos = row->mapFromItem(m_view, pos);
+                 if (!row->iconRect().contains(mappedPos) && !row->textRect().contains(mappedPos) && !pressedItemAlreadySelected) {
+                     createRubberBand = true;
+                 } else {
+                     m_selectionManager->setSelected(m_pressedIndex.value(), 1, KItemListSelectionManager::Toggle);
+                     m_selectionManager->beginAnchoredSelection(m_pressedIndex.value());
+                     createRubberBand = false; // multi selection, don't propagate any further
+                     // This will be the start of an item drag-to-copy operation if the user now moves the mouse before releasing the mouse button.
+                 }
              } else if (!shiftPressed || !m_selectionManager->isAnchoredSelectionActive()) {
                  // Select the pressed item and start a new anchored selection
                  m_selectionManager->setSelected(m_pressedIndex.value(), 1, KItemListSelectionManager::Select);