QScintilla/Editor.py

changeset 3190
a9a94491c4fd
parent 3169
7b1b754a60a6
child 3201
0f115f6db6cb
equal deleted inserted replaced
3189:9a21c547de5f 3190:a9a94491c4fd
312 if self.fileName is not None: 312 if self.fileName is not None:
313 if (QFileInfo(self.fileName).size() // 1024) > \ 313 if (QFileInfo(self.fileName).size() // 1024) > \
314 Preferences.getEditor("WarnFilesize"): 314 Preferences.getEditor("WarnFilesize"):
315 res = E5MessageBox.yesNo( 315 res = E5MessageBox.yesNo(
316 self, 316 self,
317 self.trUtf8("Open File"), 317 self.tr("Open File"),
318 self.trUtf8("""<p>The size of the file <b>{0}</b>""" 318 self.tr("""<p>The size of the file <b>{0}</b>"""
319 """ is <b>{1} KB</b>.""" 319 """ is <b>{1} KB</b>."""
320 """ Do you really want to load it?</p>""") 320 """ Do you really want to load it?</p>""")
321 .format(self.fileName, 321 .format(self.fileName,
322 QFileInfo(self.fileName).size() // 1024), 322 QFileInfo(self.fileName).size() // 1024),
323 icon=E5MessageBox.Warning) 323 icon=E5MessageBox.Warning)
324 if not res: 324 if not res:
325 raise IOError() 325 raise IOError()
364 # Make sure tabbing through a QWorkspace works. 364 # Make sure tabbing through a QWorkspace works.
365 self.setFocusPolicy(Qt.StrongFocus) 365 self.setFocusPolicy(Qt.StrongFocus)
366 366
367 self.__updateReadOnly(True) 367 self.__updateReadOnly(True)
368 368
369 self.setWhatsThis(self.trUtf8( 369 self.setWhatsThis(self.tr(
370 """<b>A Source Editor Window</b>""" 370 """<b>A Source Editor Window</b>"""
371 """<p>This window is used to display and edit a source file.""" 371 """<p>This window is used to display and edit a source file."""
372 """ You can open as many of these as you like. The name of the""" 372 """ You can open as many of these as you like. The name of the"""
373 """ file is displayed in the window's titlebar.</p>""" 373 """ file is displayed in the window's titlebar.</p>"""
374 """<p>In order to set breakpoints just click in the space""" 374 """<p>In order to set breakpoints just click in the space"""
618 self.encodingsMenu = self.__initContextMenuEncodings() 618 self.encodingsMenu = self.__initContextMenuEncodings()
619 self.__menus["Encodings"] = self.encodingsMenu 619 self.__menus["Encodings"] = self.encodingsMenu
620 620
621 self.menuActs["Undo"] = self.menu.addAction( 621 self.menuActs["Undo"] = self.menu.addAction(
622 UI.PixmapCache.getIcon("editUndo.png"), 622 UI.PixmapCache.getIcon("editUndo.png"),
623 self.trUtf8('Undo'), self.undo) 623 self.tr('Undo'), self.undo)
624 self.menuActs["Redo"] = self.menu.addAction( 624 self.menuActs["Redo"] = self.menu.addAction(
625 UI.PixmapCache.getIcon("editRedo.png"), 625 UI.PixmapCache.getIcon("editRedo.png"),
626 self.trUtf8('Redo'), self.redo) 626 self.tr('Redo'), self.redo)
627 self.menuActs["Revert"] = self.menu.addAction( 627 self.menuActs["Revert"] = self.menu.addAction(
628 self.trUtf8("Revert to last saved state"), 628 self.tr("Revert to last saved state"),
629 self.revertToUnmodified) 629 self.revertToUnmodified)
630 self.menu.addSeparator() 630 self.menu.addSeparator()
631 self.menuActs["Cut"] = self.menu.addAction( 631 self.menuActs["Cut"] = self.menu.addAction(
632 UI.PixmapCache.getIcon("editCut.png"), 632 UI.PixmapCache.getIcon("editCut.png"),
633 self.trUtf8('Cut'), self.cut) 633 self.tr('Cut'), self.cut)
634 self.menuActs["Copy"] = self.menu.addAction( 634 self.menuActs["Copy"] = self.menu.addAction(
635 UI.PixmapCache.getIcon("editCopy.png"), 635 UI.PixmapCache.getIcon("editCopy.png"),
636 self.trUtf8('Copy'), self.copy) 636 self.tr('Copy'), self.copy)
637 self.menu.addAction( 637 self.menu.addAction(
638 UI.PixmapCache.getIcon("editPaste.png"), 638 UI.PixmapCache.getIcon("editPaste.png"),
639 self.trUtf8('Paste'), self.paste) 639 self.tr('Paste'), self.paste)
640 if not self.miniMenu: 640 if not self.miniMenu:
641 self.menu.addSeparator() 641 self.menu.addSeparator()
642 self.menu.addAction( 642 self.menu.addAction(
643 UI.PixmapCache.getIcon("editIndent.png"), 643 UI.PixmapCache.getIcon("editIndent.png"),
644 self.trUtf8('Indent'), self.indentLineOrSelection) 644 self.tr('Indent'), self.indentLineOrSelection)
645 self.menu.addAction( 645 self.menu.addAction(
646 UI.PixmapCache.getIcon("editUnindent.png"), 646 UI.PixmapCache.getIcon("editUnindent.png"),
647 self.trUtf8('Unindent'), self.unindentLineOrSelection) 647 self.tr('Unindent'), self.unindentLineOrSelection)
648 self.menuActs["Comment"] = self.menu.addAction( 648 self.menuActs["Comment"] = self.menu.addAction(
649 UI.PixmapCache.getIcon("editComment.png"), 649 UI.PixmapCache.getIcon("editComment.png"),
650 self.trUtf8('Comment'), self.commentLineOrSelection) 650 self.tr('Comment'), self.commentLineOrSelection)
651 self.menuActs["Uncomment"] = self.menu.addAction( 651 self.menuActs["Uncomment"] = self.menu.addAction(
652 UI.PixmapCache.getIcon("editUncomment.png"), 652 UI.PixmapCache.getIcon("editUncomment.png"),
653 self.trUtf8('Uncomment'), self.uncommentLineOrSelection) 653 self.tr('Uncomment'), self.uncommentLineOrSelection)
654 self.menuActs["StreamComment"] = self.menu.addAction( 654 self.menuActs["StreamComment"] = self.menu.addAction(
655 self.trUtf8('Stream Comment'), 655 self.tr('Stream Comment'),
656 self.streamCommentLineOrSelection) 656 self.streamCommentLineOrSelection)
657 self.menuActs["BoxComment"] = self.menu.addAction( 657 self.menuActs["BoxComment"] = self.menu.addAction(
658 self.trUtf8('Box Comment'), 658 self.tr('Box Comment'),
659 self.boxCommentLineOrSelection) 659 self.boxCommentLineOrSelection)
660 self.menu.addSeparator() 660 self.menu.addSeparator()
661 self.menu.addAction( 661 self.menu.addAction(
662 self.trUtf8('Select to brace'), self.selectToMatchingBrace) 662 self.tr('Select to brace'), self.selectToMatchingBrace)
663 self.menu.addAction(self.trUtf8('Select all'), self.__selectAll) 663 self.menu.addAction(self.tr('Select all'), self.__selectAll)
664 self.menu.addAction( 664 self.menu.addAction(
665 self.trUtf8('Deselect all'), self.__deselectAll) 665 self.tr('Deselect all'), self.__deselectAll)
666 self.menu.addSeparator() 666 self.menu.addSeparator()
667 self.menuActs["SpellCheck"] = self.menu.addAction( 667 self.menuActs["SpellCheck"] = self.menu.addAction(
668 UI.PixmapCache.getIcon("spellchecking.png"), 668 UI.PixmapCache.getIcon("spellchecking.png"),
669 self.trUtf8('Check spelling...'), self.checkSpelling) 669 self.tr('Check spelling...'), self.checkSpelling)
670 self.menuActs["SpellCheckSelection"] = self.menu.addAction( 670 self.menuActs["SpellCheckSelection"] = self.menu.addAction(
671 UI.PixmapCache.getIcon("spellchecking.png"), 671 UI.PixmapCache.getIcon("spellchecking.png"),
672 self.trUtf8('Check spelling of selection...'), 672 self.tr('Check spelling of selection...'),
673 self.__checkSpellingSelection) 673 self.__checkSpellingSelection)
674 self.menuActs["SpellCheckRemove"] = self.menu.addAction( 674 self.menuActs["SpellCheckRemove"] = self.menu.addAction(
675 self.trUtf8("Remove from dictionary"), 675 self.tr("Remove from dictionary"),
676 self.__removeFromSpellingDictionary) 676 self.__removeFromSpellingDictionary)
677 self.menu.addSeparator() 677 self.menu.addSeparator()
678 self.menu.addAction( 678 self.menu.addAction(
679 self.trUtf8('Shorten empty lines'), self.shortenEmptyLines) 679 self.tr('Shorten empty lines'), self.shortenEmptyLines)
680 self.menu.addSeparator() 680 self.menu.addSeparator()
681 self.menuActs["Languages"] = self.menu.addMenu(self.languagesMenu) 681 self.menuActs["Languages"] = self.menu.addMenu(self.languagesMenu)
682 self.menuActs["Encodings"] = self.menu.addMenu(self.encodingsMenu) 682 self.menuActs["Encodings"] = self.menu.addMenu(self.encodingsMenu)
683 self.menuActs["Eol"] = self.menu.addMenu(self.eolMenu) 683 self.menuActs["Eol"] = self.menu.addMenu(self.eolMenu)
684 self.menu.addSeparator() 684 self.menu.addSeparator()
685 self.menuActs["MonospacedFont"] = self.menu.addAction( 685 self.menuActs["MonospacedFont"] = self.menu.addAction(
686 self.trUtf8("Use Monospaced Font"), 686 self.tr("Use Monospaced Font"),
687 self.handleMonospacedEnable) 687 self.handleMonospacedEnable)
688 self.menuActs["MonospacedFont"].setCheckable(True) 688 self.menuActs["MonospacedFont"].setCheckable(True)
689 self.menuActs["MonospacedFont"].setChecked(self.useMonospaced) 689 self.menuActs["MonospacedFont"].setChecked(self.useMonospaced)
690 self.menuActs["AutosaveEnable"] = self.menu.addAction( 690 self.menuActs["AutosaveEnable"] = self.menu.addAction(
691 self.trUtf8("Autosave enabled"), self.__autosaveEnable) 691 self.tr("Autosave enabled"), self.__autosaveEnable)
692 self.menuActs["AutosaveEnable"].setCheckable(True) 692 self.menuActs["AutosaveEnable"].setCheckable(True)
693 self.menuActs["AutosaveEnable"].setChecked(self.autosaveEnabled) 693 self.menuActs["AutosaveEnable"].setChecked(self.autosaveEnabled)
694 self.menuActs["TypingAidsEnabled"] = self.menu.addAction( 694 self.menuActs["TypingAidsEnabled"] = self.menu.addAction(
695 self.trUtf8("Typing aids enabled"), self.__toggleTypingAids) 695 self.tr("Typing aids enabled"), self.__toggleTypingAids)
696 self.menuActs["TypingAidsEnabled"].setCheckable(True) 696 self.menuActs["TypingAidsEnabled"].setCheckable(True)
697 self.menuActs["TypingAidsEnabled"].setEnabled( 697 self.menuActs["TypingAidsEnabled"].setEnabled(
698 self.completer is not None) 698 self.completer is not None)
699 self.menuActs["TypingAidsEnabled"].setChecked( 699 self.menuActs["TypingAidsEnabled"].setChecked(
700 self.completer is not None and self.completer.isEnabled()) 700 self.completer is not None and self.completer.isEnabled())
701 self.menuActs["AutoCompletionEnable"] = self.menu.addAction( 701 self.menuActs["AutoCompletionEnable"] = self.menu.addAction(
702 self.trUtf8("Autocompletion enabled"), 702 self.tr("Autocompletion enabled"),
703 self.__toggleAutoCompletionEnable) 703 self.__toggleAutoCompletionEnable)
704 self.menuActs["AutoCompletionEnable"].setCheckable(True) 704 self.menuActs["AutoCompletionEnable"].setCheckable(True)
705 self.menuActs["AutoCompletionEnable"].setChecked( 705 self.menuActs["AutoCompletionEnable"].setChecked(
706 self.autoCompletionThreshold() != -1) 706 self.autoCompletionThreshold() != -1)
707 if not self.isResourcesFile: 707 if not self.isResourcesFile:
718 self.menu.addSeparator() 718 self.menu.addSeparator()
719 self.menuActs["Tools"] = self.menu.addMenu(self.toolsMenu) 719 self.menuActs["Tools"] = self.menu.addMenu(self.toolsMenu)
720 self.menu.addSeparator() 720 self.menu.addSeparator()
721 self.menu.addAction( 721 self.menu.addAction(
722 UI.PixmapCache.getIcon("documentNewView.png"), 722 UI.PixmapCache.getIcon("documentNewView.png"),
723 self.trUtf8('New Document View'), self.__newView) 723 self.tr('New Document View'), self.__newView)
724 self.menuActs["NewSplit"] = self.menu.addAction( 724 self.menuActs["NewSplit"] = self.menu.addAction(
725 UI.PixmapCache.getIcon("splitVertical.png"), 725 UI.PixmapCache.getIcon("splitVertical.png"),
726 self.trUtf8('New Document View (with new split)'), 726 self.tr('New Document View (with new split)'),
727 self.__newViewNewSplit) 727 self.__newViewNewSplit)
728 self.menuActs["NewSplit"].setEnabled(self.vm.canSplit()) 728 self.menuActs["NewSplit"].setEnabled(self.vm.canSplit())
729 self.menu.addAction( 729 self.menu.addAction(
730 UI.PixmapCache.getIcon("close.png"), 730 UI.PixmapCache.getIcon("close.png"),
731 self.trUtf8('Close'), self.__contextClose) 731 self.tr('Close'), self.__contextClose)
732 self.menu.addSeparator() 732 self.menu.addSeparator()
733 self.menuActs["Save"] = self.menu.addAction( 733 self.menuActs["Save"] = self.menu.addAction(
734 UI.PixmapCache.getIcon("fileSave.png"), 734 UI.PixmapCache.getIcon("fileSave.png"),
735 self.trUtf8('Save'), self.__contextSave) 735 self.tr('Save'), self.__contextSave)
736 self.menu.addAction( 736 self.menu.addAction(
737 UI.PixmapCache.getIcon("fileSaveAs.png"), 737 UI.PixmapCache.getIcon("fileSaveAs.png"),
738 self.trUtf8('Save As...'), self.__contextSaveAs) 738 self.tr('Save As...'), self.__contextSaveAs)
739 if not self.miniMenu: 739 if not self.miniMenu:
740 self.menu.addMenu(self.exportersMenu) 740 self.menu.addMenu(self.exportersMenu)
741 self.menu.addSeparator() 741 self.menu.addSeparator()
742 self.menuActs["OpenRejections"] = self.menu.addAction( 742 self.menuActs["OpenRejections"] = self.menu.addAction(
743 self.trUtf8("Open 'rejection' file"), 743 self.tr("Open 'rejection' file"),
744 self.__contextOpenRejections) 744 self.__contextOpenRejections)
745 self.menu.addSeparator() 745 self.menu.addSeparator()
746 self.menu.addAction( 746 self.menu.addAction(
747 UI.PixmapCache.getIcon("printPreview.png"), 747 UI.PixmapCache.getIcon("printPreview.png"),
748 self.trUtf8("Print Preview"), self.printPreviewFile) 748 self.tr("Print Preview"), self.printPreviewFile)
749 self.menu.addAction( 749 self.menu.addAction(
750 UI.PixmapCache.getIcon("print.png"), 750 UI.PixmapCache.getIcon("print.png"),
751 self.trUtf8('Print'), self.printFile) 751 self.tr('Print'), self.printFile)
752 else: 752 else:
753 self.menuActs["OpenRejections"] = None 753 self.menuActs["OpenRejections"] = None
754 754
755 self.menu.aboutToShow.connect(self.__showContextMenu) 755 self.menu.aboutToShow.connect(self.__showContextMenu)
756 756
765 """ 765 """
766 Private method used to setup the Checks context sub menu. 766 Private method used to setup the Checks context sub menu.
767 767
768 @return reference to the generated menu (QMenu) 768 @return reference to the generated menu (QMenu)
769 """ 769 """
770 menu = QMenu(self.trUtf8('Autocomplete')) 770 menu = QMenu(self.tr('Autocomplete'))
771 771
772 self.menuActs["acDynamic"] = menu.addAction( 772 self.menuActs["acDynamic"] = menu.addAction(
773 self.trUtf8('dynamic'), self.autoComplete) 773 self.tr('dynamic'), self.autoComplete)
774 menu.addSeparator() 774 menu.addSeparator()
775 menu.addAction( 775 menu.addAction(
776 self.trUtf8('from Document'), self.autoCompleteFromDocument) 776 self.tr('from Document'), self.autoCompleteFromDocument)
777 self.menuActs["acAPI"] = menu.addAction( 777 self.menuActs["acAPI"] = menu.addAction(
778 self.trUtf8('from APIs'), self.autoCompleteFromAPIs) 778 self.tr('from APIs'), self.autoCompleteFromAPIs)
779 self.menuActs["acAPIDocument"] = menu.addAction( 779 self.menuActs["acAPIDocument"] = menu.addAction(
780 self.trUtf8('from Document and APIs'), self.autoCompleteFromAll) 780 self.tr('from Document and APIs'), self.autoCompleteFromAll)
781 menu.addSeparator() 781 menu.addSeparator()
782 self.menuActs["calltip"] = menu.addAction( 782 self.menuActs["calltip"] = menu.addAction(
783 self.trUtf8('Calltip'), self.callTip) 783 self.tr('Calltip'), self.callTip)
784 784
785 menu.aboutToShow.connect(self.__showContextMenuAutocompletion) 785 menu.aboutToShow.connect(self.__showContextMenuAutocompletion)
786 786
787 return menu 787 return menu
788 788
790 """ 790 """
791 Private method used to setup the Checks context sub menu. 791 Private method used to setup the Checks context sub menu.
792 792
793 @return reference to the generated menu (QMenu) 793 @return reference to the generated menu (QMenu)
794 """ 794 """
795 menu = QMenu(self.trUtf8('Check')) 795 menu = QMenu(self.tr('Check'))
796 menu.aboutToShow.connect(self.__showContextMenuChecks) 796 menu.aboutToShow.connect(self.__showContextMenuChecks)
797 return menu 797 return menu
798 798
799 def __initContextMenuTools(self): 799 def __initContextMenuTools(self):
800 """ 800 """
801 Private method used to setup the Tools context sub menu. 801 Private method used to setup the Tools context sub menu.
802 802
803 @return reference to the generated menu (QMenu) 803 @return reference to the generated menu (QMenu)
804 """ 804 """
805 menu = QMenu(self.trUtf8('Tools')) 805 menu = QMenu(self.tr('Tools'))
806 menu.aboutToShow.connect(self.__showContextMenuTools) 806 menu.aboutToShow.connect(self.__showContextMenuTools)
807 return menu 807 return menu
808 808
809 def __initContextMenuShow(self): 809 def __initContextMenuShow(self):
810 """ 810 """
811 Private method used to setup the Show context sub menu. 811 Private method used to setup the Show context sub menu.
812 812
813 @return reference to the generated menu (QMenu) 813 @return reference to the generated menu (QMenu)
814 """ 814 """
815 menu = QMenu(self.trUtf8('Show')) 815 menu = QMenu(self.tr('Show'))
816 816
817 menu.addAction(self.trUtf8('Code metrics...'), self.__showCodeMetrics) 817 menu.addAction(self.tr('Code metrics...'), self.__showCodeMetrics)
818 self.coverageMenuAct = menu.addAction( 818 self.coverageMenuAct = menu.addAction(
819 self.trUtf8('Code coverage...'), self.__showCodeCoverage) 819 self.tr('Code coverage...'), self.__showCodeCoverage)
820 self.coverageShowAnnotationMenuAct = menu.addAction( 820 self.coverageShowAnnotationMenuAct = menu.addAction(
821 self.trUtf8('Show code coverage annotations'), 821 self.tr('Show code coverage annotations'),
822 self.codeCoverageShowAnnotations) 822 self.codeCoverageShowAnnotations)
823 self.coverageHideAnnotationMenuAct = menu.addAction( 823 self.coverageHideAnnotationMenuAct = menu.addAction(
824 self.trUtf8('Hide code coverage annotations'), 824 self.tr('Hide code coverage annotations'),
825 self.__codeCoverageHideAnnotations) 825 self.__codeCoverageHideAnnotations)
826 self.profileMenuAct = menu.addAction( 826 self.profileMenuAct = menu.addAction(
827 self.trUtf8('Profile data...'), self.__showProfileData) 827 self.tr('Profile data...'), self.__showProfileData)
828 828
829 menu.aboutToShow.connect(self.__showContextMenuShow) 829 menu.aboutToShow.connect(self.__showContextMenuShow)
830 830
831 return menu 831 return menu
832 832
834 """ 834 """
835 Private method used to setup the diagrams context sub menu. 835 Private method used to setup the diagrams context sub menu.
836 836
837 @return reference to the generated menu (QMenu) 837 @return reference to the generated menu (QMenu)
838 """ 838 """
839 menu = QMenu(self.trUtf8('Diagrams')) 839 menu = QMenu(self.tr('Diagrams'))
840 840
841 menu.addAction( 841 menu.addAction(
842 self.trUtf8('Class Diagram...'), self.__showClassDiagram) 842 self.tr('Class Diagram...'), self.__showClassDiagram)
843 menu.addAction( 843 menu.addAction(
844 self.trUtf8('Package Diagram...'), self.__showPackageDiagram) 844 self.tr('Package Diagram...'), self.__showPackageDiagram)
845 menu.addAction( 845 menu.addAction(
846 self.trUtf8('Imports Diagram...'), self.__showImportsDiagram) 846 self.tr('Imports Diagram...'), self.__showImportsDiagram)
847 self.applicationDiagramMenuAct = menu.addAction( 847 self.applicationDiagramMenuAct = menu.addAction(
848 self.trUtf8('Application Diagram...'), 848 self.tr('Application Diagram...'),
849 self.__showApplicationDiagram) 849 self.__showApplicationDiagram)
850 menu.addSeparator() 850 menu.addSeparator()
851 menu.addAction( 851 menu.addAction(
852 UI.PixmapCache.getIcon("open.png"), 852 UI.PixmapCache.getIcon("open.png"),
853 self.trUtf8("Load Diagram..."), self.__loadDiagram) 853 self.tr("Load Diagram..."), self.__loadDiagram)
854 854
855 menu.aboutToShow.connect(self.__showContextMenuGraphics) 855 menu.aboutToShow.connect(self.__showContextMenuGraphics)
856 856
857 return menu 857 return menu
858 858
860 """ 860 """
861 Private method used to setup the Languages context sub menu. 861 Private method used to setup the Languages context sub menu.
862 862
863 @return reference to the generated menu (QMenu) 863 @return reference to the generated menu (QMenu)
864 """ 864 """
865 menu = QMenu(self.trUtf8("Languages")) 865 menu = QMenu(self.tr("Languages"))
866 866
867 self.languagesActGrp = QActionGroup(self) 867 self.languagesActGrp = QActionGroup(self)
868 self.noLanguageAct = menu.addAction(self.trUtf8("No Language")) 868 self.noLanguageAct = menu.addAction(self.tr("No Language"))
869 self.noLanguageAct.setCheckable(True) 869 self.noLanguageAct.setCheckable(True)
870 self.noLanguageAct.setData("None") 870 self.noLanguageAct.setData("None")
871 self.languagesActGrp.addAction(self.noLanguageAct) 871 self.languagesActGrp.addAction(self.noLanguageAct)
872 menu.addSeparator() 872 menu.addSeparator()
873 873
886 act.setData(language) 886 act.setData(language)
887 self.supportedLanguages[language].append(act) 887 self.supportedLanguages[language].append(act)
888 self.languagesActGrp.addAction(act) 888 self.languagesActGrp.addAction(act)
889 889
890 menu.addSeparator() 890 menu.addSeparator()
891 self.pygmentsAct = menu.addAction(self.trUtf8("Guessed")) 891 self.pygmentsAct = menu.addAction(self.tr("Guessed"))
892 self.pygmentsAct.setCheckable(True) 892 self.pygmentsAct.setCheckable(True)
893 self.pygmentsAct.setData("Guessed") 893 self.pygmentsAct.setData("Guessed")
894 self.languagesActGrp.addAction(self.pygmentsAct) 894 self.languagesActGrp.addAction(self.pygmentsAct)
895 self.pygmentsSelAct = menu.addAction(self.trUtf8("Alternatives")) 895 self.pygmentsSelAct = menu.addAction(self.tr("Alternatives"))
896 self.pygmentsSelAct.setData("Alternatives") 896 self.pygmentsSelAct.setData("Alternatives")
897 897
898 menu.triggered.connect(self.__languageMenuTriggered) 898 menu.triggered.connect(self.__languageMenuTriggered)
899 menu.aboutToShow.connect(self.__showContextMenuLanguages) 899 menu.aboutToShow.connect(self.__showContextMenuLanguages)
900 900
906 906
907 @return reference to the generated menu (QMenu) 907 @return reference to the generated menu (QMenu)
908 """ 908 """
909 self.supportedEncodings = {} 909 self.supportedEncodings = {}
910 910
911 menu = QMenu(self.trUtf8("Encodings")) 911 menu = QMenu(self.tr("Encodings"))
912 912
913 self.encodingsActGrp = QActionGroup(self) 913 self.encodingsActGrp = QActionGroup(self)
914 914
915 for encoding in sorted(Utilities.supportedCodecs): 915 for encoding in sorted(Utilities.supportedCodecs):
916 act = menu.addAction(encoding) 916 act = menu.addAction(encoding)
930 930
931 @return reference to the generated menu (QMenu) 931 @return reference to the generated menu (QMenu)
932 """ 932 """
933 self.supportedEols = {} 933 self.supportedEols = {}
934 934
935 menu = QMenu(self.trUtf8("End-of-Line Type")) 935 menu = QMenu(self.tr("End-of-Line Type"))
936 936
937 self.eolActGrp = QActionGroup(self) 937 self.eolActGrp = QActionGroup(self)
938 938
939 act = menu.addAction(UI.PixmapCache.getIcon("eolLinux.png"), 939 act = menu.addAction(UI.PixmapCache.getIcon("eolLinux.png"),
940 self.trUtf8("Unix")) 940 self.tr("Unix"))
941 act.setCheckable(True) 941 act.setCheckable(True)
942 act.setData('\n') 942 act.setData('\n')
943 self.supportedEols['\n'] = act 943 self.supportedEols['\n'] = act
944 self.eolActGrp.addAction(act) 944 self.eolActGrp.addAction(act)
945 945
946 act = menu.addAction(UI.PixmapCache.getIcon("eolWindows.png"), 946 act = menu.addAction(UI.PixmapCache.getIcon("eolWindows.png"),
947 self.trUtf8("Windows")) 947 self.tr("Windows"))
948 act.setCheckable(True) 948 act.setCheckable(True)
949 act.setData('\r\n') 949 act.setData('\r\n')
950 self.supportedEols['\r\n'] = act 950 self.supportedEols['\r\n'] = act
951 self.eolActGrp.addAction(act) 951 self.eolActGrp.addAction(act)
952 952
953 act = menu.addAction(UI.PixmapCache.getIcon("eolMac.png"), 953 act = menu.addAction(UI.PixmapCache.getIcon("eolMac.png"),
954 self.trUtf8("Macintosh")) 954 self.tr("Macintosh"))
955 act.setCheckable(True) 955 act.setCheckable(True)
956 act.setData('\r') 956 act.setData('\r')
957 self.supportedEols['\r'] = act 957 self.supportedEols['\r'] = act
958 self.eolActGrp.addAction(act) 958 self.eolActGrp.addAction(act)
959 959
966 """ 966 """
967 Private method used to setup the Exporters context sub menu. 967 Private method used to setup the Exporters context sub menu.
968 968
969 @return reference to the generated menu (QMenu) 969 @return reference to the generated menu (QMenu)
970 """ 970 """
971 menu = QMenu(self.trUtf8("Export as")) 971 menu = QMenu(self.tr("Export as"))
972 972
973 from . import Exporters 973 from . import Exporters
974 supportedExporters = Exporters.getSupportedFormats() 974 supportedExporters = Exporters.getSupportedFormats()
975 exporters = sorted(list(supportedExporters.keys())) 975 exporters = sorted(list(supportedExporters.keys()))
976 for exporter in exporters: 976 for exporter in exporters:
999 """ 999 """
1000 # bookmark margin 1000 # bookmark margin
1001 self.bmMarginMenu = QMenu() 1001 self.bmMarginMenu = QMenu()
1002 1002
1003 self.bmMarginMenu.addAction( 1003 self.bmMarginMenu.addAction(
1004 self.trUtf8('Toggle bookmark'), self.menuToggleBookmark) 1004 self.tr('Toggle bookmark'), self.menuToggleBookmark)
1005 self.marginMenuActs["NextBookmark"] = self.bmMarginMenu.addAction( 1005 self.marginMenuActs["NextBookmark"] = self.bmMarginMenu.addAction(
1006 self.trUtf8('Next bookmark'), self.nextBookmark) 1006 self.tr('Next bookmark'), self.nextBookmark)
1007 self.marginMenuActs["PreviousBookmark"] = self.bmMarginMenu.addAction( 1007 self.marginMenuActs["PreviousBookmark"] = self.bmMarginMenu.addAction(
1008 self.trUtf8('Previous bookmark'), self.previousBookmark) 1008 self.tr('Previous bookmark'), self.previousBookmark)
1009 self.marginMenuActs["ClearBookmark"] = self.bmMarginMenu.addAction( 1009 self.marginMenuActs["ClearBookmark"] = self.bmMarginMenu.addAction(
1010 self.trUtf8('Clear all bookmarks'), self.clearBookmarks) 1010 self.tr('Clear all bookmarks'), self.clearBookmarks)
1011 1011
1012 self.bmMarginMenu.aboutToShow.connect(self.__showContextMenuMargin) 1012 self.bmMarginMenu.aboutToShow.connect(self.__showContextMenuMargin)
1013 1013
1014 # breakpoint margin 1014 # breakpoint margin
1015 self.bpMarginMenu = QMenu() 1015 self.bpMarginMenu = QMenu()
1016 1016
1017 self.marginMenuActs["Breakpoint"] = self.bpMarginMenu.addAction( 1017 self.marginMenuActs["Breakpoint"] = self.bpMarginMenu.addAction(
1018 self.trUtf8('Toggle breakpoint'), self.menuToggleBreakpoint) 1018 self.tr('Toggle breakpoint'), self.menuToggleBreakpoint)
1019 self.marginMenuActs["TempBreakpoint"] = self.bpMarginMenu.addAction( 1019 self.marginMenuActs["TempBreakpoint"] = self.bpMarginMenu.addAction(
1020 self.trUtf8('Toggle temporary breakpoint'), 1020 self.tr('Toggle temporary breakpoint'),
1021 self.__menuToggleTemporaryBreakpoint) 1021 self.__menuToggleTemporaryBreakpoint)
1022 self.marginMenuActs["EditBreakpoint"] = self.bpMarginMenu.addAction( 1022 self.marginMenuActs["EditBreakpoint"] = self.bpMarginMenu.addAction(
1023 self.trUtf8('Edit breakpoint...'), self.menuEditBreakpoint) 1023 self.tr('Edit breakpoint...'), self.menuEditBreakpoint)
1024 self.marginMenuActs["EnableBreakpoint"] = self.bpMarginMenu.addAction( 1024 self.marginMenuActs["EnableBreakpoint"] = self.bpMarginMenu.addAction(
1025 self.trUtf8('Enable breakpoint'), 1025 self.tr('Enable breakpoint'),
1026 self.__menuToggleBreakpointEnabled) 1026 self.__menuToggleBreakpointEnabled)
1027 self.marginMenuActs["NextBreakpoint"] = self.bpMarginMenu.addAction( 1027 self.marginMenuActs["NextBreakpoint"] = self.bpMarginMenu.addAction(
1028 self.trUtf8('Next breakpoint'), self.menuNextBreakpoint) 1028 self.tr('Next breakpoint'), self.menuNextBreakpoint)
1029 self.marginMenuActs["PreviousBreakpoint"] = \ 1029 self.marginMenuActs["PreviousBreakpoint"] = \
1030 self.bpMarginMenu.addAction( 1030 self.bpMarginMenu.addAction(
1031 self.trUtf8('Previous breakpoint'), 1031 self.tr('Previous breakpoint'),
1032 self.menuPreviousBreakpoint) 1032 self.menuPreviousBreakpoint)
1033 self.marginMenuActs["ClearBreakpoint"] = self.bpMarginMenu.addAction( 1033 self.marginMenuActs["ClearBreakpoint"] = self.bpMarginMenu.addAction(
1034 self.trUtf8('Clear all breakpoints'), self.__menuClearBreakpoints) 1034 self.tr('Clear all breakpoints'), self.__menuClearBreakpoints)
1035 1035
1036 self.bpMarginMenu.aboutToShow.connect(self.__showContextMenuMargin) 1036 self.bpMarginMenu.aboutToShow.connect(self.__showContextMenuMargin)
1037 1037
1038 # indicator margin 1038 # indicator margin
1039 self.indicMarginMenu = QMenu() 1039 self.indicMarginMenu = QMenu()
1040 1040
1041 self.marginMenuActs["GotoSyntaxError"] = \ 1041 self.marginMenuActs["GotoSyntaxError"] = \
1042 self.indicMarginMenu.addAction( 1042 self.indicMarginMenu.addAction(
1043 self.trUtf8('Goto syntax error'), self.gotoSyntaxError) 1043 self.tr('Goto syntax error'), self.gotoSyntaxError)
1044 self.marginMenuActs["ShowSyntaxError"] = \ 1044 self.marginMenuActs["ShowSyntaxError"] = \
1045 self.indicMarginMenu.addAction( 1045 self.indicMarginMenu.addAction(
1046 self.trUtf8('Show syntax error message'), 1046 self.tr('Show syntax error message'),
1047 self.__showSyntaxError) 1047 self.__showSyntaxError)
1048 self.marginMenuActs["ClearSyntaxError"] = \ 1048 self.marginMenuActs["ClearSyntaxError"] = \
1049 self.indicMarginMenu.addAction( 1049 self.indicMarginMenu.addAction(
1050 self.trUtf8('Clear syntax error'), self.clearSyntaxError) 1050 self.tr('Clear syntax error'), self.clearSyntaxError)
1051 self.indicMarginMenu.addSeparator() 1051 self.indicMarginMenu.addSeparator()
1052 self.marginMenuActs["NextWarningMarker"] = \ 1052 self.marginMenuActs["NextWarningMarker"] = \
1053 self.indicMarginMenu.addAction( 1053 self.indicMarginMenu.addAction(
1054 self.trUtf8("Next warning"), self.nextWarning) 1054 self.tr("Next warning"), self.nextWarning)
1055 self.marginMenuActs["PreviousWarningMarker"] = \ 1055 self.marginMenuActs["PreviousWarningMarker"] = \
1056 self.indicMarginMenu.addAction( 1056 self.indicMarginMenu.addAction(
1057 self.trUtf8("Previous warning"), self.previousWarning) 1057 self.tr("Previous warning"), self.previousWarning)
1058 self.marginMenuActs["ShowWarning"] = \ 1058 self.marginMenuActs["ShowWarning"] = \
1059 self.indicMarginMenu.addAction( 1059 self.indicMarginMenu.addAction(
1060 self.trUtf8('Show warning message'), self.__showWarning) 1060 self.tr('Show warning message'), self.__showWarning)
1061 self.marginMenuActs["ClearWarnings"] = \ 1061 self.marginMenuActs["ClearWarnings"] = \
1062 self.indicMarginMenu.addAction( 1062 self.indicMarginMenu.addAction(
1063 self.trUtf8('Clear warnings'), self.clearWarnings) 1063 self.tr('Clear warnings'), self.clearWarnings)
1064 self.indicMarginMenu.addSeparator() 1064 self.indicMarginMenu.addSeparator()
1065 self.marginMenuActs["NextCoverageMarker"] = \ 1065 self.marginMenuActs["NextCoverageMarker"] = \
1066 self.indicMarginMenu.addAction( 1066 self.indicMarginMenu.addAction(
1067 self.trUtf8('Next uncovered line'), self.nextUncovered) 1067 self.tr('Next uncovered line'), self.nextUncovered)
1068 self.marginMenuActs["PreviousCoverageMarker"] = \ 1068 self.marginMenuActs["PreviousCoverageMarker"] = \
1069 self.indicMarginMenu.addAction( 1069 self.indicMarginMenu.addAction(
1070 self.trUtf8('Previous uncovered line'), self.previousUncovered) 1070 self.tr('Previous uncovered line'), self.previousUncovered)
1071 self.indicMarginMenu.addSeparator() 1071 self.indicMarginMenu.addSeparator()
1072 self.marginMenuActs["NextTaskMarker"] = \ 1072 self.marginMenuActs["NextTaskMarker"] = \
1073 self.indicMarginMenu.addAction( 1073 self.indicMarginMenu.addAction(
1074 self.trUtf8('Next task'), self.nextTask) 1074 self.tr('Next task'), self.nextTask)
1075 self.marginMenuActs["PreviousTaskMarker"] = \ 1075 self.marginMenuActs["PreviousTaskMarker"] = \
1076 self.indicMarginMenu.addAction( 1076 self.indicMarginMenu.addAction(
1077 self.trUtf8('Previous task'), self.previousTask) 1077 self.tr('Previous task'), self.previousTask)
1078 self.indicMarginMenu.addSeparator() 1078 self.indicMarginMenu.addSeparator()
1079 self.marginMenuActs["NextChangeMarker"] = \ 1079 self.marginMenuActs["NextChangeMarker"] = \
1080 self.indicMarginMenu.addAction( 1080 self.indicMarginMenu.addAction(
1081 self.trUtf8('Next change'), self.nextChange) 1081 self.tr('Next change'), self.nextChange)
1082 self.marginMenuActs["PreviousChangeMarker"] = \ 1082 self.marginMenuActs["PreviousChangeMarker"] = \
1083 self.indicMarginMenu.addAction( 1083 self.indicMarginMenu.addAction(
1084 self.trUtf8('Previous change'), self.previousChange) 1084 self.tr('Previous change'), self.previousChange)
1085 1085
1086 self.indicMarginMenu.aboutToShow.connect(self.__showContextMenuMargin) 1086 self.indicMarginMenu.aboutToShow.connect(self.__showContextMenuMargin)
1087 1087
1088 def __initContextMenuUnifiedMargins(self): 1088 def __initContextMenuUnifiedMargins(self):
1089 """ 1089 """
1090 Private method used to setup the context menu for the unified margins. 1090 Private method used to setup the context menu for the unified margins.
1091 """ 1091 """
1092 self.marginMenu = QMenu() 1092 self.marginMenu = QMenu()
1093 1093
1094 self.marginMenu.addAction( 1094 self.marginMenu.addAction(
1095 self.trUtf8('Toggle bookmark'), self.menuToggleBookmark) 1095 self.tr('Toggle bookmark'), self.menuToggleBookmark)
1096 self.marginMenuActs["NextBookmark"] = self.marginMenu.addAction( 1096 self.marginMenuActs["NextBookmark"] = self.marginMenu.addAction(
1097 self.trUtf8('Next bookmark'), self.nextBookmark) 1097 self.tr('Next bookmark'), self.nextBookmark)
1098 self.marginMenuActs["PreviousBookmark"] = self.marginMenu.addAction( 1098 self.marginMenuActs["PreviousBookmark"] = self.marginMenu.addAction(
1099 self.trUtf8('Previous bookmark'), self.previousBookmark) 1099 self.tr('Previous bookmark'), self.previousBookmark)
1100 self.marginMenuActs["ClearBookmark"] = self.marginMenu.addAction( 1100 self.marginMenuActs["ClearBookmark"] = self.marginMenu.addAction(
1101 self.trUtf8('Clear all bookmarks'), self.clearBookmarks) 1101 self.tr('Clear all bookmarks'), self.clearBookmarks)
1102 self.marginMenu.addSeparator() 1102 self.marginMenu.addSeparator()
1103 self.marginMenuActs["GotoSyntaxError"] = self.marginMenu.addAction( 1103 self.marginMenuActs["GotoSyntaxError"] = self.marginMenu.addAction(
1104 self.trUtf8('Goto syntax error'), self.gotoSyntaxError) 1104 self.tr('Goto syntax error'), self.gotoSyntaxError)
1105 self.marginMenuActs["ShowSyntaxError"] = self.marginMenu.addAction( 1105 self.marginMenuActs["ShowSyntaxError"] = self.marginMenu.addAction(
1106 self.trUtf8('Show syntax error message'), self.__showSyntaxError) 1106 self.tr('Show syntax error message'), self.__showSyntaxError)
1107 self.marginMenuActs["ClearSyntaxError"] = self.marginMenu.addAction( 1107 self.marginMenuActs["ClearSyntaxError"] = self.marginMenu.addAction(
1108 self.trUtf8('Clear syntax error'), self.clearSyntaxError) 1108 self.tr('Clear syntax error'), self.clearSyntaxError)
1109 self.marginMenu.addSeparator() 1109 self.marginMenu.addSeparator()
1110 self.marginMenuActs["NextWarningMarker"] = self.marginMenu.addAction( 1110 self.marginMenuActs["NextWarningMarker"] = self.marginMenu.addAction(
1111 self.trUtf8("Next warning"), self.nextWarning) 1111 self.tr("Next warning"), self.nextWarning)
1112 self.marginMenuActs["PreviousWarningMarker"] = \ 1112 self.marginMenuActs["PreviousWarningMarker"] = \
1113 self.marginMenu.addAction( 1113 self.marginMenu.addAction(
1114 self.trUtf8("Previous warning"), self.previousWarning) 1114 self.tr("Previous warning"), self.previousWarning)
1115 self.marginMenuActs["ShowWarning"] = self.marginMenu.addAction( 1115 self.marginMenuActs["ShowWarning"] = self.marginMenu.addAction(
1116 self.trUtf8('Show warning message'), self.__showWarning) 1116 self.tr('Show warning message'), self.__showWarning)
1117 self.marginMenuActs["ClearWarnings"] = self.marginMenu.addAction( 1117 self.marginMenuActs["ClearWarnings"] = self.marginMenu.addAction(
1118 self.trUtf8('Clear warnings'), self.clearWarnings) 1118 self.tr('Clear warnings'), self.clearWarnings)
1119 self.marginMenu.addSeparator() 1119 self.marginMenu.addSeparator()
1120 self.marginMenuActs["Breakpoint"] = self.marginMenu.addAction( 1120 self.marginMenuActs["Breakpoint"] = self.marginMenu.addAction(
1121 self.trUtf8('Toggle breakpoint'), self.menuToggleBreakpoint) 1121 self.tr('Toggle breakpoint'), self.menuToggleBreakpoint)
1122 self.marginMenuActs["TempBreakpoint"] = self.marginMenu.addAction( 1122 self.marginMenuActs["TempBreakpoint"] = self.marginMenu.addAction(
1123 self.trUtf8('Toggle temporary breakpoint'), 1123 self.tr('Toggle temporary breakpoint'),
1124 self.__menuToggleTemporaryBreakpoint) 1124 self.__menuToggleTemporaryBreakpoint)
1125 self.marginMenuActs["EditBreakpoint"] = self.marginMenu.addAction( 1125 self.marginMenuActs["EditBreakpoint"] = self.marginMenu.addAction(
1126 self.trUtf8('Edit breakpoint...'), self.menuEditBreakpoint) 1126 self.tr('Edit breakpoint...'), self.menuEditBreakpoint)
1127 self.marginMenuActs["EnableBreakpoint"] = self.marginMenu.addAction( 1127 self.marginMenuActs["EnableBreakpoint"] = self.marginMenu.addAction(
1128 self.trUtf8('Enable breakpoint'), 1128 self.tr('Enable breakpoint'),
1129 self.__menuToggleBreakpointEnabled) 1129 self.__menuToggleBreakpointEnabled)
1130 self.marginMenuActs["NextBreakpoint"] = self.marginMenu.addAction( 1130 self.marginMenuActs["NextBreakpoint"] = self.marginMenu.addAction(
1131 self.trUtf8('Next breakpoint'), self.menuNextBreakpoint) 1131 self.tr('Next breakpoint'), self.menuNextBreakpoint)
1132 self.marginMenuActs["PreviousBreakpoint"] = self.marginMenu.addAction( 1132 self.marginMenuActs["PreviousBreakpoint"] = self.marginMenu.addAction(
1133 self.trUtf8('Previous breakpoint'), self.menuPreviousBreakpoint) 1133 self.tr('Previous breakpoint'), self.menuPreviousBreakpoint)
1134 self.marginMenuActs["ClearBreakpoint"] = self.marginMenu.addAction( 1134 self.marginMenuActs["ClearBreakpoint"] = self.marginMenu.addAction(
1135 self.trUtf8('Clear all breakpoints'), self.__menuClearBreakpoints) 1135 self.tr('Clear all breakpoints'), self.__menuClearBreakpoints)
1136 self.marginMenu.addSeparator() 1136 self.marginMenu.addSeparator()
1137 self.marginMenuActs["NextCoverageMarker"] = self.marginMenu.addAction( 1137 self.marginMenuActs["NextCoverageMarker"] = self.marginMenu.addAction(
1138 self.trUtf8('Next uncovered line'), self.nextUncovered) 1138 self.tr('Next uncovered line'), self.nextUncovered)
1139 self.marginMenuActs["PreviousCoverageMarker"] = \ 1139 self.marginMenuActs["PreviousCoverageMarker"] = \
1140 self.marginMenu.addAction( 1140 self.marginMenu.addAction(
1141 self.trUtf8('Previous uncovered line'), self.previousUncovered) 1141 self.tr('Previous uncovered line'), self.previousUncovered)
1142 self.marginMenu.addSeparator() 1142 self.marginMenu.addSeparator()
1143 self.marginMenuActs["NextTaskMarker"] = self.marginMenu.addAction( 1143 self.marginMenuActs["NextTaskMarker"] = self.marginMenu.addAction(
1144 self.trUtf8('Next task'), self.nextTask) 1144 self.tr('Next task'), self.nextTask)
1145 self.marginMenuActs["PreviousTaskMarker"] = self.marginMenu.addAction( 1145 self.marginMenuActs["PreviousTaskMarker"] = self.marginMenu.addAction(
1146 self.trUtf8('Previous task'), self.previousTask) 1146 self.tr('Previous task'), self.previousTask)
1147 self.marginMenu.addSeparator() 1147 self.marginMenu.addSeparator()
1148 self.marginMenuActs["NextChangeMarker"] = self.marginMenu.addAction( 1148 self.marginMenuActs["NextChangeMarker"] = self.marginMenu.addAction(
1149 self.trUtf8('Next change'), self.nextChange) 1149 self.tr('Next change'), self.nextChange)
1150 self.marginMenuActs["PreviousChangeMarker"] = \ 1150 self.marginMenuActs["PreviousChangeMarker"] = \
1151 self.marginMenu.addAction( 1151 self.marginMenu.addAction(
1152 self.trUtf8('Previous change'), self.previousChange) 1152 self.tr('Previous change'), self.previousChange)
1153 self.marginMenu.addSeparator() 1153 self.marginMenu.addSeparator()
1154 self.marginMenuActs["LMBbookmarks"] = self.marginMenu.addAction( 1154 self.marginMenuActs["LMBbookmarks"] = self.marginMenu.addAction(
1155 self.trUtf8('LMB toggles bookmarks'), self.__lmBbookmarks) 1155 self.tr('LMB toggles bookmarks'), self.__lmBbookmarks)
1156 self.marginMenuActs["LMBbookmarks"].setCheckable(True) 1156 self.marginMenuActs["LMBbookmarks"].setCheckable(True)
1157 self.marginMenuActs["LMBbookmarks"].setChecked(False) 1157 self.marginMenuActs["LMBbookmarks"].setChecked(False)
1158 self.marginMenuActs["LMBbreakpoints"] = self.marginMenu.addAction( 1158 self.marginMenuActs["LMBbreakpoints"] = self.marginMenu.addAction(
1159 self.trUtf8('LMB toggles breakpoints'), self.__lmBbreakpoints) 1159 self.tr('LMB toggles breakpoints'), self.__lmBbreakpoints)
1160 self.marginMenuActs["LMBbreakpoints"].setCheckable(True) 1160 self.marginMenuActs["LMBbreakpoints"].setCheckable(True)
1161 self.marginMenuActs["LMBbreakpoints"].setChecked(True) 1161 self.marginMenuActs["LMBbreakpoints"].setChecked(True)
1162 1162
1163 self.marginMenu.aboutToShow.connect(self.__showContextMenuMargin) 1163 self.marginMenu.aboutToShow.connect(self.__showContextMenuMargin)
1164 1164
1183 if exporter: 1183 if exporter:
1184 exporter.exportSource() 1184 exporter.exportSource()
1185 else: 1185 else:
1186 E5MessageBox.critical( 1186 E5MessageBox.critical(
1187 self, 1187 self,
1188 self.trUtf8("Export source"), 1188 self.tr("Export source"),
1189 self.trUtf8( 1189 self.tr(
1190 """<p>No exporter available for the """ 1190 """<p>No exporter available for the """
1191 """export format <b>{0}</b>. Aborting...</p>""") 1191 """export format <b>{0}</b>. Aborting...</p>""")
1192 .format(exporterFormat)) 1192 .format(exporterFormat))
1193 else: 1193 else:
1194 E5MessageBox.critical( 1194 E5MessageBox.critical(
1195 self, 1195 self,
1196 self.trUtf8("Export source"), 1196 self.tr("Export source"),
1197 self.trUtf8("""No export format given. Aborting...""")) 1197 self.tr("""No export format given. Aborting..."""))
1198 1198
1199 def __showContextMenuLanguages(self): 1199 def __showContextMenuLanguages(self):
1200 """ 1200 """
1201 Private slot handling the aboutToShow signal of the languages context 1201 Private slot handling the aboutToShow signal of the languages context
1202 menu. 1202 menu.
1203 """ 1203 """
1204 if self.apiLanguage.startswith("Pygments|"): 1204 if self.apiLanguage.startswith("Pygments|"):
1205 self.pygmentsSelAct.setText( 1205 self.pygmentsSelAct.setText(
1206 self.trUtf8("Alternatives ({0})").format( 1206 self.tr("Alternatives ({0})").format(
1207 self.getLanguage(normalized=False))) 1207 self.getLanguage(normalized=False)))
1208 else: 1208 else:
1209 self.pygmentsSelAct.setText(self.trUtf8("Alternatives")) 1209 self.pygmentsSelAct.setText(self.tr("Alternatives"))
1210 self.showMenu.emit("Languages", self.languagesMenu, self) 1210 self.showMenu.emit("Languages", self.languagesMenu, self)
1211 1211
1212 def __selectPygmentsLexer(self): 1212 def __selectPygmentsLexer(self):
1213 """ 1213 """
1214 Private method to select a specific pygments lexer. 1214 Private method to select a specific pygments lexer.
1222 self.getLanguage(normalized=False, forPygments=True)) 1222 self.getLanguage(normalized=False, forPygments=True))
1223 except ValueError: 1223 except ValueError:
1224 lexerSel = 0 1224 lexerSel = 0
1225 lexerName, ok = QInputDialog.getItem( 1225 lexerName, ok = QInputDialog.getItem(
1226 self, 1226 self,
1227 self.trUtf8("Pygments Lexer"), 1227 self.tr("Pygments Lexer"),
1228 self.trUtf8("Select the Pygments lexer to apply."), 1228 self.tr("Select the Pygments lexer to apply."),
1229 lexerList, 1229 lexerList,
1230 lexerSel, 1230 lexerSel,
1231 False) 1231 False)
1232 if ok and lexerName: 1232 if ok and lexerName:
1233 return lexerName 1233 return lexerName
1659 """ 1659 """
1660 Private slot to handle the modificationAttempted signal. 1660 Private slot to handle the modificationAttempted signal.
1661 """ 1661 """
1662 E5MessageBox.warning( 1662 E5MessageBox.warning(
1663 self, 1663 self,
1664 self.trUtf8("Modification of Read Only file"), 1664 self.tr("Modification of Read Only file"),
1665 self.trUtf8("""You are attempting to change a read only file. """ 1665 self.tr("""You are attempting to change a read only file. """
1666 """Please save to a different file first.""")) 1666 """Please save to a different file first."""))
1667 1667
1668 def setNoName(self, noName): 1668 def setNoName(self, noName):
1669 """ 1669 """
1670 Public method to set the display string for an unnamed editor. 1670 Public method to set the display string for an unnamed editor.
1671 1671
2353 sb = e5App().getObject("UserInterface").statusBar() 2353 sb = e5App().getObject("UserInterface").statusBar()
2354 printDialog = QPrintDialog(printer, self) 2354 printDialog = QPrintDialog(printer, self)
2355 if self.hasSelectedText(): 2355 if self.hasSelectedText():
2356 printDialog.addEnabledOption(QAbstractPrintDialog.PrintSelection) 2356 printDialog.addEnabledOption(QAbstractPrintDialog.PrintSelection)
2357 if printDialog.exec_() == QDialog.Accepted: 2357 if printDialog.exec_() == QDialog.Accepted:
2358 sb.showMessage(self.trUtf8('Printing...')) 2358 sb.showMessage(self.tr('Printing...'))
2359 QApplication.processEvents() 2359 QApplication.processEvents()
2360 fn = self.getFileName() 2360 fn = self.getFileName()
2361 if fn is not None: 2361 if fn is not None:
2362 printer.setDocName(os.path.basename(fn)) 2362 printer.setDocName(os.path.basename(fn))
2363 else: 2363 else:
2370 # Qscintilla seems to print one line more than told 2370 # Qscintilla seems to print one line more than told
2371 res = printer.printRange(self, fromLine, toLine - 1) 2371 res = printer.printRange(self, fromLine, toLine - 1)
2372 else: 2372 else:
2373 res = printer.printRange(self) 2373 res = printer.printRange(self)
2374 if res: 2374 if res:
2375 sb.showMessage(self.trUtf8('Printing completed'), 2000) 2375 sb.showMessage(self.tr('Printing completed'), 2000)
2376 else: 2376 else:
2377 sb.showMessage(self.trUtf8('Error while printing'), 2000) 2377 sb.showMessage(self.tr('Error while printing'), 2000)
2378 QApplication.processEvents() 2378 QApplication.processEvents()
2379 else: 2379 else:
2380 sb.showMessage(self.trUtf8('Printing aborted'), 2000) 2380 sb.showMessage(self.tr('Printing aborted'), 2000)
2381 QApplication.processEvents() 2381 QApplication.processEvents()
2382 2382
2383 def printPreviewFile(self): 2383 def printPreviewFile(self):
2384 """ 2384 """
2385 Public slot to show a print preview of the text. 2385 Public slot to show a print preview of the text.
2698 fn = self.fileName 2698 fn = self.fileName
2699 if fn is None: 2699 if fn is None:
2700 fn = self.noName 2700 fn = self.noName
2701 res = E5MessageBox.okToClearData( 2701 res = E5MessageBox.okToClearData(
2702 self, 2702 self,
2703 self.trUtf8("File Modified"), 2703 self.tr("File Modified"),
2704 self.trUtf8("<p>The file <b>{0}</b> has unsaved changes.</p>") 2704 self.tr("<p>The file <b>{0}</b> has unsaved changes.</p>")
2705 .format(fn), 2705 .format(fn),
2706 self.saveFile) 2706 self.saveFile)
2707 if res: 2707 if res:
2708 self.vm.setEditorName(self, self.fileName) 2708 self.vm.setEditorName(self, self.fileName)
2709 return res 2709 return res
2747 txt, self.encoding = Utilities.readEncodedFile(fn) 2747 txt, self.encoding = Utilities.readEncodedFile(fn)
2748 except (UnicodeDecodeError, IOError) as why: 2748 except (UnicodeDecodeError, IOError) as why:
2749 QApplication.restoreOverrideCursor() 2749 QApplication.restoreOverrideCursor()
2750 E5MessageBox.critical( 2750 E5MessageBox.critical(
2751 self.vm, 2751 self.vm,
2752 self.trUtf8('Open File'), 2752 self.tr('Open File'),
2753 self.trUtf8('<p>The file <b>{0}</b> could not be opened.</p>' 2753 self.tr('<p>The file <b>{0}</b> could not be opened.</p>'
2754 '<p>Reason: {1}</p>') 2754 '<p>Reason: {1}</p>')
2755 .format(fn, str(why))) 2755 .format(fn, str(why)))
2756 QApplication.restoreOverrideCursor() 2756 QApplication.restoreOverrideCursor()
2757 raise 2757 raise
2758 fileEol = self.detectEolString(txt) 2758 fileEol = self.detectEolString(txt)
2759 2759
2850 os.chmod(fn, permissions) 2850 os.chmod(fn, permissions)
2851 return True 2851 return True
2852 except (IOError, Utilities.CodingError, UnicodeError) as why: 2852 except (IOError, Utilities.CodingError, UnicodeError) as why:
2853 E5MessageBox.critical( 2853 E5MessageBox.critical(
2854 self, 2854 self,
2855 self.trUtf8('Save File'), 2855 self.tr('Save File'),
2856 self.trUtf8('<p>The file <b>{0}</b> could not be saved.<br/>' 2856 self.tr('<p>The file <b>{0}</b> could not be saved.<br/>'
2857 'Reason: {1}</p>') 2857 'Reason: {1}</p>')
2858 .format(fn, str(why))) 2858 .format(fn, str(why)))
2859 return False 2859 return False
2860 2860
2861 def saveFile(self, saveas=False, path=None): 2861 def saveFile(self, saveas=False, path=None):
2862 """ 2862 """
2899 defaultFilter = Preferences.getEditor("DefaultSaveFilter") 2899 defaultFilter = Preferences.getEditor("DefaultSaveFilter")
2900 else: 2900 else:
2901 defaultFilter = Preferences.getEditor("DefaultSaveFilter") 2901 defaultFilter = Preferences.getEditor("DefaultSaveFilter")
2902 fn, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( 2902 fn, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
2903 self, 2903 self,
2904 self.trUtf8("Save File"), 2904 self.tr("Save File"),
2905 path, 2905 path,
2906 Lexers.getSaveFileFiltersList(True, True), 2906 Lexers.getSaveFileFiltersList(True, True),
2907 defaultFilter, 2907 defaultFilter,
2908 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) 2908 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
2909 2909
2917 if ex: 2917 if ex:
2918 fn += ex 2918 fn += ex
2919 if QFileInfo(fn).exists(): 2919 if QFileInfo(fn).exists():
2920 res = E5MessageBox.yesNo( 2920 res = E5MessageBox.yesNo(
2921 self, 2921 self,
2922 self.trUtf8("Save File"), 2922 self.tr("Save File"),
2923 self.trUtf8("<p>The file <b>{0}</b> already exists." 2923 self.tr("<p>The file <b>{0}</b> already exists."
2924 " Overwrite it?</p>").format(fn), 2924 " Overwrite it?</p>").format(fn),
2925 icon=E5MessageBox.Warning) 2925 icon=E5MessageBox.Warning)
2926 if not res: 2926 if not res:
2927 return False 2927 return False
2928 fn = Utilities.toNativeSeparators(fn) 2928 fn = Utilities.toNativeSeparators(fn)
2929 newName = fn 2929 newName = fn
4224 elif acs == QsciScintilla.AcsAll: 4224 elif acs == QsciScintilla.AcsAll:
4225 self.autoCompleteFromAll() 4225 self.autoCompleteFromAll()
4226 else: 4226 else:
4227 E5MessageBox.information( 4227 E5MessageBox.information(
4228 self, 4228 self,
4229 self.trUtf8("Autocompletion"), 4229 self.tr("Autocompletion"),
4230 self.trUtf8( 4230 self.tr(
4231 """Autocompletion is not available because""" 4231 """Autocompletion is not available because"""
4232 """ there is no autocompletion source set.""")) 4232 """ there is no autocompletion source set."""))
4233 4233
4234 def setAutoCompletionEnabled(self, enable): 4234 def setAutoCompletionEnabled(self, enable):
4235 """ 4235 """
4325 """ 4325 """
4326 if self.__acHookFunction is not None: 4326 if self.__acHookFunction is not None:
4327 # there is another provider registered already 4327 # there is another provider registered already
4328 E5MessageBox.warning( 4328 E5MessageBox.warning(
4329 self, 4329 self,
4330 self.trUtf8("Activating Auto-Completion Provider"), 4330 self.tr("Activating Auto-Completion Provider"),
4331 self.trUtf8("""Auto-completion provider cannot be connected""" 4331 self.tr("""Auto-completion provider cannot be connected"""
4332 """ because there is already another one active.""" 4332 """ because there is already another one active."""
4333 """ Please check your configuration.""")) 4333 """ Please check your configuration."""))
4334 return 4334 return
4335 4335
4336 if self.autoCompletionThreshold() > 0: 4336 if self.autoCompletionThreshold() > 0:
4337 self.setAutoCompletionThreshold(0) 4337 self.setAutoCompletionThreshold(0)
4338 self.__acHookFunction = func 4338 self.__acHookFunction = func
4515 """ 4515 """
4516 if self.__ctHookFunction is not None: 4516 if self.__ctHookFunction is not None:
4517 # there is another provider registered already 4517 # there is another provider registered already
4518 E5MessageBox.warning( 4518 E5MessageBox.warning(
4519 self, 4519 self,
4520 self.trUtf8("Activating Calltip Provider"), 4520 self.tr("Activating Calltip Provider"),
4521 self.trUtf8("""Calltip provider cannot be connected""" 4521 self.tr("""Calltip provider cannot be connected"""
4522 """ because there is already another one active.""" 4522 """ because there is already another one active."""
4523 """ Please check your configuration.""")) 4523 """ Please check your configuration."""))
4524 return 4524 return
4525 4525
4526 self.__ctHookFunction = func 4526 self.__ctHookFunction = func
4527 4527
4528 def unsetCallTipHook(self): 4528 def unsetCallTipHook(self):
4749 else: 4749 else:
4750 self.marginMenuActs["EditBreakpoint"].setEnabled(False) 4750 self.marginMenuActs["EditBreakpoint"].setEnabled(False)
4751 self.marginMenuActs["EnableBreakpoint"].setEnabled(False) 4751 self.marginMenuActs["EnableBreakpoint"].setEnabled(False)
4752 if self.markersAtLine(self.line) & (1 << self.dbreakpoint): 4752 if self.markersAtLine(self.line) & (1 << self.dbreakpoint):
4753 self.marginMenuActs["EnableBreakpoint"].setText( 4753 self.marginMenuActs["EnableBreakpoint"].setText(
4754 self.trUtf8('Enable breakpoint')) 4754 self.tr('Enable breakpoint'))
4755 else: 4755 else:
4756 self.marginMenuActs["EnableBreakpoint"].setText( 4756 self.marginMenuActs["EnableBreakpoint"].setText(
4757 self.trUtf8('Disable breakpoint')) 4757 self.tr('Disable breakpoint'))
4758 if self.breaks: 4758 if self.breaks:
4759 self.marginMenuActs["NextBreakpoint"].setEnabled(True) 4759 self.marginMenuActs["NextBreakpoint"].setEnabled(True)
4760 self.marginMenuActs["PreviousBreakpoint"].setEnabled(True) 4760 self.marginMenuActs["PreviousBreakpoint"].setEnabled(True)
4761 self.marginMenuActs["ClearBreakpoint"].setEnabled(True) 4761 self.marginMenuActs["ClearBreakpoint"].setEnabled(True)
4762 else: 4762 else:
5107 5107
5108 if files: 5108 if files:
5109 if len(files) > 1: 5109 if len(files) > 1:
5110 fn, ok = QInputDialog.getItem( 5110 fn, ok = QInputDialog.getItem(
5111 self, 5111 self,
5112 self.trUtf8("Code Coverage"), 5112 self.tr("Code Coverage"),
5113 self.trUtf8("Please select a coverage file"), 5113 self.tr("Please select a coverage file"),
5114 files, 5114 files,
5115 0, False) 5115 0, False)
5116 if not ok: 5116 if not ok:
5117 return 5117 return
5118 else: 5118 else:
5163 self.coverageMarkersShown.emit(True) 5163 self.coverageMarkersShown.emit(True)
5164 else: 5164 else:
5165 if not silent: 5165 if not silent:
5166 E5MessageBox.information( 5166 E5MessageBox.information(
5167 self, 5167 self,
5168 self.trUtf8("Show Code Coverage Annotations"), 5168 self.tr("Show Code Coverage Annotations"),
5169 self.trUtf8("""All lines have been covered.""")) 5169 self.tr("""All lines have been covered."""))
5170 self.showingNotcoveredMarkers = True 5170 self.showingNotcoveredMarkers = True
5171 else: 5171 else:
5172 if not silent: 5172 if not silent:
5173 E5MessageBox.warning( 5173 E5MessageBox.warning(
5174 self, 5174 self,
5175 self.trUtf8("Show Code Coverage Annotations"), 5175 self.tr("Show Code Coverage Annotations"),
5176 self.trUtf8("""There is no coverage file available.""")) 5176 self.tr("""There is no coverage file available."""))
5177 5177
5178 def __codeCoverageHideAnnotations(self): 5178 def __codeCoverageHideAnnotations(self):
5179 """ 5179 """
5180 Private method to handle the hide code coverage annotations context 5180 Private method to handle the hide code coverage annotations context
5181 menu action. 5181 menu action.
5268 5268
5269 if files: 5269 if files:
5270 if len(files) > 1: 5270 if len(files) > 1:
5271 fn, ok = QInputDialog.getItem( 5271 fn, ok = QInputDialog.getItem(
5272 self, 5272 self,
5273 self.trUtf8("Profile Data"), 5273 self.tr("Profile Data"),
5274 self.trUtf8("Please select a profile file"), 5274 self.tr("Please select a profile file"),
5275 files, 5275 files,
5276 0, False) 5276 0, False)
5277 if not ok: 5277 if not ok:
5278 return 5278 return
5279 else: 5279 else:
5405 for handle in list(self.syntaxerrors.keys()): 5405 for handle in list(self.syntaxerrors.keys()):
5406 if self.markerLine(handle) == line: 5406 if self.markerLine(handle) == line:
5407 errors = [e[0] for e in self.syntaxerrors[handle]] 5407 errors = [e[0] for e in self.syntaxerrors[handle]]
5408 E5MessageBox.critical( 5408 E5MessageBox.critical(
5409 self, 5409 self,
5410 self.trUtf8("Syntax Error"), 5410 self.tr("Syntax Error"),
5411 "\n".join(errors)) 5411 "\n".join(errors))
5412 break 5412 break
5413 else: 5413 else:
5414 E5MessageBox.critical( 5414 E5MessageBox.critical(
5415 self, 5415 self,
5416 self.trUtf8("Syntax Error"), 5416 self.tr("Syntax Error"),
5417 self.trUtf8("No syntax error message available.")) 5417 self.tr("No syntax error message available."))
5418 5418
5419 ########################################################################### 5419 ###########################################################################
5420 ## Warning handling methods below 5420 ## Warning handling methods below
5421 ########################################################################### 5421 ###########################################################################
5422 5422
5574 5574
5575 for handle in list(self.warnings.keys()): 5575 for handle in list(self.warnings.keys()):
5576 if self.markerLine(handle) == line: 5576 if self.markerLine(handle) == line:
5577 E5MessageBox.warning( 5577 E5MessageBox.warning(
5578 self, 5578 self,
5579 self.trUtf8("Warning"), 5579 self.tr("Warning"),
5580 '\n'.join([w[0] for w in self.warnings[handle]])) 5580 '\n'.join([w[0] for w in self.warnings[handle]]))
5581 break 5581 break
5582 else: 5582 else:
5583 E5MessageBox.warning( 5583 E5MessageBox.warning(
5584 self, 5584 self,
5585 self.trUtf8("Warning"), 5585 self.tr("Warning"),
5586 self.trUtf8("No warning messages available.")) 5586 self.tr("No warning messages available."))
5587 5587
5588 ########################################################################### 5588 ###########################################################################
5589 ## Annotation handling methods below 5589 ## Annotation handling methods below
5590 ########################################################################### 5590 ###########################################################################
5591 5591
5640 for handle in self.warnings.keys(): 5640 for handle in self.warnings.keys():
5641 if self.markerLine(handle) == line: 5641 if self.markerLine(handle) == line:
5642 for msg, warningType in self.warnings[handle]: 5642 for msg, warningType in self.warnings[handle]:
5643 if warningType == self.WarningStyle: 5643 if warningType == self.WarningStyle:
5644 styleAnnotations.append( 5644 styleAnnotations.append(
5645 self.trUtf8("Style: {0}").format(msg)) 5645 self.tr("Style: {0}").format(msg))
5646 else: 5646 else:
5647 warningAnnotations.append( 5647 warningAnnotations.append(
5648 self.trUtf8("Warning: {0}").format(msg)) 5648 self.tr("Warning: {0}").format(msg))
5649 5649
5650 # step 2: do syntax errors 5650 # step 2: do syntax errors
5651 for handle in self.syntaxerrors.keys(): 5651 for handle in self.syntaxerrors.keys():
5652 if self.markerLine(handle) == line: 5652 if self.markerLine(handle) == line:
5653 for msg, _ in self.syntaxerrors[handle]: 5653 for msg, _ in self.syntaxerrors[handle]:
5654 errorAnnotations.append( 5654 errorAnnotations.append(
5655 self.trUtf8("Error: {0}").format(msg)) 5655 self.tr("Error: {0}").format(msg))
5656 5656
5657 annotations = [] 5657 annotations = []
5658 if styleAnnotations: 5658 if styleAnnotations:
5659 annotationStyleTxt = "\n".join(styleAnnotations) 5659 annotationStyleTxt = "\n".join(styleAnnotations)
5660 if warningAnnotations or errorAnnotations: 5660 if warningAnnotations or errorAnnotations:
5705 for s in list(self.macros.keys()): 5705 for s in list(self.macros.keys()):
5706 qs.append(s) 5706 qs.append(s)
5707 qs.sort() 5707 qs.sort()
5708 return QInputDialog.getItem( 5708 return QInputDialog.getItem(
5709 self, 5709 self,
5710 self.trUtf8("Macro Name"), 5710 self.tr("Macro Name"),
5711 self.trUtf8("Select a macro name:"), 5711 self.tr("Select a macro name:"),
5712 qs, 5712 qs,
5713 0, False) 5713 0, False)
5714 5714
5715 def macroRun(self): 5715 def macroRun(self):
5716 """ 5716 """
5733 Public method to load a macro from a file. 5733 Public method to load a macro from a file.
5734 """ 5734 """
5735 configDir = Utilities.getConfigDir() 5735 configDir = Utilities.getConfigDir()
5736 fname = E5FileDialog.getOpenFileName( 5736 fname = E5FileDialog.getOpenFileName(
5737 self, 5737 self,
5738 self.trUtf8("Load macro file"), 5738 self.tr("Load macro file"),
5739 configDir, 5739 configDir,
5740 self.trUtf8("Macro files (*.macro)")) 5740 self.tr("Macro files (*.macro)"))
5741 5741
5742 if not fname: 5742 if not fname:
5743 return # user aborted 5743 return # user aborted
5744 5744
5745 try: 5745 try:
5747 lines = f.readlines() 5747 lines = f.readlines()
5748 f.close() 5748 f.close()
5749 except IOError: 5749 except IOError:
5750 E5MessageBox.critical( 5750 E5MessageBox.critical(
5751 self, 5751 self,
5752 self.trUtf8("Error loading macro"), 5752 self.tr("Error loading macro"),
5753 self.trUtf8( 5753 self.tr(
5754 "<p>The macro file <b>{0}</b> could not be read.</p>") 5754 "<p>The macro file <b>{0}</b> could not be read.</p>")
5755 .format(fname)) 5755 .format(fname))
5756 return 5756 return
5757 5757
5758 if len(lines) != 2: 5758 if len(lines) != 2:
5759 E5MessageBox.critical( 5759 E5MessageBox.critical(
5760 self, 5760 self,
5761 self.trUtf8("Error loading macro"), 5761 self.tr("Error loading macro"),
5762 self.trUtf8("<p>The macro file <b>{0}</b> is corrupt.</p>") 5762 self.tr("<p>The macro file <b>{0}</b> is corrupt.</p>")
5763 .format(fname)) 5763 .format(fname))
5764 return 5764 return
5765 5765
5766 macro = QsciMacro(lines[1], self) 5766 macro = QsciMacro(lines[1], self)
5767 self.macros[lines[0].strip()] = macro 5767 self.macros[lines[0].strip()] = macro
5776 if not ok or not name: 5776 if not ok or not name:
5777 return # user abort 5777 return # user abort
5778 5778
5779 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( 5779 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
5780 self, 5780 self,
5781 self.trUtf8("Save macro file"), 5781 self.tr("Save macro file"),
5782 configDir, 5782 configDir,
5783 self.trUtf8("Macro files (*.macro)"), 5783 self.tr("Macro files (*.macro)"),
5784 "", 5784 "",
5785 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) 5785 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
5786 5786
5787 if not fname: 5787 if not fname:
5788 return # user aborted 5788 return # user aborted
5793 if ex: 5793 if ex:
5794 fname += ex 5794 fname += ex
5795 if QFileInfo(fname).exists(): 5795 if QFileInfo(fname).exists():
5796 res = E5MessageBox.yesNo( 5796 res = E5MessageBox.yesNo(
5797 self, 5797 self,
5798 self.trUtf8("Save macro"), 5798 self.tr("Save macro"),
5799 self.trUtf8("<p>The macro file <b>{0}</b> already exists." 5799 self.tr("<p>The macro file <b>{0}</b> already exists."
5800 " Overwrite it?</p>").format(fname), 5800 " Overwrite it?</p>").format(fname),
5801 icon=E5MessageBox.Warning) 5801 icon=E5MessageBox.Warning)
5802 if not res: 5802 if not res:
5803 return 5803 return
5804 fname = Utilities.toNativeSeparators(fname) 5804 fname = Utilities.toNativeSeparators(fname)
5805 5805
5809 f.write(self.macros[name].save()) 5809 f.write(self.macros[name].save())
5810 f.close() 5810 f.close()
5811 except IOError: 5811 except IOError:
5812 E5MessageBox.critical( 5812 E5MessageBox.critical(
5813 self, 5813 self,
5814 self.trUtf8("Error saving macro"), 5814 self.tr("Error saving macro"),
5815 self.trUtf8( 5815 self.tr(
5816 "<p>The macro file <b>{0}</b> could not be written.</p>") 5816 "<p>The macro file <b>{0}</b> could not be written.</p>")
5817 .format(fname)) 5817 .format(fname))
5818 return 5818 return
5819 5819
5820 def macroRecordingStart(self): 5820 def macroRecordingStart(self):
5822 Public method to start macro recording. 5822 Public method to start macro recording.
5823 """ 5823 """
5824 if self.recording: 5824 if self.recording:
5825 res = E5MessageBox.yesNo( 5825 res = E5MessageBox.yesNo(
5826 self, 5826 self,
5827 self.trUtf8("Start Macro Recording"), 5827 self.tr("Start Macro Recording"),
5828 self.trUtf8("Macro recording is already active. Start new?"), 5828 self.tr("Macro recording is already active. Start new?"),
5829 icon=E5MessageBox.Warning, 5829 icon=E5MessageBox.Warning,
5830 yesDefault=True) 5830 yesDefault=True)
5831 if res: 5831 if res:
5832 self.macroRecordingStop() 5832 self.macroRecordingStop()
5833 else: 5833 else:
5848 self.curMacro.endRecording() 5848 self.curMacro.endRecording()
5849 self.recording = False 5849 self.recording = False
5850 5850
5851 name, ok = QInputDialog.getText( 5851 name, ok = QInputDialog.getText(
5852 self, 5852 self,
5853 self.trUtf8("Macro Recording"), 5853 self.tr("Macro Recording"),
5854 self.trUtf8("Enter name of the macro:"), 5854 self.tr("Enter name of the macro:"),
5855 QLineEdit.Normal) 5855 QLineEdit.Normal)
5856 5856
5857 if ok and name: 5857 if ok and name:
5858 self.macros[name] = self.curMacro 5858 self.macros[name] = self.curMacro
5859 5859
5968 self.lastModified.toString(): 5968 self.lastModified.toString():
5969 self.inReopenPrompt = True 5969 self.inReopenPrompt = True
5970 if Preferences.getEditor("AutoReopen") and not self.isModified(): 5970 if Preferences.getEditor("AutoReopen") and not self.isModified():
5971 self.refresh() 5971 self.refresh()
5972 else: 5972 else:
5973 msg = self.trUtf8( 5973 msg = self.tr(
5974 """<p>The file <b>{0}</b> has been changed while it""" 5974 """<p>The file <b>{0}</b> has been changed while it"""
5975 """ was opened in eric5. Reread it?</p>""")\ 5975 """ was opened in eric5. Reread it?</p>""")\
5976 .format(self.fileName) 5976 .format(self.fileName)
5977 yesDefault = True 5977 yesDefault = True
5978 if self.isModified(): 5978 if self.isModified():
5979 msg += self.trUtf8( 5979 msg += self.tr(
5980 """<br><b>Warning:</b> You will lose""" 5980 """<br><b>Warning:</b> You will lose"""
5981 """ your changes upon reopening it.""") 5981 """ your changes upon reopening it.""")
5982 yesDefault = False 5982 yesDefault = False
5983 res = E5MessageBox.yesNo( 5983 res = E5MessageBox.yesNo(
5984 self, 5984 self,
5985 self.trUtf8("File changed"), msg, 5985 self.tr("File changed"), msg,
5986 icon=E5MessageBox.Warning, 5986 icon=E5MessageBox.Warning,
5987 yesDefault=yesDefault) 5987 yesDefault=yesDefault)
5988 if res: 5988 if res:
5989 self.refresh() 5989 self.refresh()
5990 else: 5990 else:
6024 if self.windowState() == Qt.WindowStates(Qt.WindowMinimized): 6024 if self.windowState() == Qt.WindowStates(Qt.WindowMinimized):
6025 cap = os.path.basename(self.fileName) 6025 cap = os.path.basename(self.fileName)
6026 else: 6026 else:
6027 cap = self.fileName 6027 cap = self.fileName
6028 if self.isReadOnly(): 6028 if self.isReadOnly():
6029 cap = self.trUtf8("{0} (ro)").format(cap) 6029 cap = self.tr("{0} (ro)").format(cap)
6030 self.setWindowTitle(cap) 6030 self.setWindowTitle(cap)
6031 6031
6032 super().changeEvent(evt) 6032 super().changeEvent(evt)
6033 6033
6034 def mousePressEvent(self, event): 6034 def mousePressEvent(self, event):
6117 self.isReadOnly() 6117 self.isReadOnly()
6118 if not bForce and (readOnly == self.isReadOnly()): 6118 if not bForce and (readOnly == self.isReadOnly()):
6119 return 6119 return
6120 cap = self.fileName 6120 cap = self.fileName
6121 if readOnly: 6121 if readOnly:
6122 cap = self.trUtf8("{0} (ro)".format(cap)) 6122 cap = self.tr("{0} (ro)".format(cap))
6123 self.setReadOnly(readOnly) 6123 self.setReadOnly(readOnly)
6124 self.setWindowTitle(cap) 6124 self.setWindowTitle(cap)
6125 self.captionChanged.emit(cap, self) 6125 self.captionChanged.emit(cap, self)
6126 6126
6127 def refresh(self): 6127 def refresh(self):
6252 if not QFileInfo(fname).isDir(): 6252 if not QFileInfo(fname).isDir():
6253 self.vm.openSourceFile(fname) 6253 self.vm.openSourceFile(fname)
6254 else: 6254 else:
6255 E5MessageBox.information( 6255 E5MessageBox.information(
6256 self, 6256 self,
6257 self.trUtf8("Drop Error"), 6257 self.tr("Drop Error"),
6258 self.trUtf8("""<p><b>{0}</b> is not a file.</p>""") 6258 self.tr("""<p><b>{0}</b> is not a file.</p>""")
6259 .format(fname)) 6259 .format(fname))
6260 event.acceptProposedAction() 6260 event.acceptProposedAction()
6261 else: 6261 else:
6262 super().dropEvent(event) 6262 super().dropEvent(event)
6263 6263
6271 """ 6271 """
6272 Private method used to setup the Resources context sub menu. 6272 Private method used to setup the Resources context sub menu.
6273 6273
6274 @return reference to the generated menu (QMenu) 6274 @return reference to the generated menu (QMenu)
6275 """ 6275 """
6276 menu = QMenu(self.trUtf8('Resources')) 6276 menu = QMenu(self.tr('Resources'))
6277 6277
6278 menu.addAction( 6278 menu.addAction(
6279 self.trUtf8('Add file...'), self.__addFileResource) 6279 self.tr('Add file...'), self.__addFileResource)
6280 menu.addAction( 6280 menu.addAction(
6281 self.trUtf8('Add files...'), self.__addFileResources) 6281 self.tr('Add files...'), self.__addFileResources)
6282 menu.addAction( 6282 menu.addAction(
6283 self.trUtf8('Add aliased file...'), 6283 self.tr('Add aliased file...'),
6284 self.__addFileAliasResource) 6284 self.__addFileAliasResource)
6285 menu.addAction( 6285 menu.addAction(
6286 self.trUtf8('Add localized resource...'), 6286 self.tr('Add localized resource...'),
6287 self.__addLocalizedResource) 6287 self.__addLocalizedResource)
6288 menu.addSeparator() 6288 menu.addSeparator()
6289 menu.addAction( 6289 menu.addAction(
6290 self.trUtf8('Add resource frame'), self.__addResourceFrame) 6290 self.tr('Add resource frame'), self.__addResourceFrame)
6291 6291
6292 menu.aboutToShow.connect(self.__showContextMenuResources) 6292 menu.aboutToShow.connect(self.__showContextMenuResources)
6293 6293
6294 return menu 6294 return menu
6295 6295
6305 Private method to handle the Add file context menu action. 6305 Private method to handle the Add file context menu action.
6306 """ 6306 """
6307 dirStr = os.path.dirname(self.fileName) 6307 dirStr = os.path.dirname(self.fileName)
6308 file = E5FileDialog.getOpenFileName( 6308 file = E5FileDialog.getOpenFileName(
6309 self, 6309 self,
6310 self.trUtf8("Add file resource"), 6310 self.tr("Add file resource"),
6311 dirStr, 6311 dirStr,
6312 "") 6312 "")
6313 if file: 6313 if file:
6314 relFile = QDir(dirStr).relativeFilePath(file) 6314 relFile = QDir(dirStr).relativeFilePath(file)
6315 line, index = self.getCursorPosition() 6315 line, index = self.getCursorPosition()
6321 Private method to handle the Add files context menu action. 6321 Private method to handle the Add files context menu action.
6322 """ 6322 """
6323 dirStr = os.path.dirname(self.fileName) 6323 dirStr = os.path.dirname(self.fileName)
6324 files = E5FileDialog.getOpenFileNames( 6324 files = E5FileDialog.getOpenFileNames(
6325 self, 6325 self,
6326 self.trUtf8("Add file resources"), 6326 self.tr("Add file resources"),
6327 dirStr, 6327 dirStr,
6328 "") 6328 "")
6329 if files: 6329 if files:
6330 myDir = QDir(dirStr) 6330 myDir = QDir(dirStr)
6331 filesText = "" 6331 filesText = ""
6341 Private method to handle the Add aliased file context menu action. 6341 Private method to handle the Add aliased file context menu action.
6342 """ 6342 """
6343 dirStr = os.path.dirname(self.fileName) 6343 dirStr = os.path.dirname(self.fileName)
6344 file = E5FileDialog.getOpenFileName( 6344 file = E5FileDialog.getOpenFileName(
6345 self, 6345 self,
6346 self.trUtf8("Add aliased file resource"), 6346 self.tr("Add aliased file resource"),
6347 dirStr, 6347 dirStr,
6348 "") 6348 "")
6349 if file: 6349 if file:
6350 relFile = QDir(dirStr).relativeFilePath(file) 6350 relFile = QDir(dirStr).relativeFilePath(file)
6351 alias, ok = QInputDialog.getText( 6351 alias, ok = QInputDialog.getText(
6352 self, 6352 self,
6353 self.trUtf8("Add aliased file resource"), 6353 self.tr("Add aliased file resource"),
6354 self.trUtf8("Alias for file <b>{0}</b>:").format(relFile), 6354 self.tr("Alias for file <b>{0}</b>:").format(relFile),
6355 QLineEdit.Normal, 6355 QLineEdit.Normal,
6356 relFile) 6356 relFile)
6357 if ok and alias: 6357 if ok and alias:
6358 line, index = self.getCursorPosition() 6358 line, index = self.getCursorPosition()
6359 self.insert(' <file alias="{1}">{0}</file>\n' 6359 self.insert(' <file alias="{1}">{0}</file>\n'
6412 6412
6413 package = os.path.isdir(self.fileName) and \ 6413 package = os.path.isdir(self.fileName) and \
6414 self.fileName or os.path.dirname(self.fileName) 6414 self.fileName or os.path.dirname(self.fileName)
6415 res = E5MessageBox.yesNo( 6415 res = E5MessageBox.yesNo(
6416 self, 6416 self,
6417 self.trUtf8("Package Diagram"), 6417 self.tr("Package Diagram"),
6418 self.trUtf8("""Include class attributes?"""), 6418 self.tr("""Include class attributes?"""),
6419 yesDefault=True) 6419 yesDefault=True)
6420 self.packageDiagram = UMLDialog( 6420 self.packageDiagram = UMLDialog(
6421 UMLDialog.PackageDiagram, self.project, package, 6421 UMLDialog.PackageDiagram, self.project, package,
6422 self, noAttrs=not res) 6422 self, noAttrs=not res)
6423 self.packageDiagram.show() 6423 self.packageDiagram.show()
6432 6432
6433 package = os.path.isdir(self.fileName) and self.fileName \ 6433 package = os.path.isdir(self.fileName) and self.fileName \
6434 or os.path.dirname(self.fileName) 6434 or os.path.dirname(self.fileName)
6435 res = E5MessageBox.yesNo( 6435 res = E5MessageBox.yesNo(
6436 self, 6436 self,
6437 self.trUtf8("Imports Diagram"), 6437 self.tr("Imports Diagram"),
6438 self.trUtf8("""Include imports from external modules?""")) 6438 self.tr("""Include imports from external modules?"""))
6439 self.importsDiagram = UMLDialog( 6439 self.importsDiagram = UMLDialog(
6440 UMLDialog.ImportsDiagram, self.project, package, 6440 UMLDialog.ImportsDiagram, self.project, package,
6441 self, showExternalImports=res) 6441 self, showExternalImports=res)
6442 self.importsDiagram.show() 6442 self.importsDiagram.show()
6443 6443
6446 Private method to handle the Imports Diagram context menu action. 6446 Private method to handle the Imports Diagram context menu action.
6447 """ 6447 """
6448 from Graphics.UMLDialog import UMLDialog 6448 from Graphics.UMLDialog import UMLDialog
6449 res = E5MessageBox.yesNo( 6449 res = E5MessageBox.yesNo(
6450 self, 6450 self,
6451 self.trUtf8("Application Diagram"), 6451 self.tr("Application Diagram"),
6452 self.trUtf8("""Include module names?"""), 6452 self.tr("""Include module names?"""),
6453 yesDefault=True) 6453 yesDefault=True)
6454 self.applicationDiagram = UMLDialog( 6454 self.applicationDiagram = UMLDialog(
6455 UMLDialog.ApplicationDiagram, self.project, 6455 UMLDialog.ApplicationDiagram, self.project,
6456 self, noModules=not res) 6456 self, noModules=not res)
6457 self.applicationDiagram.show() 6457 self.applicationDiagram.show()
6734 self.spellingMenu.addAction(suggestion)) 6734 self.spellingMenu.addAction(suggestion))
6735 if suggestions: 6735 if suggestions:
6736 self.spellingMenu.addSeparator() 6736 self.spellingMenu.addSeparator()
6737 self.spellingMenu.addAction( 6737 self.spellingMenu.addAction(
6738 UI.PixmapCache.getIcon("spellchecking.png"), 6738 UI.PixmapCache.getIcon("spellchecking.png"),
6739 self.trUtf8("Check spelling..."), self.__checkSpellingWord) 6739 self.tr("Check spelling..."), self.__checkSpellingWord)
6740 self.spellingMenu.addAction( 6740 self.spellingMenu.addAction(
6741 self.trUtf8("Add to dictionary"), self.__addToSpellingDictionary) 6741 self.tr("Add to dictionary"), self.__addToSpellingDictionary)
6742 self.spellingMenu.addAction( 6742 self.spellingMenu.addAction(
6743 self.trUtf8("Ignore All"), self.__ignoreSpellingAlways) 6743 self.tr("Ignore All"), self.__ignoreSpellingAlways)
6744 6744
6745 self.showMenu.emit("Spelling", self.spellingMenu, self) 6745 self.showMenu.emit("Spelling", self.spellingMenu, self)
6746 6746
6747 def __contextMenuSpellingTriggered(self, action): 6747 def __contextMenuSpellingTriggered(self, action):
6748 """ 6748 """
7147 try: 7147 try:
7148 txt = float(txt) 7148 txt = float(txt)
7149 except ValueError: 7149 except ValueError:
7150 E5MessageBox.critical( 7150 E5MessageBox.critical(
7151 self, 7151 self,
7152 self.trUtf8("Sort Lines"), 7152 self.tr("Sort Lines"),
7153 self.trUtf8( 7153 self.tr(
7154 """The selection contains illegal data for a""" 7154 """The selection contains illegal data for a"""
7155 """ numerical sort.""")) 7155 """ numerical sort."""))
7156 return 7156 return
7157 7157
7158 if txt in selText: 7158 if txt in selText:

eric ide

mercurial