Conversation
…(or rounding) before calling QPainter.drawEllipse. Mouse positions can be QPointF, producing float coordinates that do not match the int overload.
|
如需詳細演示,請參閱:#1726 |
2f3cb48 to
ccd96b0
Compare
|
I wanted to briefly explain the current CI status. At the moment, the only failing check is: ci / check (pull_request) In this PR, the only functional changes I made are in canvas.py (related to the drawing/brush functionality). The other CI jobs (builds on macOS, Ubuntu, and Windows) are all passing successfully, so there are no runtime or cross-platform issues. I’ve just updated my branch to be fully in sync with the latest upstream state to avoid any drift. Based on my local testing and the successful build checks, the feature itself should be stable and mature at this point. |
|
Hi, @kancheng thanks for your work! Me and my company would also be very interested in this feature. What is holding it back from being merged? Or do you know why the ci / check job is failing? |
minewilliam
left a comment
There was a problem hiding this comment.
I have not had time to test/review the functionality yet. This is more of my impression of your PR at a glance.
- I think a mistake was made somewhere in a merge with main, 2 months ago. Please review your PR and make sure it does not incur a regression. Ex: type hints were added to the parameters of event handlers.
- You said you did not add translation in this PR, but you have 2 translation files commited?
PS: I apologize for the number of identical comments in my review.
| def keyPressEvent(self, e): | ||
| if e.key() in [QtCore.Qt.Key_Up, QtCore.Qt.Key_Down]: | ||
| self.list_widget.keyPressEvent(e) | ||
| else: | ||
| super().keyPressEvent(a0) | ||
| super().keyPressEvent(e) |
There was a problem hiding this comment.
This file should be reverted.
Source commit: 4d468d7#diff-20a434242a3644257f0c023ee8b47787fb12f85bd0dfeab0e3c059660b076bc3R19
| def keyPressEvent(self, event): | ||
| super().keyPressEvent(event) | ||
| if event.key() == Qt.Key_Escape: |
There was a problem hiding this comment.
This file should be reverted.
Source commit: 4d468d7#diff-7b04d17815ef0375466c70d68d5cccee332fff0cbf5753a866df82b9b5b92700R4
| if stripped_s := s.strip(): | ||
| logger.debug(stripped_s) | ||
| return len(s) | ||
| def write(self, message: str) -> int: |
There was a problem hiding this comment.
This file should be reverted.
Source commit: d05d6fa#diff-c29d43c632d9da4dd3b6284c58535d13128b46307a8231603ecb779763087c5bR24
| description: str | ||
| group_id: int | None | ||
| mask: NDArray[np.bool] | None | ||
| mask: NDArray[np.bool_] | None |
There was a problem hiding this comment.
This file should be reverted.
np.bool_ is an alias for np.bool: The latter being preferable.
dict was replaced by ShapeDict in this commit: 0e15b8c#diff-9e7397e710163a6540ac179927130394d44dfd90e0fcb81af6c8efa9a1b88e18R110
| self._brushSizeSlider.valueChanged.connect( | ||
| lambda value: self._on_brush_size_changed(value) | ||
| ) |
There was a problem hiding this comment.
| self._brushSizeSlider.valueChanged.connect( | |
| lambda value: self._on_brush_size_changed(value) | |
| ) | |
| self._brushSizeSlider.valueChanged.connect(self._on_brush_size_changed) |
| return len(self.current) >= 3 | ||
|
|
||
| def mouseDoubleClickEvent(self, a0: QtGui.QMouseEvent) -> None: | ||
| def mouseDoubleClickEvent(self, ev): |
| def mouseReleaseEvent(self, ev): | ||
| if ev.button() == Qt.RightButton: | ||
| menu = self.menus[len(self.selectedShapesCopy) > 0] | ||
| self.restoreCursor() | ||
| if not menu.exec_(self.mapToGlobal(a0.pos())) and self.selectedShapesCopy: # type: ignore | ||
| if not menu.exec_(self.mapToGlobal(ev.pos())) and self.selectedShapesCopy: | ||
| # Cancel the move by deleting the shadow copy. | ||
| self.selectedShapesCopy = [] | ||
| self.repaint() | ||
| elif a0.button() == Qt.LeftButton: | ||
| elif ev.button() == Qt.LeftButton: |
| def mousePressEvent(self, ev): | ||
| pos: QPointF = self.transformPos(ev.localPos()) | ||
|
|
||
| is_shift_pressed = a0.modifiers() & Qt.ShiftModifier | ||
| is_shift_pressed = ev.modifiers() & Qt.ShiftModifier | ||
|
|
||
| if a0.button() == Qt.LeftButton: | ||
| if ev.button() == Qt.LeftButton: |
| def mouseMoveEvent(self, ev): | ||
| """Update line with last point and current coordinates.""" | ||
| try: | ||
| pos = self.transformPos(a0.localPos()) | ||
| pos = self.transformPos(ev.localPos()) | ||
| except AttributeError: | ||
| return | ||
|
|
||
| self.mouseMoved.emit(pos) | ||
|
|
||
| self.prevMovePoint = pos | ||
|
|
||
| is_shift_pressed = a0.modifiers() & Qt.ShiftModifier | ||
| is_shift_pressed = ev.modifiers() & Qt.ShiftModifier |
| def enterEvent(self, ev): | ||
| self.overrideCursor(self._cursor) | ||
| self._update_status() | ||
|
|
||
| def leaveEvent(self, a0: QtCore.QEvent) -> None: | ||
| def leaveEvent(self, ev): | ||
| self.unHighlight() | ||
| self.restoreCursor() | ||
| self._update_status() | ||
|
|
||
| def focusOutEvent(self, a0: QtGui.QFocusEvent) -> None: | ||
| def focusOutEvent(self, ev): | ||
| self.restoreCursor() | ||
| self._update_status() |

This PR focuses only on the brush drawing tool:
No localization or unrelated changes are included.