From e251e503ae08ed04063bcfbebc1603f10c63ea2f Mon Sep 17 00:00:00 2001 From: Till Frankenbach Date: Thu, 2 Oct 2025 10:51:36 +0200 Subject: [PATCH 1/3] feat: simplify cursor management in LineTool class --- ORStools/utils/maptools.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/ORStools/utils/maptools.py b/ORStools/utils/maptools.py index bd32060f..7348277f 100644 --- a/ORStools/utils/maptools.py +++ b/ORStools/utils/maptools.py @@ -44,9 +44,6 @@ from qgis.PyQt import QtCore from qgis.PyQt.QtCore import Qt, pyqtSignal, QEvent from qgis.PyQt.QtGui import QColor, QMouseEvent -from qgis.PyQt.QtWidgets import ( - QApplication, -) from ORStools import ROUTE_COLOR from ORStools.utils import transform, router @@ -106,10 +103,12 @@ def deactivate(self): # Thus, we only change restore the Cursor once we are not dragging the annotation anymore. def canvasMoveEvent(self, e: QEvent) -> None: hovering = self.check_annotation_hover(e.pos()) - if hovering and not QApplication.overrideCursor() == QtCore.Qt.CursorShape.OpenHandCursor: - QApplication.setOverrideCursor(QtCore.Qt.CursorShape.OpenHandCursor) - elif not hovering and not self.dragging_vertex: - QApplication.restoreOverrideCursor() + if hovering: + self.setCursor(QtCore.Qt.CursorShape.OpenHandCursor) + elif not self.dragging_vertex and self.dlg.isVisible(): + self.setCursor(QtCore.Qt.CursorShape.PointingHandCursor) + elif not self.dragging_vertex: + self.setCursor(QtCore.Qt.CursorShape.CrossCursor) def check_annotation_hover(self, pos: QMouseEvent) -> int: click = [pos.x(), pos.y()] @@ -161,7 +160,7 @@ def canvasPressEvent(self, event: QEvent) -> None: if hovering: # clicking should only change the cursor if it is hovering over an annotation. # The corresponding reset happens in the release event. - QApplication.setOverrideCursor(QtCore.Qt.CursorShape.ClosedHandCursor) + self.setCursor(QtCore.Qt.CursorShape.ClosedHandCursor) if self.dlg.rubber_band: self.dlg.rubber_band.reset() self.move_i = self.dlg.annotations.index(hovering) @@ -172,15 +171,14 @@ def canvasPressEvent(self, event: QEvent) -> None: def canvasReleaseEvent(self, event: QEvent) -> None: if event.button() == Qt.MouseButton.RightButton: - QApplication.restoreOverrideCursor() + self.setCursor(QtCore.Qt.CursorShape.PointingHandCursor) self.dlg.show() return point = self.toMapCoordinates(event.pos()) self.points.append(point) - if self.dragging_vertex: - QApplication.restoreOverrideCursor() + if self.dragging_vertex: self.dragging_vertex = False try: From 9b2f817d03bf68bfcca5adad96d1490bb1e1da87 Mon Sep 17 00:00:00 2001 From: Till Frankenbach Date: Thu, 2 Oct 2025 10:53:03 +0200 Subject: [PATCH 2/3] docs: add to changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 379d593c..93b1387e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,9 @@ RELEASING: - Delete annotations when plugin is uninstalled ([#346](https://github.com/GIScience/orstools-qgis-plugin/issues/346)) - Reset hand cursor after deactivating line tool ([#342](https://github.com/GIScience/orstools-qgis-plugin/issues/342)) +## Added +- Improve cursor behaviour during digitization + ## [2.0.1] - 2025-06-01 ### Added - Readd old icons and add new icons for processing algorithms From 62e82f885430a7b5287ffddc4279107047cc2aa0 Mon Sep 17 00:00:00 2001 From: Till Frankenbach Date: Thu, 2 Oct 2025 10:53:22 +0200 Subject: [PATCH 3/3] style: run ruff --- ORStools/utils/maptools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ORStools/utils/maptools.py b/ORStools/utils/maptools.py index 7348277f..9af4459b 100644 --- a/ORStools/utils/maptools.py +++ b/ORStools/utils/maptools.py @@ -178,7 +178,7 @@ def canvasReleaseEvent(self, event: QEvent) -> None: point = self.toMapCoordinates(event.pos()) self.points.append(point) - if self.dragging_vertex: + if self.dragging_vertex: self.dragging_vertex = False try: