eric7/IconEditor/IconEditorWindow.py

branch
eric7
changeset 8353
799196d0b05d
parent 8322
b422b4e77d19
child 8356
68ec9c3d4de5
equal deleted inserted replaced
8352:879dc528461f 8353:799196d0b05d
21 from E5Gui.E5Action import E5Action, createActionGroup 21 from E5Gui.E5Action import E5Action, createActionGroup
22 from E5Gui import E5FileDialog, E5MessageBox 22 from E5Gui import E5FileDialog, E5MessageBox
23 from E5Gui.E5MainWindow import E5MainWindow 23 from E5Gui.E5MainWindow import E5MainWindow
24 from E5Gui.E5ZoomWidget import E5ZoomWidget 24 from E5Gui.E5ZoomWidget import E5ZoomWidget
25 25
26 from .IconEditorGrid import IconEditorGrid 26 from .IconEditorGrid import IconEditorGrid, IconEditorTool
27 27
28 import UI.PixmapCache 28 import UI.PixmapCache
29 import UI.Config 29 import UI.Config
30 30
31 import Preferences 31 import Preferences
553 def __initToolsActions(self): 553 def __initToolsActions(self):
554 """ 554 """
555 Private method to create the View actions. 555 Private method to create the View actions.
556 """ 556 """
557 self.esm = QSignalMapper(self) 557 self.esm = QSignalMapper(self)
558 try: 558 self.esm.mappedInt.connect(self.__editor.setTool)
559 self.esm.mappedInt.connect(self.__editor.setTool)
560 except AttributeError:
561 # pre Qt 5.15
562 self.esm.mapped[int].connect(self.__editor.setTool)
563 559
564 self.drawingActGrp = createActionGroup(self) 560 self.drawingActGrp = createActionGroup(self)
565 self.drawingActGrp.setExclusive(True) 561 self.drawingActGrp.setExclusive(True)
566 562
567 self.drawPencilAct = E5Action( 563 self.drawPencilAct = E5Action(
573 self.drawPencilAct.setWhatsThis(self.tr( 569 self.drawPencilAct.setWhatsThis(self.tr(
574 """<b>Free hand</b>""" 570 """<b>Free hand</b>"""
575 """<p>Draws non linear lines.</p>""" 571 """<p>Draws non linear lines.</p>"""
576 )) 572 ))
577 self.drawPencilAct.setCheckable(True) 573 self.drawPencilAct.setCheckable(True)
578 self.esm.setMapping(self.drawPencilAct, IconEditorGrid.Pencil) 574 self.esm.setMapping(self.drawPencilAct, IconEditorTool.PENCIL)
579 self.drawPencilAct.triggered.connect(self.esm.map) 575 self.drawPencilAct.triggered.connect(self.esm.map)
580 self.__actions.append(self.drawPencilAct) 576 self.__actions.append(self.drawPencilAct)
581 577
582 self.drawColorPickerAct = E5Action( 578 self.drawColorPickerAct = E5Action(
583 self.tr('Color Picker'), 579 self.tr('Color Picker'),
590 """<p>The color of the pixel clicked on will become """ 586 """<p>The color of the pixel clicked on will become """
591 """the current draw color.</p>""" 587 """the current draw color.</p>"""
592 )) 588 ))
593 self.drawColorPickerAct.setCheckable(True) 589 self.drawColorPickerAct.setCheckable(True)
594 self.esm.setMapping(self.drawColorPickerAct, 590 self.esm.setMapping(self.drawColorPickerAct,
595 IconEditorGrid.ColorPicker) 591 IconEditorTool.COLOR_PICKER)
596 self.drawColorPickerAct.triggered.connect(self.esm.map) 592 self.drawColorPickerAct.triggered.connect(self.esm.map)
597 self.__actions.append(self.drawColorPickerAct) 593 self.__actions.append(self.drawColorPickerAct)
598 594
599 self.drawRectangleAct = E5Action( 595 self.drawRectangleAct = E5Action(
600 self.tr('Rectangle'), 596 self.tr('Rectangle'),
605 self.drawRectangleAct.setWhatsThis(self.tr( 601 self.drawRectangleAct.setWhatsThis(self.tr(
606 """<b>Rectangle</b>""" 602 """<b>Rectangle</b>"""
607 """<p>Draw a rectangle.</p>""" 603 """<p>Draw a rectangle.</p>"""
608 )) 604 ))
609 self.drawRectangleAct.setCheckable(True) 605 self.drawRectangleAct.setCheckable(True)
610 self.esm.setMapping(self.drawRectangleAct, IconEditorGrid.Rectangle) 606 self.esm.setMapping(self.drawRectangleAct, IconEditorTool.RECTANGLE)
611 self.drawRectangleAct.triggered.connect(self.esm.map) 607 self.drawRectangleAct.triggered.connect(self.esm.map)
612 self.__actions.append(self.drawRectangleAct) 608 self.__actions.append(self.drawRectangleAct)
613 609
614 self.drawFilledRectangleAct = E5Action( 610 self.drawFilledRectangleAct = E5Action(
615 self.tr('Filled Rectangle'), 611 self.tr('Filled Rectangle'),
621 """<b>Filled Rectangle</b>""" 617 """<b>Filled Rectangle</b>"""
622 """<p>Draw a filled rectangle.</p>""" 618 """<p>Draw a filled rectangle.</p>"""
623 )) 619 ))
624 self.drawFilledRectangleAct.setCheckable(True) 620 self.drawFilledRectangleAct.setCheckable(True)
625 self.esm.setMapping(self.drawFilledRectangleAct, 621 self.esm.setMapping(self.drawFilledRectangleAct,
626 IconEditorGrid.FilledRectangle) 622 IconEditorTool.FILLED_RECTANGLE)
627 self.drawFilledRectangleAct.triggered.connect(self.esm.map) 623 self.drawFilledRectangleAct.triggered.connect(self.esm.map)
628 self.__actions.append(self.drawFilledRectangleAct) 624 self.__actions.append(self.drawFilledRectangleAct)
629 625
630 self.drawCircleAct = E5Action( 626 self.drawCircleAct = E5Action(
631 self.tr('Circle'), 627 self.tr('Circle'),
636 self.drawCircleAct.setWhatsThis(self.tr( 632 self.drawCircleAct.setWhatsThis(self.tr(
637 """<b>Circle</b>""" 633 """<b>Circle</b>"""
638 """<p>Draw a circle.</p>""" 634 """<p>Draw a circle.</p>"""
639 )) 635 ))
640 self.drawCircleAct.setCheckable(True) 636 self.drawCircleAct.setCheckable(True)
641 self.esm.setMapping(self.drawCircleAct, IconEditorGrid.Circle) 637 self.esm.setMapping(self.drawCircleAct, IconEditorTool.CIRCLE)
642 self.drawCircleAct.triggered.connect(self.esm.map) 638 self.drawCircleAct.triggered.connect(self.esm.map)
643 self.__actions.append(self.drawCircleAct) 639 self.__actions.append(self.drawCircleAct)
644 640
645 self.drawFilledCircleAct = E5Action( 641 self.drawFilledCircleAct = E5Action(
646 self.tr('Filled Circle'), 642 self.tr('Filled Circle'),
652 """<b>Filled Circle</b>""" 648 """<b>Filled Circle</b>"""
653 """<p>Draw a filled circle.</p>""" 649 """<p>Draw a filled circle.</p>"""
654 )) 650 ))
655 self.drawFilledCircleAct.setCheckable(True) 651 self.drawFilledCircleAct.setCheckable(True)
656 self.esm.setMapping(self.drawFilledCircleAct, 652 self.esm.setMapping(self.drawFilledCircleAct,
657 IconEditorGrid.FilledCircle) 653 IconEditorTool.FILLED_CIRCLE)
658 self.drawFilledCircleAct.triggered.connect(self.esm.map) 654 self.drawFilledCircleAct.triggered.connect(self.esm.map)
659 self.__actions.append(self.drawFilledCircleAct) 655 self.__actions.append(self.drawFilledCircleAct)
660 656
661 self.drawEllipseAct = E5Action( 657 self.drawEllipseAct = E5Action(
662 self.tr('Ellipse'), 658 self.tr('Ellipse'),
667 self.drawEllipseAct.setWhatsThis(self.tr( 663 self.drawEllipseAct.setWhatsThis(self.tr(
668 """<b>Ellipse</b>""" 664 """<b>Ellipse</b>"""
669 """<p>Draw an ellipse.</p>""" 665 """<p>Draw an ellipse.</p>"""
670 )) 666 ))
671 self.drawEllipseAct.setCheckable(True) 667 self.drawEllipseAct.setCheckable(True)
672 self.esm.setMapping(self.drawEllipseAct, IconEditorGrid.Ellipse) 668 self.esm.setMapping(self.drawEllipseAct, IconEditorTool.ELLIPSE)
673 self.drawEllipseAct.triggered.connect(self.esm.map) 669 self.drawEllipseAct.triggered.connect(self.esm.map)
674 self.__actions.append(self.drawEllipseAct) 670 self.__actions.append(self.drawEllipseAct)
675 671
676 self.drawFilledEllipseAct = E5Action( 672 self.drawFilledEllipseAct = E5Action(
677 self.tr('Filled Ellipse'), 673 self.tr('Filled Ellipse'),
683 """<b>Filled Ellipse</b>""" 679 """<b>Filled Ellipse</b>"""
684 """<p>Draw a filled ellipse.</p>""" 680 """<p>Draw a filled ellipse.</p>"""
685 )) 681 ))
686 self.drawFilledEllipseAct.setCheckable(True) 682 self.drawFilledEllipseAct.setCheckable(True)
687 self.esm.setMapping(self.drawFilledEllipseAct, 683 self.esm.setMapping(self.drawFilledEllipseAct,
688 IconEditorGrid.FilledEllipse) 684 IconEditorTool.FILLED_ELLIPSE)
689 self.drawFilledEllipseAct.triggered.connect(self.esm.map) 685 self.drawFilledEllipseAct.triggered.connect(self.esm.map)
690 self.__actions.append(self.drawFilledEllipseAct) 686 self.__actions.append(self.drawFilledEllipseAct)
691 687
692 self.drawFloodFillAct = E5Action( 688 self.drawFloodFillAct = E5Action(
693 self.tr('Flood Fill'), 689 self.tr('Flood Fill'),
699 """<b>Flood Fill</b>""" 695 """<b>Flood Fill</b>"""
700 """<p>Fill adjoining pixels with the same color with """ 696 """<p>Fill adjoining pixels with the same color with """
701 """the current color.</p>""" 697 """the current color.</p>"""
702 )) 698 ))
703 self.drawFloodFillAct.setCheckable(True) 699 self.drawFloodFillAct.setCheckable(True)
704 self.esm.setMapping(self.drawFloodFillAct, IconEditorGrid.Fill) 700 self.esm.setMapping(self.drawFloodFillAct, IconEditorTool.FILL)
705 self.drawFloodFillAct.triggered.connect(self.esm.map) 701 self.drawFloodFillAct.triggered.connect(self.esm.map)
706 self.__actions.append(self.drawFloodFillAct) 702 self.__actions.append(self.drawFloodFillAct)
707 703
708 self.drawLineAct = E5Action( 704 self.drawLineAct = E5Action(
709 self.tr('Line'), 705 self.tr('Line'),
714 self.drawLineAct.setWhatsThis(self.tr( 710 self.drawLineAct.setWhatsThis(self.tr(
715 """<b>Line</b>""" 711 """<b>Line</b>"""
716 """<p>Draw a line.</p>""" 712 """<p>Draw a line.</p>"""
717 )) 713 ))
718 self.drawLineAct.setCheckable(True) 714 self.drawLineAct.setCheckable(True)
719 self.esm.setMapping(self.drawLineAct, IconEditorGrid.Line) 715 self.esm.setMapping(self.drawLineAct, IconEditorTool.LINE)
720 self.drawLineAct.triggered.connect(self.esm.map) 716 self.drawLineAct.triggered.connect(self.esm.map)
721 self.__actions.append(self.drawLineAct) 717 self.__actions.append(self.drawLineAct)
722 718
723 self.drawEraserAct = E5Action( 719 self.drawEraserAct = E5Action(
724 self.tr('Eraser (Transparent)'), 720 self.tr('Eraser (Transparent)'),
729 self.drawEraserAct.setWhatsThis(self.tr( 725 self.drawEraserAct.setWhatsThis(self.tr(
730 """<b>Eraser (Transparent)</b>""" 726 """<b>Eraser (Transparent)</b>"""
731 """<p>Erase pixels by setting them to transparent.</p>""" 727 """<p>Erase pixels by setting them to transparent.</p>"""
732 )) 728 ))
733 self.drawEraserAct.setCheckable(True) 729 self.drawEraserAct.setCheckable(True)
734 self.esm.setMapping(self.drawEraserAct, IconEditorGrid.Rubber) 730 self.esm.setMapping(self.drawEraserAct, IconEditorTool.RUBBER)
735 self.drawEraserAct.triggered.connect(self.esm.map) 731 self.drawEraserAct.triggered.connect(self.esm.map)
736 self.__actions.append(self.drawEraserAct) 732 self.__actions.append(self.drawEraserAct)
737 733
738 self.drawRectangleSelectionAct = E5Action( 734 self.drawRectangleSelectionAct = E5Action(
739 self.tr('Rectangular Selection'), 735 self.tr('Rectangular Selection'),
746 """<p>Select a rectangular section of the icon using""" 742 """<p>Select a rectangular section of the icon using"""
747 """ the mouse.</p>""" 743 """ the mouse.</p>"""
748 )) 744 ))
749 self.drawRectangleSelectionAct.setCheckable(True) 745 self.drawRectangleSelectionAct.setCheckable(True)
750 self.esm.setMapping(self.drawRectangleSelectionAct, 746 self.esm.setMapping(self.drawRectangleSelectionAct,
751 IconEditorGrid.RectangleSelection) 747 IconEditorTool.SELECT_RECTANGLE)
752 self.drawRectangleSelectionAct.triggered.connect(self.esm.map) 748 self.drawRectangleSelectionAct.triggered.connect(self.esm.map)
753 self.__actions.append(self.drawRectangleSelectionAct) 749 self.__actions.append(self.drawRectangleSelectionAct)
754 750
755 self.drawCircleSelectionAct = E5Action( 751 self.drawCircleSelectionAct = E5Action(
756 self.tr('Circular Selection'), 752 self.tr('Circular Selection'),
763 """<p>Select a circular section of the icon using""" 759 """<p>Select a circular section of the icon using"""
764 """ the mouse.</p>""" 760 """ the mouse.</p>"""
765 )) 761 ))
766 self.drawCircleSelectionAct.setCheckable(True) 762 self.drawCircleSelectionAct.setCheckable(True)
767 self.esm.setMapping(self.drawCircleSelectionAct, 763 self.esm.setMapping(self.drawCircleSelectionAct,
768 IconEditorGrid.CircleSelection) 764 IconEditorTool.SELECT_CIRCLE)
769 self.drawCircleSelectionAct.triggered.connect(self.esm.map) 765 self.drawCircleSelectionAct.triggered.connect(self.esm.map)
770 self.__actions.append(self.drawCircleSelectionAct) 766 self.__actions.append(self.drawCircleSelectionAct)
771 767
772 self.drawPencilAct.setChecked(True) 768 self.drawPencilAct.trigger()
773 769
774 def __initHelpActions(self): 770 def __initHelpActions(self):
775 """ 771 """
776 Private method to create the Help actions. 772 Private method to create the Help actions.
777 """ 773 """

eric ide

mercurial