diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2020-02-09 02:55:12 -0500 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2020-02-18 17:23:47 -0500 |
| commit | 177dc6b320481cfb382f4c74ff089bdc5b7750e0 (patch) | |
| tree | cbefc56053b267727a9e06932e56429bd3625591 | |
| parent | 7eae9b5dd4ea13029ff81630ac7a5307a70eab58 (diff) | |
shift+right-click selects items
| -rw-r--r-- | src/filetree.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
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)) { |
