Skip to content

Commit

Permalink
Merge pull request #336 from zxcalc/improve-ctrl-arrow
Browse files Browse the repository at this point in the history
Improve ctrl arrow
  • Loading branch information
RazinShaikh authored Jul 18, 2024
2 parents 880b553 + db51226 commit ec45b4f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions zxlive/graphview.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,22 +150,27 @@ 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
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)
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)

def mouseMoveEvent(self, e: QMouseEvent) -> None:
super().mouseMoveEvent(e)
Expand Down

0 comments on commit ec45b4f

Please sign in to comment.