X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/e321a9cc3e8da6a63da8d247b2855e69119d0e9d..b2f18e411a929665257dad8c6a51f3e2e617cee5:/src/kitemviews/kitemlistcontroller.cpp diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp index ba4047dbe..4d926474b 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 @@ -1578,6 +1579,7 @@ bool KItemListController::onPress(const QPoint& screenPos, const QPointF& pos, c } if (m_pressedIndex.has_value()) { + // The hover highlight area of an item is being pressed. m_selectionManager->setCurrentItem(m_pressedIndex.value()); const auto row = m_view->m_visibleItems.value(m_pressedIndex.value()); // anything outside of row.contains() will be the empty region of the row rect const bool hitTargetIsRowEmptyRegion = !row->contains(row->mapFromItem(m_view, pos)); @@ -1586,8 +1588,14 @@ bool KItemListController::onPress(const QPoint& screenPos, const QPointF& pos, c bool createRubberBand = (hitTargetIsRowEmptyRegion && m_selectionManager->selectedItems().isEmpty()); if (rightClick && hitTargetIsRowEmptyRegion) { - // we got a right click outside the text rect, default to action on the current url and not the pressed item - Q_EMIT itemContextMenuRequested(m_pressedIndex.value(), screenPos); + // We have a right click outside the icon and text rect but within the hover highlight area + // but it is unclear if this means that a selection rectangle for an item was clicked or the background of the view. + if (m_selectionManager->selectedItems().contains(m_pressedIndex.value())) { + // The selection rectangle for an item was clicked + Q_EMIT itemContextMenuRequested(m_pressedIndex.value(), screenPos); + } else { + Q_EMIT viewContextMenuRequested(screenPos); + } return true; } @@ -1600,8 +1608,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.