--- a/src/eric7/IconEditor/IconEditorGrid.py Wed Dec 20 11:06:38 2023 +0100 +++ b/src/eric7/IconEditor/IconEditorGrid.py Wed Dec 20 14:58:58 2023 +0100 @@ -39,11 +39,14 @@ """ Constructor - @param grid reference to the icon editor grid (IconEditorGrid) - @param text text for the undo command (string) + @param grid reference to the icon editor grid + @type IconEditorGrid + @param text text for the undo command + @type str @param oldImage copy of the icon before the changes were applied - (QImage) - @param parent reference to the parent command (QUndoCommand) + @type QImage + @param parent reference to the parent command + @type QUndoCommand """ super().__init__(text, parent) @@ -55,7 +58,8 @@ """ Public method to set the image after the changes were applied. - @param image copy of the icon after the changes were applied (QImage) + @param image copy of the icon after the changes were applied + @type QImage """ self.__imageAfter = QImage(image) @@ -137,7 +141,8 @@ """ Constructor - @param parent reference to the parent widget (QWidget) + @param parent reference to the parent widget + @type QWidget """ super().__init__(parent) @@ -239,7 +244,8 @@ """ Public method to check the dirty status. - @return flag indicating a modified status (boolean) + @return flag indicating a modified status + @rtype bool """ return self.__dirty @@ -247,9 +253,10 @@ """ Public slot to set the dirty flag. - @param dirty flag indicating the new modification status (boolean) + @param dirty flag indicating the new modification status + @type bool @param setCleanState flag indicating to set the undo stack to clean - (boolean) + @type bool """ self.__dirty = dirty self.imageChanged.emit(dirty) @@ -261,7 +268,8 @@ """ Public method to report the size hint. - @return size hint (QSize) + @return size hint + @rtype QSize """ size = self.__zoom * self.__image.size() if self.__zoom >= 3 and self.__gridEnabled: @@ -272,7 +280,8 @@ """ Public method to set the drawing color. - @param newColor reference to the new color (QColor) + @param newColor reference to the new color + @type QColor """ self.__curColor = QColor(newColor) self.colorChanged.emit(QColor(newColor)) @@ -281,7 +290,8 @@ """ Public method to get the current drawing color. - @return current drawing color (QColor) + @return current drawing color + @rtype QColor """ return QColor(self.__curColor) @@ -289,7 +299,8 @@ """ Public method to set the compositing mode. - @param mode compositing mode to set (QPainter.CompositionMode) + @param mode compositing mode to set + @type QPainter.CompositionMode """ self.__compositingMode = mode @@ -297,7 +308,8 @@ """ Public method to get the compositing mode. - @return compositing mode (QPainter.CompositionMode) + @return compositing mode + @rtype QPainter.CompositionMode """ return self.__compositingMode @@ -355,9 +367,12 @@ """ Public method to set a new icon image. - @param newImage reference to the new image (QImage) - @param undoRedo flag indicating an undo or redo operation (boolean) - @param clearUndo flag indicating to clear the undo stack (boolean) + @param newImage reference to the new image + @type QImage + @param undoRedo flag indicating an undo or redo operation + @type bool + @param clearUndo flag indicating to clear the undo stack + @type bool """ if newImage != self.__image: self.__image = newImage.convertToFormat(QImage.Format.Format_ARGB32) @@ -382,7 +397,8 @@ """ Public method to get a copy of the icon image. - @return copy of the icon image (QImage) + @return copy of the icon image + @rtype QImage """ return QImage(self.__image) @@ -390,7 +406,8 @@ """ Public method to get the size of the icon. - @return width and height of the image as a tuple (integer, integer) + @return width and height of the image as a tuple + @rtype tuple of (int, int) """ return self.__image.width(), self.__image.height() @@ -398,7 +415,8 @@ """ Public method to set the zoom factor in percent. - @param newZoom zoom factor (integer >= 100) + @param newZoom zoom factor (>= 100) + @type int """ newZoom = max(100, newZoom) # must not be less than 100 if newZoom != self.__zoom: @@ -412,7 +430,8 @@ """ Public method to get the current zoom factor in percent. - @return zoom factor (integer) + @return zoom factor + @rtype int """ return self.__zoom * 100 @@ -420,7 +439,8 @@ """ Public method to enable the display of grid lines. - @param enable enabled status of the grid lines (boolean) + @param enable enabled status of the grid lines + @type bool """ if enable != self.__gridEnabled: self.__gridEnabled = enable @@ -430,7 +450,8 @@ """ Public method to get the grid lines status. - @return enabled status of the grid lines (boolean) + @return enabled status of the grid lines + @rtype bool """ return self.__gridEnabled @@ -438,7 +459,8 @@ """ Protected method called to repaint some of the widget. - @param evt reference to the paint event object (QPaintEvent) + @param evt reference to the paint event object + @type QPaintEvent """ painter = QPainter(self) @@ -487,9 +509,12 @@ """ Private method to determine the rectangle for a given pixel coordinate. - @param i x-coordinate of the pixel in the image (integer) - @param j y-coordinate of the pixel in the image (integer) - @return rectangle for the given pixel coordinates (QRect) + @param i x-coordinate of the pixel in the image + @type int + @param j y-coordinate of the pixel in the image + @type int + @return rectangle for the given pixel coordinates + @rtype QRect """ if self.__zoom >= 3 and self.__gridEnabled: return QRect( @@ -505,7 +530,8 @@ """ Protected method to handle mouse button press events. - @param evt reference to the mouse event object (QMouseEvent) + @param evt reference to the mouse event object + @type QMouseEvent """ if evt.button() == Qt.MouseButton.LeftButton: if self.__isPasting: @@ -557,7 +583,8 @@ """ Protected method to handle mouse move events. - @param evt reference to the mouse event object (QMouseEvent) + @param evt reference to the mouse event object + @type QMouseEvent """ self.positionChanged.emit(*self.__imageCoordinates(evt.position().toPoint())) @@ -581,7 +608,8 @@ """ Protected method to handle mouse button release events. - @param evt reference to the mouse event object (QMouseEvent) + @param evt reference to the mouse event object + @type QMouseEvent """ if evt.button() == Qt.MouseButton.LeftButton: if ( @@ -611,8 +639,10 @@ """ Private slot to set or erase a pixel. - @param pos position of the pixel in the widget (QPoint) - @param opaque flag indicating a set operation (boolean) + @param pos position of the pixel in the widget + @type QPoint + @param opaque flag indicating a set operation + @type bool """ i, j = self.__imageCoordinates(pos) @@ -632,8 +662,10 @@ """ Private method to convert from widget to image coordinates. - @param pos widget coordinate (QPoint) - @return tuple with the image coordinates (tuple of two integers) + @param pos widget coordinate + @type QPoint + @return tuple with the image coordinates + @rtype tuple of (int, int) """ i = pos.x() // self.__zoom j = pos.y() // self.__zoom @@ -643,7 +675,8 @@ """ Private slot to draw a rectangle for signaling a paste operation. - @param pos widget position of the paste rectangle (QPoint) + @param pos widget position of the paste rectangle + @type QPoint """ self.__markImage.fill(self.NoMarkColor.rgba()) if self.__pasteRect.isValid(): @@ -681,9 +714,12 @@ Private method to perform a draw operation depending of the current tool. - @param pos widget coordinate to perform the draw operation at (QPoint) - @param mark flag indicating a mark operation (boolean) - @return flag indicating a successful draw (boolean) + @param pos widget coordinate to perform the draw operation at + @type QPoint + @param mark flag indicating a mark operation + @type bool + @return flag indicating a successful draw + @rtype bool """ self.__unMark() @@ -774,11 +810,15 @@ """ Private method to perform a flood fill operation. - @param i x-value in image coordinates (integer) - @param j y-value in image coordinates (integer) - @param oldColor reference to the color at position i, j (QColor) - @param doUpdate flag indicating an update is requested (boolean) + @param i x-value in image coordinates + @type int + @param j y-value in image coordinates + @type int + @param oldColor reference to the color at position i, j + @type QColor + @param doUpdate flag indicating an update is requested (used for speed optimizations) + @type bool """ if ( not self.__image.rect().contains(i, j) @@ -802,9 +842,10 @@ Private slot to update parts of the widget. @param pos1 top, left position for the update in widget coordinates - (QPoint) + @type QPoint @param pos2 bottom, right position for the update in widget - coordinates (QPoint) + coordinates + @type QPoint """ self.__updateImageRect( QPoint(*self.__imageCoordinates(pos1)), @@ -816,9 +857,10 @@ Private slot to update parts of the widget. @param ipos1 top, left position for the update in image coordinates - (QPoint) + @type QPoint @param ipos2 bottom, right position for the update in image - coordinates (QPoint) + coordinates + @type QPoint """ r1 = self.__pixelRect(ipos1.x(), ipos1.y()) r2 = self.__pixelRect(ipos2.x(), ipos2.y()) @@ -854,9 +896,12 @@ """ Private method to check, if a pixel is marked. - @param i x-value in image coordinates (integer) - @param j y-value in image coordinates (integer) - @return flag indicating a marked pixel (boolean) + @param i x-value in image coordinates + @type int + @param j y-value in image coordinates + @type int + @return flag indicating a marked pixel + @rtype bool """ return self.__markImage.pixel(i, j) == self.MarkColor.rgba() @@ -871,7 +916,8 @@ """ Public method to generate a preview pixmap. - @return preview pixmap (QPixmap) + @return preview pixmap + @rtype QPixmap """ p = QPixmap.fromImage(self.__image) return p @@ -889,7 +935,8 @@ """ Public slot to check the availability of the paste operation. - @return flag indicating availability of paste (boolean) + @return flag indicating availability of paste + @rtype bool """ return self.__clipboardImageAvailable @@ -898,7 +945,8 @@ Private method to get an image from the clipboard. @return tuple with the image (QImage) and a flag indicating a - valid image (boolean) + valid image + @rtype bool """ img = QApplication.clipboard().image() ok = not img.isNull() @@ -911,8 +959,10 @@ """ Private method to get an image from the selection. - @param cut flag indicating to cut the selection (boolean) - @return image of the selection (QImage) + @param cut flag indicating to cut the selection + @type bool + @return image of the selection + @rtype QImage """ if cut: cmd = IconEditCommand(self, self.tr("Cut Selection"), self.__image) @@ -971,7 +1021,7 @@ Public slot to paste an image from the clipboard. @param pasting flag indicating part two of the paste operation - (boolean) + @type bool """ img, ok = self.__clipboardImage() if ok: @@ -1136,7 +1186,8 @@ """ Public method to return the undo status. - @return flag indicating the availability of undo (boolean) + @return flag indicating the availability of undo + @rtype bool """ return self.__undoStack.canUndo() @@ -1144,7 +1195,8 @@ """ Public method to return the redo status. - @return flag indicating the availability of redo (boolean) + @return flag indicating the availability of redo + @rtype bool """ return self.__undoStack.canRedo() @@ -1152,7 +1204,8 @@ """ Private slot to handle the undo stack clean state change. - @param clean flag indicating the clean state (boolean) + @param clean flag indicating the clean state + @type bool """ self.setDirty(not clean) @@ -1168,6 +1221,7 @@ """ Public method to check the availability of a selection. - @return flag indicating the availability of a selection (boolean) + @return flag indicating the availability of a selection + @rtype bool """ return self.__selectionAvailable