This commit is contained in:
Roberto Alsina 2020-02-07 09:55:02 -03:00
parent 30860034f5
commit 7d294ea15a
2 changed files with 5 additions and 3 deletions

View File

@ -3,7 +3,7 @@ import shlex
import subprocess import subprocess
import sys import sys
from PySide2.QtCore import QFile, QObject from PySide2.QtCore import QFile, QObject, QTimer
from PySide2.QtUiTools import QUiLoader from PySide2.QtUiTools import QUiLoader
from PySide2.QtWidgets import QApplication, QGraphicsScene, QLabel from PySide2.QtWidgets import QApplication, QGraphicsScene, QLabel
@ -230,7 +230,8 @@ class Window(QObject):
self.screen.update_replica_of() self.screen.update_replica_of()
for mon in self.screen.monitors.values(): for mon in self.screen.monitors.values():
mon.item.update_visuals(mon) mon.item.update_visuals(mon)
self.adjust_view() # Adjust view a little later
QTimer.singleShot(0, self.adjust_view)
def possible_snaps(self, name): def possible_snaps(self, name):
"""Return two lists of values to which the x and y position """Return two lists of values to which the x and y position
@ -251,6 +252,7 @@ class Window(QObject):
return snaps_x, snaps_y return snaps_x, snaps_y
def adjust_view(self): def adjust_view(self):
print("Adjusting view")
self.ui.sceneView.resetTransform() self.ui.sceneView.resetTransform()
self.ui.sceneView.ensureVisible(self.scene.sceneRect(), 100, 100) self.ui.sceneView.ensureVisible(self.scene.sceneRect(), 100, 100)
try: try:

View File

@ -66,8 +66,8 @@ class MonitorItem(QGraphicsRectItem, QObject):
def mouseReleaseEvent(self, event): def mouseReleaseEvent(self, event):
self.setCursor(Qt.OpenHandCursor) self.setCursor(Qt.OpenHandCursor)
self.window.monitor_moved()
self.window.pos_label.hide() self.window.pos_label.hide()
self.window.monitor_moved()
def mouseMoveEvent(self, event): def mouseMoveEvent(self, event):
snaps_x, snaps_y = self.window.possible_snaps(self.name) snaps_x, snaps_y = self.window.possible_snaps(self.name)