29 from eric7.EricGui import EricPixmapCache |
29 from eric7.EricGui import EricPixmapCache |
30 from eric7.EricGui.EricAction import EricAction, createActionGroup |
30 from eric7.EricGui.EricAction import EricAction, createActionGroup |
31 from eric7.EricWidgets import EricFileDialog, EricMessageBox |
31 from eric7.EricWidgets import EricFileDialog, EricMessageBox |
32 from eric7.EricWidgets.EricApplication import ericApp |
32 from eric7.EricWidgets.EricApplication import ericApp |
33 from eric7.Globals import isMacPlatform, recentNameFiles |
33 from eric7.Globals import isMacPlatform, recentNameFiles |
|
34 from eric7.QScintilla import Exporters, Lexers |
|
35 from eric7.QScintilla.APIsManager import APIsManager |
34 from eric7.QScintilla.Editor import Editor |
36 from eric7.QScintilla.Editor import Editor |
|
37 from eric7.QScintilla.EditorAssembly import EditorAssembly |
|
38 from eric7.QScintilla.Shell import Shell |
|
39 from eric7.QScintilla.SpellChecker import SpellChecker |
|
40 from eric7.QScintilla.SpellingDictionaryEditDialog import SpellingDictionaryEditDialog |
|
41 from eric7.QScintilla.ZoomDialog import ZoomDialog |
35 from eric7.UI import Config |
42 from eric7.UI import Config |
36 |
43 |
37 |
44 |
38 class ViewManager(QWidget): |
45 class ViewManager(QWidget): |
39 """ |
46 """ |
133 self.autosaveTimer.setObjectName("AutosaveTimer") |
140 self.autosaveTimer.setObjectName("AutosaveTimer") |
134 self.autosaveTimer.setSingleShot(True) |
141 self.autosaveTimer.setSingleShot(True) |
135 self.autosaveTimer.timeout.connect(self.__autosave) |
142 self.autosaveTimer.timeout.connect(self.__autosave) |
136 |
143 |
137 # initialize the APIs manager |
144 # initialize the APIs manager |
138 from eric7.QScintilla.APIsManager import APIsManager |
|
139 |
|
140 self.apisManager = APIsManager(parent=self) |
145 self.apisManager = APIsManager(parent=self) |
141 |
146 |
142 self.__cooperationClient = None |
147 self.__cooperationClient = None |
143 |
148 |
144 self.__lastFocusWidget = None |
149 self.__lastFocusWidget = None |
933 Private method used to setup the Exporters sub menu. |
938 Private method used to setup the Exporters sub menu. |
934 |
939 |
935 @return reference to the generated menu (QMenu) |
940 @return reference to the generated menu (QMenu) |
936 """ |
941 """ |
937 menu = QMenu(QCoreApplication.translate("ViewManager", "Export as")) |
942 menu = QMenu(QCoreApplication.translate("ViewManager", "Export as")) |
938 |
|
939 from eric7.QScintilla import Exporters |
|
940 |
943 |
941 supportedExporters = Exporters.getSupportedFormats() |
944 supportedExporters = Exporters.getSupportedFormats() |
942 exporters = sorted(supportedExporters.keys()) |
945 exporters = sorted(supportedExporters.keys()) |
943 for exporter in exporters: |
946 for exporter in exporters: |
944 act = menu.addAction(supportedExporters[exporter]) |
947 act = menu.addAction(supportedExporters[exporter]) |
5836 if language is None: |
5839 if language is None: |
5837 pixmap = QPixmap() |
5840 pixmap = QPixmap() |
5838 elif language == "": |
5841 elif language == "": |
5839 pixmap = EricPixmapCache.getPixmap("fileText") |
5842 pixmap = EricPixmapCache.getPixmap("fileText") |
5840 else: |
5843 else: |
5841 from eric7.QScintilla import Lexers |
|
5842 |
|
5843 pixmap = Lexers.getLanguageIcon(language, True) |
5844 pixmap = Lexers.getLanguageIcon(language, True) |
5844 self.sbLang.setPixmap(pixmap) |
5845 self.sbLang.setPixmap(pixmap) |
5845 if pixmap.isNull(): |
5846 if pixmap.isNull(): |
5846 self.sbLang.setText(language) |
5847 self.sbLang.setText(language) |
5847 self.sbLang.setToolTip("") |
5848 self.sbLang.setToolTip("") |
5949 if editor is None or not Utilities.samepath(fn, editor.getFileName()): |
5950 if editor is None or not Utilities.samepath(fn, editor.getFileName()): |
5950 for editor in self.editors: |
5951 for editor in self.editors: |
5951 if Utilities.samepath(fn, editor.getFileName()): |
5952 if Utilities.samepath(fn, editor.getFileName()): |
5952 break |
5953 break |
5953 else: |
5954 else: |
5954 from eric7.QScintilla.EditorAssembly import EditorAssembly |
|
5955 |
|
5956 assembly = EditorAssembly( |
5955 assembly = EditorAssembly( |
5957 self.dbs, |
5956 self.dbs, |
5958 fn, |
5957 fn, |
5959 self, |
5958 self, |
5960 filetype=filetype, |
5959 filetype=filetype, |
6382 """ |
6381 """ |
6383 # Focus handling was changed with Qt 5.13.1; this copes with that |
6382 # Focus handling was changed with Qt 5.13.1; this copes with that |
6384 if now is None: |
6383 if now is None: |
6385 return |
6384 return |
6386 |
6385 |
6387 from eric7.QScintilla.Shell import Shell |
|
6388 |
|
6389 if not isinstance(now, (Editor, Shell)): |
6386 if not isinstance(now, (Editor, Shell)): |
6390 self.editActGrp.setEnabled(False) |
6387 self.editActGrp.setEnabled(False) |
6391 self.copyActGrp.setEnabled(False) |
6388 self.copyActGrp.setEnabled(False) |
6392 self.viewActGrp.setEnabled(False) |
6389 self.viewActGrp.setEnabled(False) |
6393 self.sbZoom.setEnabled(False) |
6390 self.sbZoom.setEnabled(False) |
6787 ericApp().getObject("Shell") |
6784 ericApp().getObject("Shell") |
6788 if QApplication.focusWidget() == ericApp().getObject("Shell") |
6785 if QApplication.focusWidget() == ericApp().getObject("Shell") |
6789 else self.activeWindow() |
6786 else self.activeWindow() |
6790 ) |
6787 ) |
6791 if aw: |
6788 if aw: |
6792 from eric7.QScintilla.ZoomDialog import ZoomDialog |
|
6793 |
|
6794 dlg = ZoomDialog(aw.getZoom(), self.ui, None, True) |
6789 dlg = ZoomDialog(aw.getZoom(), self.ui, None, True) |
6795 if dlg.exec() == QDialog.DialogCode.Accepted: |
6790 if dlg.exec() == QDialog.DialogCode.Accepted: |
6796 value = dlg.getZoomSize() |
6791 value = dlg.getZoomSize() |
6797 self.__zoomTo(value) |
6792 self.__zoomTo(value) |
6798 |
6793 |
7212 projetOpen = proj.isOpen() |
7207 projetOpen = proj.isOpen() |
7213 pwl = ericApp().getObject("Project").getProjectDictionaries()[0] |
7208 pwl = ericApp().getObject("Project").getProjectDictionaries()[0] |
7214 self.__editProjectPwlAct.setEnabled(projetOpen and bool(pwl)) |
7209 self.__editProjectPwlAct.setEnabled(projetOpen and bool(pwl)) |
7215 pel = ericApp().getObject("Project").getProjectDictionaries()[1] |
7210 pel = ericApp().getObject("Project").getProjectDictionaries()[1] |
7216 self.__editProjectPelAct.setEnabled(projetOpen and bool(pel)) |
7211 self.__editProjectPelAct.setEnabled(projetOpen and bool(pel)) |
7217 |
|
7218 from eric7.QScintilla.SpellChecker import SpellChecker |
|
7219 |
7212 |
7220 pwl = SpellChecker.getUserDictionaryPath() |
7213 pwl = SpellChecker.getUserDictionaryPath() |
7221 self.__editUserPwlAct.setEnabled(bool(pwl)) |
7214 self.__editUserPwlAct.setEnabled(bool(pwl)) |
7222 pel = SpellChecker.getUserDictionaryPath(True) |
7215 pel = SpellChecker.getUserDictionaryPath(True) |
7223 self.__editUserPelAct.setEnabled(bool(pel)) |
7216 self.__editUserPelAct.setEnabled(bool(pel)) |
7297 |
7290 |
7298 fileInfo = ( |
7291 fileInfo = ( |
7299 dictionaryFile |
7292 dictionaryFile |
7300 if len(dictionaryFile) < 40 |
7293 if len(dictionaryFile) < 40 |
7301 else "...{0}".format(dictionaryFile[-40:]) |
7294 else "...{0}".format(dictionaryFile[-40:]) |
7302 ) |
|
7303 from eric7.QScintilla.SpellingDictionaryEditDialog import ( |
|
7304 SpellingDictionaryEditDialog, |
|
7305 ) |
7295 ) |
7306 |
7296 |
7307 dlg = SpellingDictionaryEditDialog( |
7297 dlg = SpellingDictionaryEditDialog( |
7308 data, |
7298 data, |
7309 QCoreApplication.translate("ViewManager", "Editing {0}").format( |
7299 QCoreApplication.translate("ViewManager", "Editing {0}").format( |
7869 @return name of the filename filter (string) or None |
7859 @return name of the filename filter (string) or None |
7870 """ |
7860 """ |
7871 if self.activeWindow() is not None and self.activeWindow().getFileName(): |
7861 if self.activeWindow() is not None and self.activeWindow().getFileName(): |
7872 ext = os.path.splitext(self.activeWindow().getFileName())[1] |
7862 ext = os.path.splitext(self.activeWindow().getFileName())[1] |
7873 rx = re.compile(r".*\*\.{0}[ )].*".format(ext[1:])) |
7863 rx = re.compile(r".*\*\.{0}[ )].*".format(ext[1:])) |
7874 from eric7.QScintilla import Lexers |
|
7875 |
|
7876 filters = Lexers.getOpenFileFiltersList() |
7864 filters = Lexers.getOpenFileFiltersList() |
7877 index = -1 |
7865 index = -1 |
7878 for i in range(len(filters)): |
7866 for i in range(len(filters)): |
7879 if rx.fullmatch(filters[i]): |
7867 if rx.fullmatch(filters[i]): |
7880 index = i |
7868 index = i |