17 |
17 |
18 from .ConfigurationPageBase import ConfigurationPageBase |
18 from .ConfigurationPageBase import ConfigurationPageBase |
19 from .Ui_EditorHighlightingStylesPage import Ui_EditorHighlightingStylesPage |
19 from .Ui_EditorHighlightingStylesPage import Ui_EditorHighlightingStylesPage |
20 from ..SubstyleDefinitionDialog import SubstyleDefinitionDialog |
20 from ..SubstyleDefinitionDialog import SubstyleDefinitionDialog |
21 |
21 |
22 from E5Gui import E5MessageBox, E5FileDialog |
22 from E5Gui import EricMessageBox, EricFileDialog |
23 |
23 |
24 import UI.PixmapCache |
24 import UI.PixmapCache |
25 |
25 |
26 |
26 |
27 class EditorHighlightingStylesPage(ConfigurationPageBase, |
27 class EditorHighlightingStylesPage(ConfigurationPageBase, |
540 # Cancelled by user |
540 # Cancelled by user |
541 return |
541 return |
542 |
542 |
543 lexers = [self.lexers[name] for name in lexerNames] |
543 lexers = [self.lexers[name] for name in lexerNames] |
544 |
544 |
545 fn, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( |
545 fn, selectedFilter = EricFileDialog.getSaveFileNameAndFilter( |
546 self, |
546 self, |
547 self.tr("Export Highlighting Styles"), |
547 self.tr("Export Highlighting Styles"), |
548 stylesDir, |
548 stylesDir, |
549 self.tr("Highlighting Styles File (*.ehj)"), |
549 self.tr("Highlighting Styles File (*.ehj)"), |
550 "", |
550 "", |
551 E5FileDialog.DontConfirmOverwrite) |
551 EricFileDialog.DontConfirmOverwrite) |
552 |
552 |
553 if not fn: |
553 if not fn: |
554 return |
554 return |
555 |
555 |
556 ext = QFileInfo(fn).suffix() |
556 ext = QFileInfo(fn).suffix() |
558 ex = selectedFilter.split("(*")[1].split(")")[0] |
558 ex = selectedFilter.split("(*")[1].split(")")[0] |
559 if ex: |
559 if ex: |
560 fn += ex |
560 fn += ex |
561 |
561 |
562 ok = ( |
562 ok = ( |
563 E5MessageBox.yesNo( |
563 EricMessageBox.yesNo( |
564 self, |
564 self, |
565 self.tr("Export Highlighting Styles"), |
565 self.tr("Export Highlighting Styles"), |
566 self.tr("""<p>The highlighting styles file <b>{0}</b> exists""" |
566 self.tr("""<p>The highlighting styles file <b>{0}</b> exists""" |
567 """ already. Overwrite it?</p>""").format(fn)) |
567 """ already. Overwrite it?</p>""").format(fn)) |
568 if os.path.exists(fn) else |
568 if os.path.exists(fn) else |
584 @type bool (optional) |
584 @type bool (optional) |
585 """ |
585 """ |
586 from eric7config import getConfig |
586 from eric7config import getConfig |
587 stylesDir = getConfig("ericStylesDir") |
587 stylesDir = getConfig("ericStylesDir") |
588 |
588 |
589 fn = E5FileDialog.getOpenFileName( |
589 fn = EricFileDialog.getOpenFileName( |
590 self, |
590 self, |
591 self.tr("Import Highlighting Styles"), |
591 self.tr("Import Highlighting Styles"), |
592 stylesDir, |
592 stylesDir, |
593 self.tr("Highlighting Styles File (*.ehj);;" |
593 self.tr("Highlighting Styles File (*.ehj);;" |
594 "XML Highlighting Styles File (*.e6h *.e4h)")) |
594 "XML Highlighting Styles File (*.e6h *.e4h)")) |
616 styles = reader.readXML() |
616 styles = reader.readXML() |
617 f.close() |
617 f.close() |
618 if not styles: |
618 if not styles: |
619 return |
619 return |
620 else: |
620 else: |
621 E5MessageBox.critical( |
621 EricMessageBox.critical( |
622 self, |
622 self, |
623 self.tr("Import Highlighting Styles"), |
623 self.tr("Import Highlighting Styles"), |
624 self.tr( |
624 self.tr( |
625 "<p>The highlighting styles file <b>{0}</b> could not" |
625 "<p>The highlighting styles file <b>{0}</b> could not" |
626 " be read.</p><p>Reason: {1}</p>" |
626 " be read.</p><p>Reason: {1}</p>" |
757 def on_deleteSubstyleButton_clicked(self): |
757 def on_deleteSubstyleButton_clicked(self): |
758 """ |
758 """ |
759 Private slot to delete the selected sub-style. |
759 Private slot to delete the selected sub-style. |
760 """ |
760 """ |
761 style, substyle = self.__currentStyles() |
761 style, substyle = self.__currentStyles() |
762 ok = E5MessageBox.yesNo( |
762 ok = EricMessageBox.yesNo( |
763 self, |
763 self, |
764 self.tr("Delete Sub-Style"), |
764 self.tr("Delete Sub-Style"), |
765 self.tr("""<p>Shall the sub-style <b>{0}</b> really be""" |
765 self.tr("""<p>Shall the sub-style <b>{0}</b> really be""" |
766 """ deleted?</p>""").format( |
766 """ deleted?</p>""").format( |
767 self.lexer.description(style, substyle)) |
767 self.lexer.description(style, substyle)) |
825 def on_defaultSubstylesButton_clicked(self): |
825 def on_defaultSubstylesButton_clicked(self): |
826 """ |
826 """ |
827 Private slot to reset all substyles to default values. |
827 Private slot to reset all substyles to default values. |
828 """ |
828 """ |
829 style, substyle = self.__currentStyles() |
829 style, substyle = self.__currentStyles() |
830 ok = E5MessageBox.yesNo( |
830 ok = EricMessageBox.yesNo( |
831 self, |
831 self, |
832 self.tr("Reset Sub-Styles to Default"), |
832 self.tr("Reset Sub-Styles to Default"), |
833 self.tr("<p>Do you really want to reset all defined sub-styles of" |
833 self.tr("<p>Do you really want to reset all defined sub-styles of" |
834 " <b>{0}</b> to the default values?</p>""") |
834 " <b>{0}</b> to the default values?</p>""") |
835 .format(self.lexer.description(style, substyle)) |
835 .format(self.lexer.description(style, substyle)) |