22 |
22 |
23 from .ConfigurationPageBase import ConfigurationPageBase |
23 from .ConfigurationPageBase import ConfigurationPageBase |
24 from .Ui_EditorHighlightingStylesPage import Ui_EditorHighlightingStylesPage |
24 from .Ui_EditorHighlightingStylesPage import Ui_EditorHighlightingStylesPage |
25 from ..SubstyleDefinitionDialog import SubstyleDefinitionDialog |
25 from ..SubstyleDefinitionDialog import SubstyleDefinitionDialog |
26 |
26 |
27 from EricWidgets import EricMessageBox, EricFileDialog |
27 from eric7.EricWidgets import EricMessageBox, EricFileDialog |
28 |
28 |
29 import UI.PixmapCache |
29 from eric7.EricGui import EricPixmapCache |
30 |
30 |
31 |
31 |
32 class EditorHighlightingStylesPage( |
32 class EditorHighlightingStylesPage( |
33 ConfigurationPageBase, Ui_EditorHighlightingStylesPage |
33 ConfigurationPageBase, Ui_EditorHighlightingStylesPage |
34 ): |
34 ): |
52 """ |
52 """ |
53 super().__init__() |
53 super().__init__() |
54 self.setupUi(self) |
54 self.setupUi(self) |
55 self.setObjectName("EditorHighlightingStylesPage") |
55 self.setObjectName("EditorHighlightingStylesPage") |
56 |
56 |
57 self.defaultSubstylesButton.setIcon(UI.PixmapCache.getIcon("editUndo")) |
57 self.defaultSubstylesButton.setIcon(EricPixmapCache.getIcon("editUndo")) |
58 self.addSubstyleButton.setIcon(UI.PixmapCache.getIcon("plus")) |
58 self.addSubstyleButton.setIcon(EricPixmapCache.getIcon("plus")) |
59 self.deleteSubstyleButton.setIcon(UI.PixmapCache.getIcon("minus")) |
59 self.deleteSubstyleButton.setIcon(EricPixmapCache.getIcon("minus")) |
60 self.editSubstyleButton.setIcon(UI.PixmapCache.getIcon("edit")) |
60 self.editSubstyleButton.setIcon(EricPixmapCache.getIcon("edit")) |
61 self.copySubstyleButton.setIcon(UI.PixmapCache.getIcon("editCopy")) |
61 self.copySubstyleButton.setIcon(EricPixmapCache.getIcon("editCopy")) |
62 |
62 |
63 self.__fontButtonMenu = QMenu() |
63 self.__fontButtonMenu = QMenu() |
64 act = self.__fontButtonMenu.addAction(self.tr("Font")) |
64 act = self.__fontButtonMenu.addAction(self.tr("Font")) |
65 act.setData(self.FONT) |
65 act.setData(self.FONT) |
66 self.__fontButtonMenu.addSeparator() |
66 self.__fontButtonMenu.addSeparator() |
88 |
88 |
89 self.lexer = None |
89 self.lexer = None |
90 self.lexers = lexers |
90 self.lexers = lexers |
91 |
91 |
92 # set initial values |
92 # set initial values |
93 import QScintilla.Lexers |
93 from eric7.QScintilla import Lexers |
94 |
94 |
95 languages = sorted([""] + list(self.lexers.keys())) |
95 languages = sorted([""] + list(self.lexers.keys())) |
96 for language in languages: |
96 for language in languages: |
97 self.lexerLanguageComboBox.addItem( |
97 self.lexerLanguageComboBox.addItem( |
98 QScintilla.Lexers.getLanguageIcon(language, False), language |
98 Lexers.getLanguageIcon(language, False), language |
99 ) |
99 ) |
100 self.on_lexerLanguageComboBox_activated(0) |
100 self.on_lexerLanguageComboBox_activated(0) |
101 |
101 |
102 def save(self): |
102 def save(self): |
103 """ |
103 """ |
595 if fpath.exists() |
595 if fpath.exists() |
596 else True |
596 else True |
597 ) |
597 ) |
598 |
598 |
599 if ok: |
599 if ok: |
600 from Preferences.HighlightingStylesFile import HighlightingStylesFile |
600 from eric7.Preferences.HighlightingStylesFile import HighlightingStylesFile |
601 |
601 |
602 highlightingStylesFile = HighlightingStylesFile() |
602 highlightingStylesFile = HighlightingStylesFile() |
603 highlightingStylesFile.writeFile(str(fpath), lexers) |
603 highlightingStylesFile.writeFile(str(fpath), lexers) |
604 |
604 |
605 def __importStyles(self, importAll=False): |
605 def __importStyles(self, importAll=False): |
627 if not fn: |
627 if not fn: |
628 return |
628 return |
629 |
629 |
630 if fn.endswith(".ehj"): |
630 if fn.endswith(".ehj"): |
631 # new JSON based file |
631 # new JSON based file |
632 from Preferences.HighlightingStylesFile import HighlightingStylesFile |
632 from eric7.Preferences.HighlightingStylesFile import HighlightingStylesFile |
633 |
633 |
634 highlightingStylesFile = HighlightingStylesFile() |
634 highlightingStylesFile = HighlightingStylesFile() |
635 styles = highlightingStylesFile.readFile(fn) |
635 styles = highlightingStylesFile.readFile(fn) |
636 if not styles: |
636 if not styles: |
637 return |
637 return |
638 else: |
638 else: |
639 # old XML based file |
639 # old XML based file |
640 f = QFile(fn) |
640 f = QFile(fn) |
641 if f.open(QIODevice.OpenModeFlag.ReadOnly): |
641 if f.open(QIODevice.OpenModeFlag.ReadOnly): |
642 from EricXML.HighlightingStylesReader import HighlightingStylesReader |
642 from eric7.EricXML.HighlightingStylesReader import ( |
|
643 HighlightingStylesReader, |
|
644 ) |
643 |
645 |
644 reader = HighlightingStylesReader(f, self.lexers) |
646 reader = HighlightingStylesReader(f, self.lexers) |
645 styles = reader.readXML() |
647 styles = reader.readXML() |
646 f.close() |
648 f.close() |
647 if not styles: |
649 if not styles: |