5 |
5 |
6 """ |
6 """ |
7 Module implementing the Editor Highlighting Styles configuration page. |
7 Module implementing the Editor Highlighting Styles configuration page. |
8 """ |
8 """ |
9 |
9 |
10 import os |
10 import pathlib |
11 |
11 |
12 from PyQt6.QtCore import pyqtSlot, Qt, QFileInfo, QFile, QIODevice |
12 from PyQt6.QtCore import pyqtSlot, Qt, QFile, QIODevice |
13 from PyQt6.QtGui import QFont, QColor |
13 from PyQt6.QtGui import QFont, QColor |
14 from PyQt6.QtWidgets import ( |
14 from PyQt6.QtWidgets import ( |
15 QColorDialog, QFontDialog, QInputDialog, QMenu, QTreeWidgetItem, QDialog |
15 QColorDialog, QFontDialog, QInputDialog, QMenu, QTreeWidgetItem, QDialog |
16 ) |
16 ) |
17 |
17 |
560 EricFileDialog.DontConfirmOverwrite) |
560 EricFileDialog.DontConfirmOverwrite) |
561 |
561 |
562 if not fn: |
562 if not fn: |
563 return |
563 return |
564 |
564 |
565 ext = QFileInfo(fn).suffix() |
565 fpath = pathlib.Path(fn) |
566 if not ext: |
566 if not fpath.suffix: |
567 ex = selectedFilter.split("(*")[1].split(")")[0] |
567 ex = selectedFilter.split("(*")[1].split(")")[0] |
568 if ex: |
568 if ex: |
569 fn += ex |
569 fpath = fpath.with_suffix(ex) |
570 |
570 |
571 ok = ( |
571 ok = ( |
572 EricMessageBox.yesNo( |
572 EricMessageBox.yesNo( |
573 self, |
573 self, |
574 self.tr("Export Highlighting Styles"), |
574 self.tr("Export Highlighting Styles"), |
575 self.tr("""<p>The highlighting styles file <b>{0}</b> exists""" |
575 self.tr("""<p>The highlighting styles file <b>{0}</b> exists""" |
576 """ already. Overwrite it?</p>""").format(fn)) |
576 """ already. Overwrite it?</p>""").format(str(fpath))) |
577 if os.path.exists(fn) else |
577 if fpath.exists() else |
578 True |
578 True |
579 ) |
579 ) |
580 |
580 |
581 if ok: |
581 if ok: |
582 from Preferences.HighlightingStylesFile import ( |
582 from Preferences.HighlightingStylesFile import ( |
583 HighlightingStylesFile |
583 HighlightingStylesFile |
584 ) |
584 ) |
585 highlightingStylesFile = HighlightingStylesFile() |
585 highlightingStylesFile = HighlightingStylesFile() |
586 highlightingStylesFile.writeFile(fn, lexers) |
586 highlightingStylesFile.writeFile(str(fpath), lexers) |
587 |
587 |
588 def __importStyles(self, importAll=False): |
588 def __importStyles(self, importAll=False): |
589 """ |
589 """ |
590 Private method to import the styles of lexers to be selected. |
590 Private method to import the styles of lexers to be selected. |
591 |
591 |