eric6/IconEditor/IconEditorGrid.py

branch
maintenance
changeset 8273
698ae46f40a4
parent 8176
31965986ecd1
parent 8269
87f521f359d5
--- a/eric6/IconEditor/IconEditorGrid.py	Fri Apr 02 11:59:41 2021 +0200
+++ b/eric6/IconEditor/IconEditorGrid.py	Sat May 01 14:27:20 2021 +0200
@@ -34,7 +34,7 @@
             (QImage)
         @param parent reference to the parent command (QUndoCommand)
         """
-        super(IconEditCommand, self).__init__(text, parent)
+        super().__init__(text, parent)
         
         self.__grid = grid
         self.__imageBefore = QImage(oldImage)
@@ -91,6 +91,7 @@
     sizeChanged = pyqtSignal(int, int)
     zoomChanged = pyqtSignal(int)
     
+    # convert to Enum
     Pencil = 1
     Rubber = 2
     Line = 3
@@ -103,6 +104,7 @@
     Fill = 10
     ColorPicker = 11
     
+    # convert to Enum
     RectangleSelection = 20
     CircleSelection = 21
     
@@ -121,7 +123,7 @@
         
         @param parent reference to the parent widget (QWidget)
         """
-        super(IconEditorGrid, self).__init__(parent)
+        super().__init__(parent)
         
         self.setAttribute(Qt.WidgetAttribute.WA_StaticContents)
         self.setSizePolicy(QSizePolicy.Policy.Minimum,
@@ -549,10 +551,12 @@
         @param evt reference to the mouse event object (QMouseEvent)
         """
         if evt.button() == Qt.MouseButton.LeftButton:
-            if self.__curTool in [self.Pencil, self.Rubber]:
-                if self.__currentUndoCmd:
-                    self.__currentUndoCmd.setAfterImage(self.__image)
-                    self.__currentUndoCmd = None
+            if (
+                self.__curTool in [self.Pencil, self.Rubber] and
+                self.__currentUndoCmd
+            ):
+                self.__currentUndoCmd.setAfterImage(self.__image)
+                self.__currentUndoCmd = None
             
             if self.__curTool not in [self.Pencil, self.Rubber,
                                       self.Fill, self.ColorPicker,
@@ -611,14 +615,16 @@
         
         x, y = self.__imageCoordinates(pos)
         isize = self.__image.size()
-        if x + self.__clipboardSize.width() <= isize.width():
-            sx = self.__clipboardSize.width()
-        else:
-            sx = isize.width() - x
-        if y + self.__clipboardSize.height() <= isize.height():
-            sy = self.__clipboardSize.height()
-        else:
-            sy = isize.height() - y
+        sx = (
+            self.__clipboardSize.width()
+            if x + self.__clipboardSize.width() <= isize.width() else
+            isize.width() - x
+        )
+        sy = (
+            self.__clipboardSize.height()
+            if y + self.__clipboardSize.height() <= isize.height() else
+            isize.height() - y
+        )
         
         self.__pasteRect = QRect(QPoint(x, y), QSize(sx - 1, sy - 1))
         
@@ -857,16 +863,18 @@
         img.fill(qRgba(0, 0, 0, 0))
         for i in range(0, self.__selRect.width()):
             for j in range(0, self.__selRect.height()):
-                if self.__image.rect().contains(self.__selRect.x() + i,
-                                                self.__selRect.y() + j):
-                    if self.__isMarked(
-                            self.__selRect.x() + i, self.__selRect.y() + j):
-                        img.setPixel(i, j, self.__image.pixel(
-                            self.__selRect.x() + i, self.__selRect.y() + j))
-                        if cut:
-                            self.__image.setPixel(self.__selRect.x() + i,
-                                                  self.__selRect.y() + j,
-                                                  qRgba(0, 0, 0, 0))
+                if (
+                    self.__image.rect().contains(
+                        self.__selRect.x() + i, self.__selRect.y() + j) and
+                    self.__isMarked(self.__selRect.x() + i,
+                                    self.__selRect.y() + j)
+                ):
+                    img.setPixel(i, j, self.__image.pixel(
+                        self.__selRect.x() + i, self.__selRect.y() + j))
+                    if cut:
+                        self.__image.setPixel(self.__selRect.x() + i,
+                                              self.__selRect.y() + j,
+                                              qRgba(0, 0, 0, 0))
         
         if cut:
             self.__undoStack.push(cmd)

eric ide

mercurial