eric6/IconEditor/IconEditorGrid.py

changeset 7254
f00d825fbdb3
parent 7229
53054eb5b15a
child 7360
9190402e4505
equal deleted inserted replaced
7253:50dbe65a1334 7254:f00d825fbdb3
7 Module implementing the icon editor grid. 7 Module implementing the icon editor grid.
8 """ 8 """
9 9
10 10
11 from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QPoint, QRect, QSize 11 from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QPoint, QRect, QSize
12 from PyQt5.QtGui import QImage, QColor, QPixmap, qRgba, QPainter, QCursor, \ 12 from PyQt5.QtGui import (
13 QBrush, qGray, qAlpha 13 QImage, QColor, QPixmap, qRgba, QPainter, QCursor, QBrush, qGray, qAlpha
14 from PyQt5.QtWidgets import QUndoCommand, QWidget, QSizePolicy, QUndoStack, \ 14 )
15 QApplication, QDialog 15 from PyQt5.QtWidgets import (
16 QUndoCommand, QWidget, QSizePolicy, QUndoStack, QApplication, QDialog
17 )
16 18
17 from E5Gui import E5MessageBox 19 from E5Gui import E5MessageBox
18 20
19 from .cursors import cursors_rc # __IGNORE_WARNING__ 21 from .cursors import cursors_rc # __IGNORE_WARNING__
20 22
709 @param j y-value in image coordinates (integer) 711 @param j y-value in image coordinates (integer)
710 @param oldColor reference to the color at position i, j (QColor) 712 @param oldColor reference to the color at position i, j (QColor)
711 @param doUpdate flag indicating an update is requested (boolean) 713 @param doUpdate flag indicating an update is requested (boolean)
712 (used for speed optimizations) 714 (used for speed optimizations)
713 """ 715 """
714 if not self.__image.rect().contains(i, j) or \ 716 if (
715 self.__image.pixel(i, j) != oldColor.rgba() or \ 717 not self.__image.rect().contains(i, j) or
716 self.__image.pixel(i, j) == self.penColor().rgba(): 718 self.__image.pixel(i, j) != oldColor.rgba() or
719 self.__image.pixel(i, j) == self.penColor().rgba()
720 ):
717 return 721 return
718 722
719 self.__image.setPixel(i, j, self.penColor().rgba()) 723 self.__image.setPixel(i, j, self.penColor().rgba())
720 724
721 self.__drawFlood(i, j - 1, oldColor, False) 725 self.__drawFlood(i, j - 1, oldColor, False)
891 @param pasting flag indicating part two of the paste operation 895 @param pasting flag indicating part two of the paste operation
892 (boolean) 896 (boolean)
893 """ 897 """
894 img, ok = self.__clipboardImage() 898 img, ok = self.__clipboardImage()
895 if ok: 899 if ok:
896 if img.width() > self.__image.width() or \ 900 if (
897 img.height() > self.__image.height(): 901 img.width() > self.__image.width() or
902 img.height() > self.__image.height()
903 ):
898 res = E5MessageBox.yesNo( 904 res = E5MessageBox.yesNo(
899 self, 905 self,
900 self.tr("Paste"), 906 self.tr("Paste"),
901 self.tr( 907 self.tr(
902 """<p>The clipboard image is larger than the""" 908 """<p>The clipboard image is larger than the"""
980 from .IconSizeDialog import IconSizeDialog 986 from .IconSizeDialog import IconSizeDialog
981 dlg = IconSizeDialog(self.__image.width(), self.__image.height()) 987 dlg = IconSizeDialog(self.__image.width(), self.__image.height())
982 res = dlg.exec_() 988 res = dlg.exec_()
983 if res == QDialog.Accepted: 989 if res == QDialog.Accepted:
984 newWidth, newHeight = dlg.getData() 990 newWidth, newHeight = dlg.getData()
985 if newWidth != self.__image.width() or \ 991 if (
986 newHeight != self.__image.height(): 992 newWidth != self.__image.width() or
993 newHeight != self.__image.height()
994 ):
987 cmd = IconEditCommand(self, self.tr("Resize Image"), 995 cmd = IconEditCommand(self, self.tr("Resize Image"),
988 self.__image) 996 self.__image)
989 img = self.__image.scaled( 997 img = self.__image.scaled(
990 newWidth, newHeight, Qt.IgnoreAspectRatio, 998 newWidth, newHeight, Qt.IgnoreAspectRatio,
991 Qt.SmoothTransformation) 999 Qt.SmoothTransformation)

eric ide

mercurial