--- a/eric6/IconEditor/IconEditorGrid.py Mon Mar 01 17:48:43 2021 +0100 +++ b/eric6/IconEditor/IconEditorGrid.py Tue Mar 02 17:17:09 2021 +0100 @@ -123,10 +123,11 @@ """ super(IconEditorGrid, self).__init__(parent) - self.setAttribute(Qt.WA_StaticContents) - self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) + self.setAttribute(Qt.WidgetAttribute.WA_StaticContents) + self.setSizePolicy(QSizePolicy.Policy.Minimum, + QSizePolicy.Policy.Minimum) - self.__curColor = Qt.black + self.__curColor = Qt.GlobalColor.black self.__zoom = 12 self.__curTool = self.Pencil self.__startPos = QPoint() @@ -141,12 +142,14 @@ self.__undoStack = QUndoStack(self) self.__currentUndoCmd = None - self.__image = QImage(32, 32, QImage.Format_ARGB32) + self.__image = QImage(32, 32, QImage.Format.Format_ARGB32) self.__image.fill(qRgba(0, 0, 0, 0)) self.__markImage = QImage(self.__image) self.__markImage.fill(self.NoMarkColor.rgba()) - self.__compositingMode = QPainter.CompositionMode_SourceOver + self.__compositingMode = ( + QPainter.CompositionMode.CompositionMode_SourceOver + ) self.__lastPos = (-1, -1) self.__gridEnabled = True @@ -172,7 +175,7 @@ """ cursorsPath = os.path.join(os.path.dirname(__file__), "cursors") - self.__normalCursor = QCursor(Qt.ArrowCursor) + self.__normalCursor = QCursor(Qt.CursorShape.ArrowCursor) pix = QPixmap(os.path.join(cursorsPath, "colorpicker-cursor.xpm")) mask = pix.createHeuristicMask() @@ -332,7 +335,8 @@ @param clearUndo flag indicating to clear the undo stack (boolean) """ if newImage != self.__image: - self.__image = newImage.convertToFormat(QImage.Format_ARGB32) + self.__image = newImage.convertToFormat( + QImage.Format.Format_ARGB32) self.update() self.updateGeometry() self.resize(self.sizeHint()) @@ -430,13 +434,13 @@ j += 1 col = QColor("#aaa") - painter.setPen(Qt.DashLine) + painter.setPen(Qt.PenStyle.DashLine) for i in range(0, self.__image.width()): for j in range(0, self.__image.height()): rect = self.__pixelRect(i, j) if evt.region().intersects(rect): color = QColor.fromRgba(self.__image.pixel(i, j)) - painter.fillRect(rect, QBrush(Qt.white)) + painter.fillRect(rect, QBrush(Qt.GlobalColor.white)) painter.fillRect(QRect(rect.topLeft(), rect.center()), col) painter.fillRect(QRect(rect.center(), rect.bottomRight()), col) @@ -468,7 +472,7 @@ @param evt reference to the mouse event object (QMouseEvent) """ - if evt.button() == Qt.LeftButton: + if evt.button() == Qt.MouseButton.LeftButton: if self.__isPasting: self.__isPasting = False self.editPaste(True) @@ -519,11 +523,14 @@ """ self.positionChanged.emit(*self.__imageCoordinates(evt.pos())) - if self.__isPasting and not (evt.buttons() & Qt.LeftButton): + if ( + self.__isPasting and + not (evt.buttons() & Qt.MouseButton.LeftButton) + ): self.__drawPasteRect(evt.pos()) return - if evt.buttons() & Qt.LeftButton: + if evt.buttons() & Qt.MouseButton.LeftButton: if self.__curTool == self.Pencil: self.__setImagePixel(evt.pos(), True) self.setDirty(True) @@ -541,7 +548,7 @@ @param evt reference to the mouse event object (QMouseEvent) """ - if evt.button() == Qt.LeftButton: + if evt.button() == Qt.MouseButton.LeftButton: if self.__curTool in [self.Pencil, self.Rubber]: if self.__currentUndoCmd: self.__currentUndoCmd.setAfterImage(self.__image) @@ -831,7 +838,7 @@ img = QApplication.clipboard().image() ok = not img.isNull() if ok: - img = img.convertToFormat(QImage.Format_ARGB32) + img = img.convertToFormat(QImage.Format.Format_ARGB32) return img, ok @@ -846,7 +853,7 @@ cmd = IconEditCommand(self, self.tr("Cut Selection"), self.__image) - img = QImage(self.__selRect.size(), QImage.Format_ARGB32) + img = QImage(self.__selRect.size(), QImage.Format.Format_ARGB32) img.fill(qRgba(0, 0, 0, 0)) for i in range(0, self.__selRect.width()): for j in range(0, self.__selRect.height()): @@ -987,7 +994,7 @@ from .IconSizeDialog import IconSizeDialog dlg = IconSizeDialog(self.__image.width(), self.__image.height()) res = dlg.exec() - if res == QDialog.Accepted: + if res == QDialog.DialogCode.Accepted: newWidth, newHeight = dlg.getData() if ( newWidth != self.__image.width() or @@ -996,8 +1003,8 @@ cmd = IconEditCommand(self, self.tr("Resize Image"), self.__image) img = self.__image.scaled( - newWidth, newHeight, Qt.IgnoreAspectRatio, - Qt.SmoothTransformation) + newWidth, newHeight, Qt.AspectRatioMode.IgnoreAspectRatio, + Qt.TransformationMode.SmoothTransformation) self.setIconImage(img) self.setDirty(True) self.__undoStack.push(cmd) @@ -1010,9 +1017,9 @@ from .IconSizeDialog import IconSizeDialog dlg = IconSizeDialog(self.__image.width(), self.__image.height()) res = dlg.exec() - if res == QDialog.Accepted: + if res == QDialog.DialogCode.Accepted: width, height = dlg.getData() - img = QImage(width, height, QImage.Format_ARGB32) + img = QImage(width, height, QImage.Format.Format_ARGB32) img.fill(qRgba(0, 0, 0, 0)) self.setIconImage(img)