17 |
17 |
18 from Globals import recentNameFiles |
18 from Globals import recentNameFiles |
19 |
19 |
20 import Preferences |
20 import Preferences |
21 |
21 |
22 from BookmarkedFilesDialog import BookmarkedFilesDialog |
22 from .BookmarkedFilesDialog import BookmarkedFilesDialog |
23 |
23 |
24 from QScintilla.QsciScintillaCompat import QSCINTILLA_VERSION |
24 from QScintilla.QsciScintillaCompat import QSCINTILLA_VERSION |
25 from QScintilla.Editor import Editor |
25 from QScintilla.Editor import Editor |
26 from QScintilla.GotoDialog import GotoDialog |
26 from QScintilla.GotoDialog import GotoDialog |
27 from QScintilla.SearchReplaceWidget import SearchReplaceWidget |
27 from QScintilla.SearchReplaceWidget import SearchReplaceWidget |
165 """ |
165 """ |
166 self.recent = [] |
166 self.recent = [] |
167 Preferences.Prefs.rsettings.sync() |
167 Preferences.Prefs.rsettings.sync() |
168 rs = Preferences.Prefs.rsettings.value(recentNameFiles) |
168 rs = Preferences.Prefs.rsettings.value(recentNameFiles) |
169 if rs is not None: |
169 if rs is not None: |
170 for f in rs: |
170 for f in Preferences.toList(rs): |
171 if QFileInfo(f).exists(): |
171 if QFileInfo(f).exists(): |
172 self.recent.append(f) |
172 self.recent.append(f) |
173 |
173 |
174 def __saveRecent(self): |
174 def __saveRecent(self): |
175 """ |
175 """ |
422 # list containing all bookmark actions |
422 # list containing all bookmark actions |
423 self.bookmarkActions = [] |
423 self.bookmarkActions = [] |
424 |
424 |
425 # list containing all spell checking actions |
425 # list containing all spell checking actions |
426 self.spellingActions = [] |
426 self.spellingActions = [] |
|
427 |
|
428 self.__actions = { |
|
429 "bookmark" : self.bookmarkActions, |
|
430 "edit" : self.editActions, |
|
431 "file" : self.fileActions, |
|
432 "macro" : self.macroActions, |
|
433 "search" : self.searchActions, |
|
434 "spelling" : self.spellingActions, |
|
435 "view" : self.viewActions, |
|
436 "window" : self.windowActions, |
|
437 } |
427 |
438 |
428 self._initWindowActions() |
439 self._initWindowActions() |
429 self.__initFileActions() |
440 self.__initFileActions() |
430 self.__initEditActions() |
441 self.__initEditActions() |
431 self.__initSearchActions() |
442 self.__initSearchActions() |
695 Private method used to setup the Exporters sub menu. |
706 Private method used to setup the Exporters sub menu. |
696 """ |
707 """ |
697 menu = QMenu(QApplication.translate('ViewManager', "Export as")) |
708 menu = QMenu(QApplication.translate('ViewManager', "Export as")) |
698 |
709 |
699 supportedExporters = QScintilla.Exporters.getSupportedFormats() |
710 supportedExporters = QScintilla.Exporters.getSupportedFormats() |
700 exporters = supportedExporters.keys() |
711 exporters = sorted(list(supportedExporters.keys())) |
701 exporters.sort() |
|
702 for exporter in exporters: |
712 for exporter in exporters: |
703 act = menu.addAction(supportedExporters[exporter]) |
713 act = menu.addAction(supportedExporters[exporter]) |
704 act.setData(exporter) |
714 act.setData(exporter) |
705 |
715 |
706 self.connect(menu, SIGNAL('triggered(QAction *)'), self.__exportMenuTriggered) |
716 self.connect(menu, SIGNAL('triggered(QAction *)'), self.__exportMenuTriggered) |
3062 @param filetype type of the source file (string) |
3072 @param filetype type of the source file (string) |
3063 @param selection tuple (start, end) of an area to be selected |
3073 @param selection tuple (start, end) of an area to be selected |
3064 """ |
3074 """ |
3065 try: |
3075 try: |
3066 newWin, editor = self.getEditor(fn, filetype = filetype) |
3076 newWin, editor = self.getEditor(fn, filetype = filetype) |
3067 except IOError: |
3077 except (IOError, UnicodeDecodeError): |
3068 return |
3078 return |
3069 |
3079 |
3070 if newWin: |
3080 if newWin: |
3071 self._modificationStatusChanged(editor.isModified(), editor) |
3081 self._modificationStatusChanged(editor.isModified(), editor) |
3072 self._checkActions(editor) |
3082 self._checkActions(editor) |
3176 @param error flag indicating an error highlight (boolean) |
3186 @param error flag indicating an error highlight (boolean) |
3177 @param syntaxError flag indicating a syntax error |
3187 @param syntaxError flag indicating a syntax error |
3178 """ |
3188 """ |
3179 try: |
3189 try: |
3180 newWin, self.currentEditor = self.getEditor(fn) |
3190 newWin, self.currentEditor = self.getEditor(fn) |
3181 except IOError: |
3191 except (IOError, UnicodeDecodeError): |
3182 return |
3192 return |
3183 |
3193 |
3184 enc = self.currentEditor.getEncoding() |
3194 enc = self.currentEditor.getEncoding() |
3185 lang = self.currentEditor.getLanguage() |
3195 lang = self.currentEditor.getLanguage() |
3186 eol = self.currentEditor.getEolIndicator() |
3196 eol = self.currentEditor.getEolIndicator() |
4681 """ |
4691 """ |
4682 Public method to get a list of all actions. |
4692 Public method to get a list of all actions. |
4683 |
4693 |
4684 @param type string denoting the action set to get. |
4694 @param type string denoting the action set to get. |
4685 It must be one of "edit", "file", "search", |
4695 It must be one of "edit", "file", "search", |
4686 "view", "window", "macro" or "bookmark" |
4696 "view", "window", "macro", "bookmark" or |
|
4697 "spelling". |
4687 @return list of all actions (list of E4Action) |
4698 @return list of all actions (list of E4Action) |
4688 """ |
4699 """ |
4689 try: |
4700 try: |
4690 exec 'actionList = self.%sActions[:]' % type |
4701 return self.__actions[type][:] |
4691 except AttributeError: |
4702 except KeyError: |
4692 actionList = [] |
4703 return [] |
4693 |
|
4694 return actionList |
|
4695 |
4704 |
4696 def __editorCommand(self, cmd): |
4705 def __editorCommand(self, cmd): |
4697 """ |
4706 """ |
4698 Private method to send an editor command to the active window. |
4707 Private method to send an editor command to the active window. |
4699 |
4708 |