This commit is contained in:
Roberto Alsina 2020-02-06 18:42:03 -03:00
parent eb17909563
commit 30860034f5
1 changed files with 3 additions and 2 deletions

View File

@ -76,15 +76,16 @@ class MonitorItem(QGraphicsRectItem, QObject):
current_pos = event.screenPos()
new_pos = view.mapFromScene(self.orig_pos) + current_pos - click_pos
new_pos = view.mapToScene(new_pos)
delta = view.mapToScene(0, 20).y()
if not event.modifiers() & Qt.AltModifier:
# Check for snaps
x = new_pos.x()
delta_x = min((abs(x - sx), i) for i, sx in enumerate(snaps_x))
if delta_x[0] < 50: # snap
if delta_x[0] < delta: # snap
new_pos.setX(int(snaps_x[delta_x[1]]))
y = new_pos.y()
delta_y = min((abs(y - sy), i) for i, sy in enumerate(snaps_y))
if delta_y[0] < 50: # snap
if delta_y[0] < delta: # snap
new_pos.setY(int(snaps_y[delta_y[1]]))
self.setPos(new_pos)
self.window.show_pos(int(self.pos().x()), int(self.pos().y()))