547 Protected method to handle mouse button release events. |
547 Protected method to handle mouse button release events. |
548 |
548 |
549 @param evt reference to the mouse event object (QMouseEvent) |
549 @param evt reference to the mouse event object (QMouseEvent) |
550 """ |
550 """ |
551 if evt.button() == Qt.MouseButton.LeftButton: |
551 if evt.button() == Qt.MouseButton.LeftButton: |
552 if self.__curTool in [self.Pencil, self.Rubber]: |
552 if ( |
553 if self.__currentUndoCmd: |
553 self.__curTool in [self.Pencil, self.Rubber] and |
554 self.__currentUndoCmd.setAfterImage(self.__image) |
554 self.__currentUndoCmd |
555 self.__currentUndoCmd = None |
555 ): |
|
556 self.__currentUndoCmd.setAfterImage(self.__image) |
|
557 self.__currentUndoCmd = None |
556 |
558 |
557 if self.__curTool not in [self.Pencil, self.Rubber, |
559 if self.__curTool not in [self.Pencil, self.Rubber, |
558 self.Fill, self.ColorPicker, |
560 self.Fill, self.ColorPicker, |
559 self.RectangleSelection, |
561 self.RectangleSelection, |
560 self.CircleSelection]: |
562 self.CircleSelection]: |
855 |
857 |
856 img = QImage(self.__selRect.size(), QImage.Format.Format_ARGB32) |
858 img = QImage(self.__selRect.size(), QImage.Format.Format_ARGB32) |
857 img.fill(qRgba(0, 0, 0, 0)) |
859 img.fill(qRgba(0, 0, 0, 0)) |
858 for i in range(0, self.__selRect.width()): |
860 for i in range(0, self.__selRect.width()): |
859 for j in range(0, self.__selRect.height()): |
861 for j in range(0, self.__selRect.height()): |
860 if self.__image.rect().contains(self.__selRect.x() + i, |
862 if ( |
861 self.__selRect.y() + j): |
863 self.__image.rect().contains( |
862 if self.__isMarked( |
864 self.__selRect.x() + i, self.__selRect.y() + j) and |
863 self.__selRect.x() + i, self.__selRect.y() + j): |
865 self.__isMarked(self.__selRect.x() + i, |
864 img.setPixel(i, j, self.__image.pixel( |
866 self.__selRect.y() + j) |
865 self.__selRect.x() + i, self.__selRect.y() + j)) |
867 ): |
866 if cut: |
868 img.setPixel(i, j, self.__image.pixel( |
867 self.__image.setPixel(self.__selRect.x() + i, |
869 self.__selRect.x() + i, self.__selRect.y() + j)) |
868 self.__selRect.y() + j, |
870 if cut: |
869 qRgba(0, 0, 0, 0)) |
871 self.__image.setPixel(self.__selRect.x() + i, |
|
872 self.__selRect.y() + j, |
|
873 qRgba(0, 0, 0, 0)) |
870 |
874 |
871 if cut: |
875 if cut: |
872 self.__undoStack.push(cmd) |
876 self.__undoStack.push(cmd) |
873 cmd.setAfterImage(self.__image) |
877 cmd.setAfterImage(self.__image) |
874 |
878 |