Skip to content

Commit

Permalink
Implements #267
Browse files Browse the repository at this point in the history
  • Loading branch information
jvdwetering committed Jul 17, 2024
1 parent 8c1bb14 commit bdc69bc
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion zxlive/graphview.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
import random
from PySide6.QtCore import QRect, QSize, QPointF, Signal, Qt, QRectF, QLineF, QObject, QTimerEvent
from PySide6.QtWidgets import QGraphicsView, QGraphicsPathItem, QRubberBand, QGraphicsEllipseItem, QGraphicsItem, QLabel
from PySide6.QtGui import QPen, QColor, QPainter, QPainterPath, QTransform, QMouseEvent, QWheelEvent, QBrush, QShortcut, QKeySequence
from PySide6.QtGui import (QPen, QColor, QPainter, QPainterPath, QTransform,
QMouseEvent, QWheelEvent, QBrush, QShortcut, QKeySequence,
QKeyEvent)

from dataclasses import dataclass

Expand Down Expand Up @@ -139,6 +141,24 @@ def mousePressEvent(self, e: QMouseEvent) -> None:
else:
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:
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)
elif e.key() == Qt.Key.Key_Down:
g.set_position(v,y+0.5,x)
elif e.key() == Qt.Key.Key_Left:
g.set_position(v,y,x-0.5)
elif e.key() == Qt.Key.Key_Right:
g.set_position(v,y,x+0.5)
vitem.set_pos_from_graph()

def mouseMoveEvent(self, e: QMouseEvent) -> None:
super().mouseMoveEvent(e)
if self.tool == GraphTool.Selection:
Expand Down

0 comments on commit bdc69bc

Please sign in to comment.