Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] view: Fix a type error with PyQt6 #285

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions orangecanvas/canvas/tests/test_view.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from AnyQt.QtCore import QPointF, QRect

from orangecanvas.gui.test import QAppTestCase
from orangecanvas.canvas import view, scene


class TestView(QAppTestCase):
def setUp(self):
super().setUp()
self.scene = scene.CanvasScene()
self.view = view.CanvasView(self.scene)
self.view.resize(420, 420)
self.scene.setSceneRect(0, 0, 400, 400)

def tearDown(self):
self.scene.clear()
del self.view
del self.scene
super().tearDown()

def test_view_pinch_zoom(self):
# Missing QTest.touchEvent in PyQt; cannot properly simulate touch
# events so test this the ugly way.
anchor = QPointF(350, 350)
self.view._CanvasView__setZoomLevel(5.0, anchor)
mapped = self.view.mapFromScene(anchor)
self.assertTrue(self.view.viewport().rect().contains(mapped))
2 changes: 1 addition & 1 deletion orangecanvas/canvas/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def __setZoomLevel(self, scale, anchor=None):
if anchor is not None:
center = self.viewport().rect().center()
diff = self.mapToScene(center) - self.mapToScene(anchor)
self.centerOn(anchor + diff)
self.centerOn(QPointF(anchor) + diff)
self.zoomLevelChanged.emit(scale)

zoomLevelChanged = Signal(float)
Expand Down