7 Module implementing a dialog for the configuration of eric. |
7 Module implementing a dialog for the configuration of eric. |
8 """ |
8 """ |
9 |
9 |
10 import os |
10 import os |
11 import types |
11 import types |
|
12 import contextlib |
12 |
13 |
13 from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QMetaObject, QRect |
14 from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QMetaObject, QRect |
14 from PyQt5.QtGui import QPixmap |
15 from PyQt5.QtGui import QPixmap |
15 from PyQt5.QtWidgets import ( |
16 from PyQt5.QtWidgets import ( |
16 QSizePolicy, QSpacerItem, QWidget, QTreeWidget, QStackedWidget, QDialog, |
17 QSizePolicy, QSpacerItem, QWidget, QTreeWidget, QStackedWidget, QDialog, |
640 ) |
641 ) |
641 |
642 |
642 self.lexers = {} |
643 self.lexers = {} |
643 for language in QScintilla.Lexers.getSupportedLanguages(): |
644 for language in QScintilla.Lexers.getSupportedLanguages(): |
644 if language not in self.lexers: |
645 if language not in self.lexers: |
645 try: |
646 with contextlib.suppress(PreferencesLexerLanguageError): |
646 self.lexers[language] = PreferencesLexer(language, self) |
647 self.lexers[language] = PreferencesLexer(language, self) |
647 except PreferencesLexerLanguageError: |
|
648 pass |
|
649 |
648 |
650 def __importConfigurationPage(self, name): |
649 def __importConfigurationPage(self, name): |
651 """ |
650 """ |
652 Private method to import a configuration page module. |
651 Private method to import a configuration page module. |
653 |
652 |
694 if mod: |
693 if mod: |
695 page = mod.create(self) |
694 page = mod.create(self) |
696 if page is not None: |
695 if page is not None: |
697 self.configStack.addWidget(page) |
696 self.configStack.addWidget(page) |
698 pageData[-1] = page |
697 pageData[-1] = page |
699 try: |
698 with contextlib.suppress(AttributeError): |
700 page.setMode(self.displayMode) |
699 page.setMode(self.displayMode) |
701 except AttributeError: |
|
702 pass |
|
703 return page |
700 return page |
704 |
701 |
705 def showConfigurationPageByName(self, pageName, setCurrent=True): |
702 def showConfigurationPageByName(self, pageName, setCurrent=True): |
706 """ |
703 """ |
707 Public slot to show a named configuration page. |
704 Public slot to show a named configuration page. |