From 0a40ab55cbce371b3fd245d9c2f7399dc0d33ad2 Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Thu, 20 Jul 2023 08:11:20 +0200 Subject: [PATCH] Add menu even to networks --- birdvisu/graphics_items.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/birdvisu/graphics_items.py b/birdvisu/graphics_items.py index c148c78..4db3e5a 100644 --- a/birdvisu/graphics_items.py +++ b/birdvisu/graphics_items.py @@ -151,6 +151,21 @@ class NetworkGraphicsItem(QGraphicsItem): self.window.graphicsitems[edge].update_line() super().mouseMoveEvent(evt) + def contextMenuEvent(self, evt): + menu = QMenu(self.window) + tree_act = QAction('Show routing tree', self.window) + menu.addAction(tree_act) + path_act = object() + if self.window.mode == self.window.Mode.ShortestPathDAG: + path_act = QAction('Show path to here', self.window) + menu.addAction(path_act) + + action = menu.exec(evt.screenPos()) + if action == tree_act: + self.window.dagMode(self.vertex_id) + if action == path_act: + self.window.shortestPathMode(self.vertex_id) + # Admit we are basically only a wrapper of the icon. def boundingRect(self): return self.icon.boundingRect()