732 menu = QMenu(self.trUtf8("Languages")) |
732 menu = QMenu(self.trUtf8("Languages")) |
733 |
733 |
734 self.languagesActGrp = QActionGroup(self) |
734 self.languagesActGrp = QActionGroup(self) |
735 self.noLanguageAct = menu.addAction(self.trUtf8("No Language")) |
735 self.noLanguageAct = menu.addAction(self.trUtf8("No Language")) |
736 self.noLanguageAct.setCheckable(True) |
736 self.noLanguageAct.setCheckable(True) |
737 self.noLanguageAct.setData(QVariant("None")) |
737 self.noLanguageAct.setData("None") |
738 self.languagesActGrp.addAction(self.noLanguageAct) |
738 self.languagesActGrp.addAction(self.noLanguageAct) |
739 menu.addSeparator() |
739 menu.addSeparator() |
740 |
740 |
741 self.supportedLanguages = {} |
741 self.supportedLanguages = {} |
742 supportedLanguages = Lexers.getSupportedLanguages() |
742 supportedLanguages = Lexers.getSupportedLanguages() |
745 for language in languages: |
745 for language in languages: |
746 if language != "Guessed": |
746 if language != "Guessed": |
747 self.supportedLanguages[language] = supportedLanguages[language][:] |
747 self.supportedLanguages[language] = supportedLanguages[language][:] |
748 act = menu.addAction(self.supportedLanguages[language][0]) |
748 act = menu.addAction(self.supportedLanguages[language][0]) |
749 act.setCheckable(True) |
749 act.setCheckable(True) |
750 act.setData(QVariant(language)) |
750 act.setData(language) |
751 self.supportedLanguages[language].append(act) |
751 self.supportedLanguages[language].append(act) |
752 self.languagesActGrp.addAction(act) |
752 self.languagesActGrp.addAction(act) |
753 |
753 |
754 menu.addSeparator() |
754 menu.addSeparator() |
755 self.pygmentsAct = menu.addAction(self.trUtf8("Guessed")) |
755 self.pygmentsAct = menu.addAction(self.trUtf8("Guessed")) |
756 self.pygmentsAct.setCheckable(True) |
756 self.pygmentsAct.setCheckable(True) |
757 self.pygmentsAct.setData(QVariant("Guessed")) |
757 self.pygmentsAct.setData("Guessed") |
758 self.languagesActGrp.addAction(self.pygmentsAct) |
758 self.languagesActGrp.addAction(self.pygmentsAct) |
759 self.pygmentsSelAct = menu.addAction(self.trUtf8("Alternatives")) |
759 self.pygmentsSelAct = menu.addAction(self.trUtf8("Alternatives")) |
760 self.pygmentsSelAct.setData(QVariant("Alternatives")) |
760 self.pygmentsSelAct.setData("Alternatives") |
761 |
761 |
762 self.connect(menu, SIGNAL('triggered(QAction *)'), self.__languageMenuTriggered) |
762 self.connect(menu, SIGNAL('triggered(QAction *)'), self.__languageMenuTriggered) |
763 self.connect(menu, SIGNAL('aboutToShow()'), self.__showContextMenuLanguages) |
763 self.connect(menu, SIGNAL('aboutToShow()'), self.__showContextMenuLanguages) |
764 |
764 |
765 return menu |
765 return menu |
775 self.encodingsActGrp = QActionGroup(self) |
775 self.encodingsActGrp = QActionGroup(self) |
776 |
776 |
777 for encoding in sorted(Utilities.supportedCodecs): |
777 for encoding in sorted(Utilities.supportedCodecs): |
778 act = menu.addAction(encoding) |
778 act = menu.addAction(encoding) |
779 act.setCheckable(True) |
779 act.setCheckable(True) |
780 act.setData(QVariant(encoding)) |
780 act.setData(encoding) |
781 self.supportedEncodings[encoding] = act |
781 self.supportedEncodings[encoding] = act |
782 self.encodingsActGrp.addAction(act) |
782 self.encodingsActGrp.addAction(act) |
783 |
783 |
784 self.connect(menu, SIGNAL('triggered(QAction *)'), self.__encodingsMenuTriggered) |
784 self.connect(menu, SIGNAL('triggered(QAction *)'), self.__encodingsMenuTriggered) |
785 self.connect(menu, SIGNAL('aboutToShow()'), self.__showContextMenuEncodings) |
785 self.connect(menu, SIGNAL('aboutToShow()'), self.__showContextMenuEncodings) |
796 |
796 |
797 self.eolActGrp = QActionGroup(self) |
797 self.eolActGrp = QActionGroup(self) |
798 |
798 |
799 act = menu.addAction(self.trUtf8("Unix")) |
799 act = menu.addAction(self.trUtf8("Unix")) |
800 act.setCheckable(True) |
800 act.setCheckable(True) |
801 act.setData(QVariant('\n')) |
801 act.setData('\n') |
802 self.supportedEols['\n'] = act |
802 self.supportedEols['\n'] = act |
803 self.eolActGrp.addAction(act) |
803 self.eolActGrp.addAction(act) |
804 |
804 |
805 act = menu.addAction(self.trUtf8("Windows")) |
805 act = menu.addAction(self.trUtf8("Windows")) |
806 act.setCheckable(True) |
806 act.setCheckable(True) |
807 act.setData(QVariant('\r\n')) |
807 act.setData('\r\n') |
808 self.supportedEols['\r\n'] = act |
808 self.supportedEols['\r\n'] = act |
809 self.eolActGrp.addAction(act) |
809 self.eolActGrp.addAction(act) |
810 |
810 |
811 act = menu.addAction(self.trUtf8("Macintosh")) |
811 act = menu.addAction(self.trUtf8("Macintosh")) |
812 act.setCheckable(True) |
812 act.setCheckable(True) |
813 act.setData(QVariant('\r')) |
813 act.setData('\r') |
814 self.supportedEols['\r'] = act |
814 self.supportedEols['\r'] = act |
815 self.eolActGrp.addAction(act) |
815 self.eolActGrp.addAction(act) |
816 |
816 |
817 self.connect(menu, SIGNAL('triggered(QAction *)'), self.__eolMenuTriggered) |
817 self.connect(menu, SIGNAL('triggered(QAction *)'), self.__eolMenuTriggered) |
818 self.connect(menu, SIGNAL('aboutToShow()'), self.__showContextMenuEol) |
818 self.connect(menu, SIGNAL('aboutToShow()'), self.__showContextMenuEol) |
828 supportedExporters = Exporters.getSupportedFormats() |
828 supportedExporters = Exporters.getSupportedFormats() |
829 exporters = supportedExporters.keys() |
829 exporters = supportedExporters.keys() |
830 exporters.sort() |
830 exporters.sort() |
831 for exporter in exporters: |
831 for exporter in exporters: |
832 act = menu.addAction(supportedExporters[exporter]) |
832 act = menu.addAction(supportedExporters[exporter]) |
833 act.setData(QVariant(exporter)) |
833 act.setData(exporter) |
834 |
834 |
835 self.connect(menu, SIGNAL('triggered(QAction *)'), self.__exportMenuTriggered) |
835 self.connect(menu, SIGNAL('triggered(QAction *)'), self.__exportMenuTriggered) |
836 |
836 |
837 return menu |
837 return menu |
838 |
838 |
1009 """ |
1009 """ |
1010 Private method to handle the selection of an export format. |
1010 Private method to handle the selection of an export format. |
1011 |
1011 |
1012 @param act reference to the action that was triggered (QAction) |
1012 @param act reference to the action that was triggered (QAction) |
1013 """ |
1013 """ |
1014 exporterFormat = act.data().toString() |
1014 exporterFormat = act.data() |
1015 self.exportFile(exporterFormat) |
1015 self.exportFile(exporterFormat) |
1016 |
1016 |
1017 def exportFile(self, exporterFormat): |
1017 def exportFile(self, exporterFormat): |
1018 """ |
1018 """ |
1019 Public method to export the file. |
1019 Public method to export the file. |
1087 elif act == self.pygmentsSelAct: |
1087 elif act == self.pygmentsSelAct: |
1088 language = self.__selectPygmentsLexer() |
1088 language = self.__selectPygmentsLexer() |
1089 if language: |
1089 if language: |
1090 self.setLanguage("dummy.pygments", pyname = language) |
1090 self.setLanguage("dummy.pygments", pyname = language) |
1091 else: |
1091 else: |
1092 language = act.data().toString() |
1092 language = act.data() |
1093 if language: |
1093 if language: |
1094 self.setLanguage(self.supportedLanguages[language][1]) |
1094 self.setLanguage(self.supportedLanguages[language][1]) |
1095 |
1095 |
1096 def languageChanged(self, language, propagate = True): |
1096 def languageChanged(self, language, propagate = True): |
1097 """ |
1097 """ |
1196 """ |
1196 """ |
1197 Private method to handle the selection of an encoding. |
1197 Private method to handle the selection of an encoding. |
1198 |
1198 |
1199 @param act reference to the action that was triggered (QAction) |
1199 @param act reference to the action that was triggered (QAction) |
1200 """ |
1200 """ |
1201 encoding = act.data().toString() |
1201 encoding = act.data() |
1202 self.__encodingChanged("%s-selected" % encoding) |
1202 self.__encodingChanged("%s-selected" % encoding) |
1203 |
1203 |
1204 def __checkEncoding(self): |
1204 def __checkEncoding(self): |
1205 """ |
1205 """ |
1206 Private method to check the selected encoding of the encodings submenu. |
1206 Private method to check the selected encoding of the encodings submenu. |
1244 """ |
1244 """ |
1245 Private method to handle the selection of an eol type. |
1245 Private method to handle the selection of an eol type. |
1246 |
1246 |
1247 @param act reference to the action that was triggered (QAction) |
1247 @param act reference to the action that was triggered (QAction) |
1248 """ |
1248 """ |
1249 eol = act.data().toString() |
1249 eol = act.data() |
1250 self.setEolModeByEolString(eol) |
1250 self.setEolModeByEolString(eol) |
1251 self.convertEols(self.eolMode()) |
1251 self.convertEols(self.eolMode()) |
1252 |
1252 |
1253 def __checkEol(self): |
1253 def __checkEol(self): |
1254 """ |
1254 """ |
1311 self.setStyleBits(self.lexer_.styleBitsNeeded()) |
1311 self.setStyleBits(self.lexer_.styleBitsNeeded()) |
1312 self.connect(self, SIGNAL("SCN_STYLENEEDED(int)"), self.__styleNeeded) |
1312 self.connect(self, SIGNAL("SCN_STYLENEEDED(int)"), self.__styleNeeded) |
1313 |
1313 |
1314 # get the font for style 0 and set it as the default font |
1314 # get the font for style 0 and set it as the default font |
1315 key = 'Scintilla/%s/style0/font' % self.lexer_.language() |
1315 key = 'Scintilla/%s/style0/font' % self.lexer_.language() |
1316 fontVariant = Preferences.Prefs.settings.value(key) |
1316 fdesc = Preferences.Prefs.settings.value(key) |
1317 if fontVariant.isValid(): |
1317 if fdesc is not None: |
1318 fdesc = fontVariant.toStringList() |
|
1319 font = QFont(fdesc[0], int(fdesc[1])) |
1318 font = QFont(fdesc[0], int(fdesc[1])) |
1320 self.lexer_.setDefaultFont(font) |
1319 self.lexer_.setDefaultFont(font) |
1321 self.lexer_.readSettings(Preferences.Prefs.settings, "Scintilla") |
1320 self.lexer_.readSettings(Preferences.Prefs.settings, "Scintilla") |
1322 |
1321 |
1323 # now set the lexer properties |
1322 # now set the lexer properties |
5155 """ |
5154 """ |
5156 Public method to set the spell checking options for files belonging |
5155 Public method to set the spell checking options for files belonging |
5157 to the current project. |
5156 to the current project. |
5158 """ |
5157 """ |
5159 project = e4App().getObject("Project") |
5158 project = e4App().getObject("Project") |
5160 if project.isOpen() and project.isProjectSource(self.fileName): |
5159 if self.fileName and \ |
|
5160 project.isOpen() and \ |
|
5161 project.isProjectSource(self.fileName): |
5161 pwl, pel = project.getProjectDictionaries() |
5162 pwl, pel = project.getProjectDictionaries() |
5162 self.__setSpellingLanguage(project.getProjectSpellLanguage(), |
5163 self.__setSpellingLanguage(project.getProjectSpellLanguage(), |
5163 pwl = pwl, pel = pel) |
5164 pwl = pwl, pel = pel) |
5164 |
5165 |
5165 def setAutoSpellChecking(self): |
5166 def setAutoSpellChecking(self): |