37 |
37 |
38 def __init__(self, grid, text, oldImage, parent=None): |
38 def __init__(self, grid, text, oldImage, parent=None): |
39 """ |
39 """ |
40 Constructor |
40 Constructor |
41 |
41 |
42 @param grid reference to the icon editor grid (IconEditorGrid) |
42 @param grid reference to the icon editor grid |
43 @param text text for the undo command (string) |
43 @type IconEditorGrid |
|
44 @param text text for the undo command |
|
45 @type str |
44 @param oldImage copy of the icon before the changes were applied |
46 @param oldImage copy of the icon before the changes were applied |
45 (QImage) |
47 @type QImage |
46 @param parent reference to the parent command (QUndoCommand) |
48 @param parent reference to the parent command |
|
49 @type QUndoCommand |
47 """ |
50 """ |
48 super().__init__(text, parent) |
51 super().__init__(text, parent) |
49 |
52 |
50 self.__grid = grid |
53 self.__grid = grid |
51 self.__imageBefore = QImage(oldImage) |
54 self.__imageBefore = QImage(oldImage) |
53 |
56 |
54 def setAfterImage(self, image): |
57 def setAfterImage(self, image): |
55 """ |
58 """ |
56 Public method to set the image after the changes were applied. |
59 Public method to set the image after the changes were applied. |
57 |
60 |
58 @param image copy of the icon after the changes were applied (QImage) |
61 @param image copy of the icon after the changes were applied |
|
62 @type QImage |
59 """ |
63 """ |
60 self.__imageAfter = QImage(image) |
64 self.__imageAfter = QImage(image) |
61 |
65 |
62 def undo(self): |
66 def undo(self): |
63 """ |
67 """ |
135 |
139 |
136 def __init__(self, parent=None): |
140 def __init__(self, parent=None): |
137 """ |
141 """ |
138 Constructor |
142 Constructor |
139 |
143 |
140 @param parent reference to the parent widget (QWidget) |
144 @param parent reference to the parent widget |
|
145 @type QWidget |
141 """ |
146 """ |
142 super().__init__(parent) |
147 super().__init__(parent) |
143 |
148 |
144 self.setAttribute(Qt.WidgetAttribute.WA_StaticContents) |
149 self.setAttribute(Qt.WidgetAttribute.WA_StaticContents) |
145 self.setSizePolicy(QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Minimum) |
150 self.setSizePolicy(QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Minimum) |
237 |
242 |
238 def isDirty(self): |
243 def isDirty(self): |
239 """ |
244 """ |
240 Public method to check the dirty status. |
245 Public method to check the dirty status. |
241 |
246 |
242 @return flag indicating a modified status (boolean) |
247 @return flag indicating a modified status |
|
248 @rtype bool |
243 """ |
249 """ |
244 return self.__dirty |
250 return self.__dirty |
245 |
251 |
246 def setDirty(self, dirty, setCleanState=False): |
252 def setDirty(self, dirty, setCleanState=False): |
247 """ |
253 """ |
248 Public slot to set the dirty flag. |
254 Public slot to set the dirty flag. |
249 |
255 |
250 @param dirty flag indicating the new modification status (boolean) |
256 @param dirty flag indicating the new modification status |
|
257 @type bool |
251 @param setCleanState flag indicating to set the undo stack to clean |
258 @param setCleanState flag indicating to set the undo stack to clean |
252 (boolean) |
259 @type bool |
253 """ |
260 """ |
254 self.__dirty = dirty |
261 self.__dirty = dirty |
255 self.imageChanged.emit(dirty) |
262 self.imageChanged.emit(dirty) |
256 |
263 |
257 if not dirty and setCleanState: |
264 if not dirty and setCleanState: |
259 |
266 |
260 def sizeHint(self): |
267 def sizeHint(self): |
261 """ |
268 """ |
262 Public method to report the size hint. |
269 Public method to report the size hint. |
263 |
270 |
264 @return size hint (QSize) |
271 @return size hint |
|
272 @rtype QSize |
265 """ |
273 """ |
266 size = self.__zoom * self.__image.size() |
274 size = self.__zoom * self.__image.size() |
267 if self.__zoom >= 3 and self.__gridEnabled: |
275 if self.__zoom >= 3 and self.__gridEnabled: |
268 size += QSize(1, 1) |
276 size += QSize(1, 1) |
269 return size |
277 return size |
270 |
278 |
271 def setPenColor(self, newColor): |
279 def setPenColor(self, newColor): |
272 """ |
280 """ |
273 Public method to set the drawing color. |
281 Public method to set the drawing color. |
274 |
282 |
275 @param newColor reference to the new color (QColor) |
283 @param newColor reference to the new color |
|
284 @type QColor |
276 """ |
285 """ |
277 self.__curColor = QColor(newColor) |
286 self.__curColor = QColor(newColor) |
278 self.colorChanged.emit(QColor(newColor)) |
287 self.colorChanged.emit(QColor(newColor)) |
279 |
288 |
280 def penColor(self): |
289 def penColor(self): |
281 """ |
290 """ |
282 Public method to get the current drawing color. |
291 Public method to get the current drawing color. |
283 |
292 |
284 @return current drawing color (QColor) |
293 @return current drawing color |
|
294 @rtype QColor |
285 """ |
295 """ |
286 return QColor(self.__curColor) |
296 return QColor(self.__curColor) |
287 |
297 |
288 def setCompositingMode(self, mode): |
298 def setCompositingMode(self, mode): |
289 """ |
299 """ |
290 Public method to set the compositing mode. |
300 Public method to set the compositing mode. |
291 |
301 |
292 @param mode compositing mode to set (QPainter.CompositionMode) |
302 @param mode compositing mode to set |
|
303 @type QPainter.CompositionMode |
293 """ |
304 """ |
294 self.__compositingMode = mode |
305 self.__compositingMode = mode |
295 |
306 |
296 def compositingMode(self): |
307 def compositingMode(self): |
297 """ |
308 """ |
298 Public method to get the compositing mode. |
309 Public method to get the compositing mode. |
299 |
310 |
300 @return compositing mode (QPainter.CompositionMode) |
311 @return compositing mode |
|
312 @rtype QPainter.CompositionMode |
301 """ |
313 """ |
302 return self.__compositingMode |
314 return self.__compositingMode |
303 |
315 |
304 def setTool(self, tool): |
316 def setTool(self, tool): |
305 """ |
317 """ |
353 |
365 |
354 def setIconImage(self, newImage, undoRedo=False, clearUndo=False): |
366 def setIconImage(self, newImage, undoRedo=False, clearUndo=False): |
355 """ |
367 """ |
356 Public method to set a new icon image. |
368 Public method to set a new icon image. |
357 |
369 |
358 @param newImage reference to the new image (QImage) |
370 @param newImage reference to the new image |
359 @param undoRedo flag indicating an undo or redo operation (boolean) |
371 @type QImage |
360 @param clearUndo flag indicating to clear the undo stack (boolean) |
372 @param undoRedo flag indicating an undo or redo operation |
|
373 @type bool |
|
374 @param clearUndo flag indicating to clear the undo stack |
|
375 @type bool |
361 """ |
376 """ |
362 if newImage != self.__image: |
377 if newImage != self.__image: |
363 self.__image = newImage.convertToFormat(QImage.Format.Format_ARGB32) |
378 self.__image = newImage.convertToFormat(QImage.Format.Format_ARGB32) |
364 self.update() |
379 self.update() |
365 self.updateGeometry() |
380 self.updateGeometry() |
380 |
395 |
381 def iconImage(self): |
396 def iconImage(self): |
382 """ |
397 """ |
383 Public method to get a copy of the icon image. |
398 Public method to get a copy of the icon image. |
384 |
399 |
385 @return copy of the icon image (QImage) |
400 @return copy of the icon image |
|
401 @rtype QImage |
386 """ |
402 """ |
387 return QImage(self.__image) |
403 return QImage(self.__image) |
388 |
404 |
389 def iconSize(self): |
405 def iconSize(self): |
390 """ |
406 """ |
391 Public method to get the size of the icon. |
407 Public method to get the size of the icon. |
392 |
408 |
393 @return width and height of the image as a tuple (integer, integer) |
409 @return width and height of the image as a tuple |
|
410 @rtype tuple of (int, int) |
394 """ |
411 """ |
395 return self.__image.width(), self.__image.height() |
412 return self.__image.width(), self.__image.height() |
396 |
413 |
397 def setZoomFactor(self, newZoom): |
414 def setZoomFactor(self, newZoom): |
398 """ |
415 """ |
399 Public method to set the zoom factor in percent. |
416 Public method to set the zoom factor in percent. |
400 |
417 |
401 @param newZoom zoom factor (integer >= 100) |
418 @param newZoom zoom factor (>= 100) |
|
419 @type int |
402 """ |
420 """ |
403 newZoom = max(100, newZoom) # must not be less than 100 |
421 newZoom = max(100, newZoom) # must not be less than 100 |
404 if newZoom != self.__zoom: |
422 if newZoom != self.__zoom: |
405 self.__zoom = newZoom // 100 |
423 self.__zoom = newZoom // 100 |
406 self.update() |
424 self.update() |
410 |
428 |
411 def zoomFactor(self): |
429 def zoomFactor(self): |
412 """ |
430 """ |
413 Public method to get the current zoom factor in percent. |
431 Public method to get the current zoom factor in percent. |
414 |
432 |
415 @return zoom factor (integer) |
433 @return zoom factor |
|
434 @rtype int |
416 """ |
435 """ |
417 return self.__zoom * 100 |
436 return self.__zoom * 100 |
418 |
437 |
419 def setGridEnabled(self, enable): |
438 def setGridEnabled(self, enable): |
420 """ |
439 """ |
421 Public method to enable the display of grid lines. |
440 Public method to enable the display of grid lines. |
422 |
441 |
423 @param enable enabled status of the grid lines (boolean) |
442 @param enable enabled status of the grid lines |
|
443 @type bool |
424 """ |
444 """ |
425 if enable != self.__gridEnabled: |
445 if enable != self.__gridEnabled: |
426 self.__gridEnabled = enable |
446 self.__gridEnabled = enable |
427 self.update() |
447 self.update() |
428 |
448 |
429 def isGridEnabled(self): |
449 def isGridEnabled(self): |
430 """ |
450 """ |
431 Public method to get the grid lines status. |
451 Public method to get the grid lines status. |
432 |
452 |
433 @return enabled status of the grid lines (boolean) |
453 @return enabled status of the grid lines |
|
454 @rtype bool |
434 """ |
455 """ |
435 return self.__gridEnabled |
456 return self.__gridEnabled |
436 |
457 |
437 def paintEvent(self, evt): |
458 def paintEvent(self, evt): |
438 """ |
459 """ |
439 Protected method called to repaint some of the widget. |
460 Protected method called to repaint some of the widget. |
440 |
461 |
441 @param evt reference to the paint event object (QPaintEvent) |
462 @param evt reference to the paint event object |
|
463 @type QPaintEvent |
442 """ |
464 """ |
443 painter = QPainter(self) |
465 painter = QPainter(self) |
444 |
466 |
445 if self.__zoom >= 3 and self.__gridEnabled: |
467 if self.__zoom >= 3 and self.__gridEnabled: |
446 if ericApp().usesDarkPalette(): |
468 if ericApp().usesDarkPalette(): |
485 |
507 |
486 def __pixelRect(self, i, j): |
508 def __pixelRect(self, i, j): |
487 """ |
509 """ |
488 Private method to determine the rectangle for a given pixel coordinate. |
510 Private method to determine the rectangle for a given pixel coordinate. |
489 |
511 |
490 @param i x-coordinate of the pixel in the image (integer) |
512 @param i x-coordinate of the pixel in the image |
491 @param j y-coordinate of the pixel in the image (integer) |
513 @type int |
492 @return rectangle for the given pixel coordinates (QRect) |
514 @param j y-coordinate of the pixel in the image |
|
515 @type int |
|
516 @return rectangle for the given pixel coordinates |
|
517 @rtype QRect |
493 """ |
518 """ |
494 if self.__zoom >= 3 and self.__gridEnabled: |
519 if self.__zoom >= 3 and self.__gridEnabled: |
495 return QRect( |
520 return QRect( |
496 self.__zoom * i + 1, |
521 self.__zoom * i + 1, |
497 self.__zoom * j + 1, |
522 self.__zoom * j + 1, |
503 |
528 |
504 def mousePressEvent(self, evt): |
529 def mousePressEvent(self, evt): |
505 """ |
530 """ |
506 Protected method to handle mouse button press events. |
531 Protected method to handle mouse button press events. |
507 |
532 |
508 @param evt reference to the mouse event object (QMouseEvent) |
533 @param evt reference to the mouse event object |
|
534 @type QMouseEvent |
509 """ |
535 """ |
510 if evt.button() == Qt.MouseButton.LeftButton: |
536 if evt.button() == Qt.MouseButton.LeftButton: |
511 if self.__isPasting: |
537 if self.__isPasting: |
512 self.__isPasting = False |
538 self.__isPasting = False |
513 self.editPaste(True) |
539 self.editPaste(True) |
555 |
581 |
556 def mouseMoveEvent(self, evt): |
582 def mouseMoveEvent(self, evt): |
557 """ |
583 """ |
558 Protected method to handle mouse move events. |
584 Protected method to handle mouse move events. |
559 |
585 |
560 @param evt reference to the mouse event object (QMouseEvent) |
586 @param evt reference to the mouse event object |
|
587 @type QMouseEvent |
561 """ |
588 """ |
562 self.positionChanged.emit(*self.__imageCoordinates(evt.position().toPoint())) |
589 self.positionChanged.emit(*self.__imageCoordinates(evt.position().toPoint())) |
563 |
590 |
564 if self.__isPasting and not (evt.buttons() & Qt.MouseButton.LeftButton): |
591 if self.__isPasting and not (evt.buttons() & Qt.MouseButton.LeftButton): |
565 self.__drawPasteRect(evt.position().toPoint()) |
592 self.__drawPasteRect(evt.position().toPoint()) |
579 |
606 |
580 def mouseReleaseEvent(self, evt): |
607 def mouseReleaseEvent(self, evt): |
581 """ |
608 """ |
582 Protected method to handle mouse button release events. |
609 Protected method to handle mouse button release events. |
583 |
610 |
584 @param evt reference to the mouse event object (QMouseEvent) |
611 @param evt reference to the mouse event object |
|
612 @type QMouseEvent |
585 """ |
613 """ |
586 if evt.button() == Qt.MouseButton.LeftButton: |
614 if evt.button() == Qt.MouseButton.LeftButton: |
587 if ( |
615 if ( |
588 self.__curTool in [IconEditorTool.PENCIL, IconEditorTool.RUBBER] |
616 self.__curTool in [IconEditorTool.PENCIL, IconEditorTool.RUBBER] |
589 and self.__currentUndoCmd |
617 and self.__currentUndoCmd |
609 |
637 |
610 def __setImagePixel(self, pos, opaque): |
638 def __setImagePixel(self, pos, opaque): |
611 """ |
639 """ |
612 Private slot to set or erase a pixel. |
640 Private slot to set or erase a pixel. |
613 |
641 |
614 @param pos position of the pixel in the widget (QPoint) |
642 @param pos position of the pixel in the widget |
615 @param opaque flag indicating a set operation (boolean) |
643 @type QPoint |
|
644 @param opaque flag indicating a set operation |
|
645 @type bool |
616 """ |
646 """ |
617 i, j = self.__imageCoordinates(pos) |
647 i, j = self.__imageCoordinates(pos) |
618 |
648 |
619 if self.__image.rect().contains(i, j) and (i, j) != self.__lastPos: |
649 if self.__image.rect().contains(i, j) and (i, j) != self.__lastPos: |
620 if opaque: |
650 if opaque: |
630 |
660 |
631 def __imageCoordinates(self, pos): |
661 def __imageCoordinates(self, pos): |
632 """ |
662 """ |
633 Private method to convert from widget to image coordinates. |
663 Private method to convert from widget to image coordinates. |
634 |
664 |
635 @param pos widget coordinate (QPoint) |
665 @param pos widget coordinate |
636 @return tuple with the image coordinates (tuple of two integers) |
666 @type QPoint |
|
667 @return tuple with the image coordinates |
|
668 @rtype tuple of (int, int) |
637 """ |
669 """ |
638 i = pos.x() // self.__zoom |
670 i = pos.x() // self.__zoom |
639 j = pos.y() // self.__zoom |
671 j = pos.y() // self.__zoom |
640 return i, j |
672 return i, j |
641 |
673 |
642 def __drawPasteRect(self, pos): |
674 def __drawPasteRect(self, pos): |
643 """ |
675 """ |
644 Private slot to draw a rectangle for signaling a paste operation. |
676 Private slot to draw a rectangle for signaling a paste operation. |
645 |
677 |
646 @param pos widget position of the paste rectangle (QPoint) |
678 @param pos widget position of the paste rectangle |
|
679 @type QPoint |
647 """ |
680 """ |
648 self.__markImage.fill(self.NoMarkColor.rgba()) |
681 self.__markImage.fill(self.NoMarkColor.rgba()) |
649 if self.__pasteRect.isValid(): |
682 if self.__pasteRect.isValid(): |
650 self.__updateImageRect( |
683 self.__updateImageRect( |
651 self.__pasteRect.topLeft(), |
684 self.__pasteRect.topLeft(), |
679 def __drawTool(self, pos, mark): |
712 def __drawTool(self, pos, mark): |
680 """ |
713 """ |
681 Private method to perform a draw operation depending of the current |
714 Private method to perform a draw operation depending of the current |
682 tool. |
715 tool. |
683 |
716 |
684 @param pos widget coordinate to perform the draw operation at (QPoint) |
717 @param pos widget coordinate to perform the draw operation at |
685 @param mark flag indicating a mark operation (boolean) |
718 @type QPoint |
686 @return flag indicating a successful draw (boolean) |
719 @param mark flag indicating a mark operation |
|
720 @type bool |
|
721 @return flag indicating a successful draw |
|
722 @rtype bool |
687 """ |
723 """ |
688 self.__unMark() |
724 self.__unMark() |
689 |
725 |
690 if mark: |
726 if mark: |
691 self.__endPos = QPoint(pos) |
727 self.__endPos = QPoint(pos) |
772 |
808 |
773 def __drawFlood(self, i, j, oldColor, doUpdate=True): |
809 def __drawFlood(self, i, j, oldColor, doUpdate=True): |
774 """ |
810 """ |
775 Private method to perform a flood fill operation. |
811 Private method to perform a flood fill operation. |
776 |
812 |
777 @param i x-value in image coordinates (integer) |
813 @param i x-value in image coordinates |
778 @param j y-value in image coordinates (integer) |
814 @type int |
779 @param oldColor reference to the color at position i, j (QColor) |
815 @param j y-value in image coordinates |
780 @param doUpdate flag indicating an update is requested (boolean) |
816 @type int |
|
817 @param oldColor reference to the color at position i, j |
|
818 @type QColor |
|
819 @param doUpdate flag indicating an update is requested |
781 (used for speed optimizations) |
820 (used for speed optimizations) |
|
821 @type bool |
782 """ |
822 """ |
783 if ( |
823 if ( |
784 not self.__image.rect().contains(i, j) |
824 not self.__image.rect().contains(i, j) |
785 or self.__image.pixel(i, j) != oldColor.rgba() |
825 or self.__image.pixel(i, j) != oldColor.rgba() |
786 or self.__image.pixel(i, j) == self.penColor().rgba() |
826 or self.__image.pixel(i, j) == self.penColor().rgba() |
800 def __updateRect(self, pos1, pos2): |
840 def __updateRect(self, pos1, pos2): |
801 """ |
841 """ |
802 Private slot to update parts of the widget. |
842 Private slot to update parts of the widget. |
803 |
843 |
804 @param pos1 top, left position for the update in widget coordinates |
844 @param pos1 top, left position for the update in widget coordinates |
805 (QPoint) |
845 @type QPoint |
806 @param pos2 bottom, right position for the update in widget |
846 @param pos2 bottom, right position for the update in widget |
807 coordinates (QPoint) |
847 coordinates |
|
848 @type QPoint |
808 """ |
849 """ |
809 self.__updateImageRect( |
850 self.__updateImageRect( |
810 QPoint(*self.__imageCoordinates(pos1)), |
851 QPoint(*self.__imageCoordinates(pos1)), |
811 QPoint(*self.__imageCoordinates(pos2)), |
852 QPoint(*self.__imageCoordinates(pos2)), |
812 ) |
853 ) |
814 def __updateImageRect(self, ipos1, ipos2): |
855 def __updateImageRect(self, ipos1, ipos2): |
815 """ |
856 """ |
816 Private slot to update parts of the widget. |
857 Private slot to update parts of the widget. |
817 |
858 |
818 @param ipos1 top, left position for the update in image coordinates |
859 @param ipos1 top, left position for the update in image coordinates |
819 (QPoint) |
860 @type QPoint |
820 @param ipos2 bottom, right position for the update in image |
861 @param ipos2 bottom, right position for the update in image |
821 coordinates (QPoint) |
862 coordinates |
|
863 @type QPoint |
822 """ |
864 """ |
823 r1 = self.__pixelRect(ipos1.x(), ipos1.y()) |
865 r1 = self.__pixelRect(ipos1.x(), ipos1.y()) |
824 r2 = self.__pixelRect(ipos2.x(), ipos2.y()) |
866 r2 = self.__pixelRect(ipos2.x(), ipos2.y()) |
825 |
867 |
826 left = min(r1.x(), r2.x()) |
868 left = min(r1.x(), r2.x()) |
852 |
894 |
853 def __isMarked(self, i, j): |
895 def __isMarked(self, i, j): |
854 """ |
896 """ |
855 Private method to check, if a pixel is marked. |
897 Private method to check, if a pixel is marked. |
856 |
898 |
857 @param i x-value in image coordinates (integer) |
899 @param i x-value in image coordinates |
858 @param j y-value in image coordinates (integer) |
900 @type int |
859 @return flag indicating a marked pixel (boolean) |
901 @param j y-value in image coordinates |
|
902 @type int |
|
903 @return flag indicating a marked pixel |
|
904 @rtype bool |
860 """ |
905 """ |
861 return self.__markImage.pixel(i, j) == self.MarkColor.rgba() |
906 return self.__markImage.pixel(i, j) == self.MarkColor.rgba() |
862 |
907 |
863 def __updatePreviewPixmap(self): |
908 def __updatePreviewPixmap(self): |
864 """ |
909 """ |
869 |
914 |
870 def previewPixmap(self): |
915 def previewPixmap(self): |
871 """ |
916 """ |
872 Public method to generate a preview pixmap. |
917 Public method to generate a preview pixmap. |
873 |
918 |
874 @return preview pixmap (QPixmap) |
919 @return preview pixmap |
|
920 @rtype QPixmap |
875 """ |
921 """ |
876 p = QPixmap.fromImage(self.__image) |
922 p = QPixmap.fromImage(self.__image) |
877 return p |
923 return p |
878 |
924 |
879 def __checkClipboard(self): |
925 def __checkClipboard(self): |
887 |
933 |
888 def canPaste(self): |
934 def canPaste(self): |
889 """ |
935 """ |
890 Public slot to check the availability of the paste operation. |
936 Public slot to check the availability of the paste operation. |
891 |
937 |
892 @return flag indicating availability of paste (boolean) |
938 @return flag indicating availability of paste |
|
939 @rtype bool |
893 """ |
940 """ |
894 return self.__clipboardImageAvailable |
941 return self.__clipboardImageAvailable |
895 |
942 |
896 def __clipboardImage(self): |
943 def __clipboardImage(self): |
897 """ |
944 """ |
898 Private method to get an image from the clipboard. |
945 Private method to get an image from the clipboard. |
899 |
946 |
900 @return tuple with the image (QImage) and a flag indicating a |
947 @return tuple with the image (QImage) and a flag indicating a |
901 valid image (boolean) |
948 valid image |
|
949 @rtype bool |
902 """ |
950 """ |
903 img = QApplication.clipboard().image() |
951 img = QApplication.clipboard().image() |
904 ok = not img.isNull() |
952 ok = not img.isNull() |
905 if ok: |
953 if ok: |
906 img = img.convertToFormat(QImage.Format.Format_ARGB32) |
954 img = img.convertToFormat(QImage.Format.Format_ARGB32) |
909 |
957 |
910 def __getSelectionImage(self, cut): |
958 def __getSelectionImage(self, cut): |
911 """ |
959 """ |
912 Private method to get an image from the selection. |
960 Private method to get an image from the selection. |
913 |
961 |
914 @param cut flag indicating to cut the selection (boolean) |
962 @param cut flag indicating to cut the selection |
915 @return image of the selection (QImage) |
963 @type bool |
|
964 @return image of the selection |
|
965 @rtype QImage |
916 """ |
966 """ |
917 if cut: |
967 if cut: |
918 cmd = IconEditCommand(self, self.tr("Cut Selection"), self.__image) |
968 cmd = IconEditCommand(self, self.tr("Cut Selection"), self.__image) |
919 |
969 |
920 img = QImage(self.__selRect.size(), QImage.Format.Format_ARGB32) |
970 img = QImage(self.__selRect.size(), QImage.Format.Format_ARGB32) |
969 def editPaste(self, pasting=False): |
1019 def editPaste(self, pasting=False): |
970 """ |
1020 """ |
971 Public slot to paste an image from the clipboard. |
1021 Public slot to paste an image from the clipboard. |
972 |
1022 |
973 @param pasting flag indicating part two of the paste operation |
1023 @param pasting flag indicating part two of the paste operation |
974 (boolean) |
1024 @type bool |
975 """ |
1025 """ |
976 img, ok = self.__clipboardImage() |
1026 img, ok = self.__clipboardImage() |
977 if ok: |
1027 if ok: |
978 if ( |
1028 if ( |
979 img.width() > self.__image.width() |
1029 img.width() > self.__image.width() |
1134 |
1184 |
1135 def canUndo(self): |
1185 def canUndo(self): |
1136 """ |
1186 """ |
1137 Public method to return the undo status. |
1187 Public method to return the undo status. |
1138 |
1188 |
1139 @return flag indicating the availability of undo (boolean) |
1189 @return flag indicating the availability of undo |
|
1190 @rtype bool |
1140 """ |
1191 """ |
1141 return self.__undoStack.canUndo() |
1192 return self.__undoStack.canUndo() |
1142 |
1193 |
1143 def canRedo(self): |
1194 def canRedo(self): |
1144 """ |
1195 """ |
1145 Public method to return the redo status. |
1196 Public method to return the redo status. |
1146 |
1197 |
1147 @return flag indicating the availability of redo (boolean) |
1198 @return flag indicating the availability of redo |
|
1199 @rtype bool |
1148 """ |
1200 """ |
1149 return self.__undoStack.canRedo() |
1201 return self.__undoStack.canRedo() |
1150 |
1202 |
1151 def __cleanChanged(self, clean): |
1203 def __cleanChanged(self, clean): |
1152 """ |
1204 """ |
1153 Private slot to handle the undo stack clean state change. |
1205 Private slot to handle the undo stack clean state change. |
1154 |
1206 |
1155 @param clean flag indicating the clean state (boolean) |
1207 @param clean flag indicating the clean state |
|
1208 @type bool |
1156 """ |
1209 """ |
1157 self.setDirty(not clean) |
1210 self.setDirty(not clean) |
1158 |
1211 |
1159 def shutdown(self): |
1212 def shutdown(self): |
1160 """ |
1213 """ |