┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKai Uwe Broulik <[email protected]>2021-01-06 20:16:31 +0100
committerKai Uwe Broulik <[email protected]>2021-01-10 10:50:41 +0100
commiteb4b0fb48050ab047eecf01ccabc595a8b34d141 (patch)
treebc2f895728df149981e9c5d6281b0f8fa2532cc6 /src
parent6dd67f6f634c2995479a048ef40f9960b10c40dc (diff)
Emit "itemMiddleClicked" when Ctrl-clicking a view in single selection mode
When Ctrl can't cause a change in selection, so instead emit `itemMiddleClicked`. This way one can Ctrl-click a Place or folder in Folders panel to open it in a new tab, similar to what web browsers.
Diffstat (limited to 'src')
-rw-r--r--src/kitemviews/kitemlistcontroller.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp
index 5c9a2bbdd..8687872ee 100644
--- a/src/kitemviews/kitemlistcontroller.cpp
+++ b/src/kitemviews/kitemlistcontroller.cpp
@@ -1550,8 +1550,9 @@ bool KItemListController::onRelease(const QPointF& pos, const Qt::KeyboardModifi
return true;
}
+ const bool controlPressed = modifiers & Qt::ControlModifier;
const bool shiftOrControlPressed = modifiers & Qt::ShiftModifier ||
- modifiers & Qt::ControlModifier;
+ controlPressed;
KItemListRubberBand* rubberBand = m_view->rubberBand();
if (rubberBand->isActive()) {
@@ -1585,6 +1586,11 @@ bool KItemListController::onRelease(const QPointF& pos, const Qt::KeyboardModifi
} else if (shiftOrControlPressed) {
// The mouse click should only update the selection, not trigger the item
emitItemActivated = false;
+ // When Ctrl-clicking an item when in single selection mode
+ // i.e. where Ctrl won't change the selection, pretend it was middle clicked
+ if (controlPressed && m_selectionBehavior == SingleSelection) {
+ Q_EMIT itemMiddleClicked(index);
+ }
} else if (!(m_view->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) || m_singleClickActivationEnforced)) {
if (touch) {
emitItemActivated = true;