From 266d0088049ce25c5df4bd9c34370f2a03d69c4a Mon Sep 17 00:00:00 2001 From: Razin Shaikh Date: Thu, 18 Jul 2024 12:21:23 -0300 Subject: [PATCH 1/3] don't move the view when moving nodes with ctrl --- zxlive/graphview.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zxlive/graphview.py b/zxlive/graphview.py index 1fbb7a5..637f96f 100644 --- a/zxlive/graphview.py +++ b/zxlive/graphview.py @@ -150,7 +150,6 @@ def mousePressEvent(self, e: QMouseEvent) -> None: e.ignore() def keyPressEvent(self, e: QKeyEvent) -> None: - super().keyPressEvent(e) if Qt.KeyboardModifier.ControlModifier & e.modifiers(): g = self.graph_scene.g for v in self.graph_scene.selected_vertices: @@ -166,6 +165,8 @@ def keyPressEvent(self, e: QKeyEvent) -> None: elif e.key() == Qt.Key.Key_Right: g.set_position(v,y,x+0.5) vitem.set_pos_from_graph() + else: + super().keyPressEvent(e) def mouseMoveEvent(self, e: QMouseEvent) -> None: super().mouseMoveEvent(e) From 76835c79acafe3b4eb72a83c22e461c360614d9c Mon Sep 17 00:00:00 2001 From: Razin Shaikh Date: Thu, 18 Jul 2024 12:21:51 -0300 Subject: [PATCH 2/3] ctrl + arrow should move nodes equal to the snap granularity --- zxlive/graphview.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/zxlive/graphview.py b/zxlive/graphview.py index 637f96f..64ffb3a 100644 --- a/zxlive/graphview.py +++ b/zxlive/graphview.py @@ -152,18 +152,19 @@ def mousePressEvent(self, e: QMouseEvent) -> None: def keyPressEvent(self, e: QKeyEvent) -> None: if Qt.KeyboardModifier.ControlModifier & e.modifiers(): g = self.graph_scene.g + distance = 1 / get_settings_value("snap-granularity", int) for v in self.graph_scene.selected_vertices: vitem = self.graph_scene.vertex_map[v] x = g.row(v) y = g.qubit(v) if e.key() == Qt.Key.Key_Up: - g.set_position(v,y-0.5,x) + g.set_position(v, y - distance, x) elif e.key() == Qt.Key.Key_Down: - g.set_position(v,y+0.5,x) + g.set_position(v, y + distance, x) elif e.key() == Qt.Key.Key_Left: - g.set_position(v,y,x-0.5) + g.set_position(v, y, x - distance) elif e.key() == Qt.Key.Key_Right: - g.set_position(v,y,x+0.5) + g.set_position(v, y, x + distance) vitem.set_pos_from_graph() else: super().keyPressEvent(e) From db51226f533a50f6a2c6589de46f8a1f2cd4c869 Mon Sep 17 00:00:00 2001 From: Razin Shaikh Date: Thu, 18 Jul 2024 13:26:31 -0300 Subject: [PATCH 3/3] ctrl-arrow is a large step, ctrl-shift-arrow is a small step --- zxlive/graphview.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/zxlive/graphview.py b/zxlive/graphview.py index 64ffb3a..5d0541a 100644 --- a/zxlive/graphview.py +++ b/zxlive/graphview.py @@ -152,7 +152,10 @@ def mousePressEvent(self, e: QMouseEvent) -> None: def keyPressEvent(self, e: QKeyEvent) -> None: if Qt.KeyboardModifier.ControlModifier & e.modifiers(): g = self.graph_scene.g - distance = 1 / get_settings_value("snap-granularity", int) + if Qt.KeyboardModifier.ShiftModifier & e.modifiers(): + distance = 1 / get_settings_value("snap-granularity", int) + else: + distance = 0.5 for v in self.graph_scene.selected_vertices: vitem = self.graph_scene.vertex_map[v] x = g.row(v)