Merge pull request #157 from jaewchoi/fix

fix a minor cursor restore bug
This commit is contained in:
darrenl 2017-09-05 21:09:59 +08:00 committed by GitHub
commit 429290c799

View File

@ -99,8 +99,6 @@ class Canvas(QWidget):
"""Update line with last point and current coordinates."""
pos = self.transformPos(ev.pos())
self.restoreCursor()
# Polygon drawing.
if self.drawing():
self.overrideCursor(CURSOR_DRAW)
@ -184,6 +182,7 @@ class Canvas(QWidget):
self.hShape.highlightClear()
self.update()
self.hVertex, self.hShape = None, None
self.overrideCursor(CURSOR_DEFAULT)
def mousePressEvent(self, ev):
pos = self.transformPos(ev.pos())
@ -210,7 +209,10 @@ class Canvas(QWidget):
self.selectedShapeCopy = None
self.repaint()
elif ev.button() == Qt.LeftButton and self.selectedShape:
self.overrideCursor(CURSOR_GRAB)
if self.selectedVertex():
self.overrideCursor(CURSOR_POINT)
else:
self.overrideCursor(CURSOR_GRAB)
elif ev.button() == Qt.LeftButton:
pos = self.transformPos(ev.pos())
if self.drawing():
@ -640,10 +642,18 @@ class Canvas(QWidget):
self.visible[shape] = value
self.repaint()
def currentCursor(self):
cursor = QApplication.overrideCursor()
if cursor is not None:
cursor = cursor.shape()
return cursor
def overrideCursor(self, cursor):
self.restoreCursor()
self._cursor = cursor
QApplication.setOverrideCursor(cursor)
if self.currentCursor() is None:
QApplication.setOverrideCursor(cursor)
else:
QApplication.changeOverrideCursor(cursor)
def restoreCursor(self):
QApplication.restoreOverrideCursor()