From 177dc6b320481cfb382f4c74ff089bdc5b7750e0 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Sun, 9 Feb 2020 02:55:12 -0500 Subject: shift+right-click selects items --- src/filetree.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/filetree.cpp') diff --git a/src/filetree.cpp b/src/filetree.cpp index 2f13db44..95d4da2a 100644 --- a/src/filetree.cpp +++ b/src/filetree.cpp @@ -522,6 +522,21 @@ void FileTree::onContextMenu(const QPoint &pos) const auto m = QApplication::keyboardModifiers(); if (m & Qt::ShiftModifier) { + // shift+right-click won't select individual items because it interferes + // with regular shift selection; this makes it behave like explorer: + // - if the right-clicked item is currently part of the selection, show + // the menu for the selection + // - if not, select this item only and show the menu for it + const auto index = m_tree->indexAt(pos); + + if (!m_tree->selectionModel()->isSelected(index)) { + m_tree->selectionModel()->select( + index, + QItemSelectionModel::ClearAndSelect | + QItemSelectionModel::Rows | + QItemSelectionModel::Current); + } + // if no shell menu was available, continue on and show the regular // context menu if (showShellMenu(pos)) { -- cgit v1.3.1