From 91a830e01b40abc5edfa9a1dc6a691cf72e9adf2 Mon Sep 17 00:00:00 2001 From: Jaewoo Choi Date: Tue, 5 Sep 2017 20:36:26 +0900 Subject: [PATCH] fix a minor cursor restore bug --- libs/canvas.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/libs/canvas.py b/libs/canvas.py index 8bbc4220..69df58c5 100644 --- a/libs/canvas.py +++ b/libs/canvas.py @@ -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()