┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/kitemlistcontainer.cpp
diff options
context:
space:
mode:
authorFelix Ernst <[email protected]>2023-11-13 17:50:24 +0100
committerFelix Ernst <[email protected]>2023-11-18 10:49:11 +0000
commit046749b073422646b5ee7f5cbc1646519e471698 (patch)
tree045bafd2e29f6980c931e08880d8c95b0a0ff7dc /src/kitemviews/kitemlistcontainer.cpp
parentafc47abcb8c143674ba7148cee358c02f4b0fd7a (diff)
Make main view react to context menu events
Before this commit, Dolphin's main view would not react to any context menu events. It only showed context menus based on hard-coded mouse or keyboard events i.e. mouse right-click and presses of the "Menu" key. This commit removes those hard-coded reactions and instead makes it so the view shows a context menu whenever a QContextMenuEvent is received. Therefore, a context menu will now be opened when any platform- or system-specific context menu triggers are invoked e.g. the Shift+F10 keyboard shortcut. Aside from this, the only side-effect is a partial removal of an unrelated bug: Previously, the hover highlight on items was never cleared when the header column in details view mode was hovered. With this commit, the hover is now correctly cleared most of the time.
Diffstat (limited to 'src/kitemviews/kitemlistcontainer.cpp')
-rw-r--r--src/kitemviews/kitemlistcontainer.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/kitemviews/kitemlistcontainer.cpp b/src/kitemviews/kitemlistcontainer.cpp
index f89a6c8ce..1cac8f7a6 100644
--- a/src/kitemviews/kitemlistcontainer.cpp
+++ b/src/kitemviews/kitemlistcontainer.cpp
@@ -138,6 +138,21 @@ void KItemListContainer::keyPressEvent(QKeyEvent *event)
}
}
+void KItemListContainer::contextMenuEvent(QContextMenuEvent *event)
+{
+ // Note copied from the keyPressEvent() method above because the same reasons probably also apply here.
+ // TODO: We should find a better way to handle the context menu events in the view.
+ // The reasons why we need this hack are:
+ // 1. Without reimplementing contextMenuEvent() here, the event would not reach the QGraphicsView.
+ // 2. By default, the KItemListView does not have the keyboard focus in the QGraphicsScene, so
+ // simply sending the event to the QGraphicsView which is the KItemListContainer's viewport
+ // does not work.
+ KItemListView *view = m_controller->view();
+ if (view) {
+ QApplication::sendEvent(view, event);
+ }
+}
+
void KItemListContainer::showEvent(QShowEvent *event)
{
QAbstractScrollArea::showEvent(event);