eric6/Preferences/ConfigurationPages/EditorHighlightingStylesPage.py

Wed, 30 Dec 2020 11:00:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:44 +0100
branch
maintenance
changeset 7924
8a96736d465e
parent 7780
41420f82c0ac
child 8013
c3bd65c330ed
permissions
-rw-r--r--

Updated copyright for 2021.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7924
8a96736d465e Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
3 # Copyright (c) 2006 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the Editor Highlighting Styles configuration page.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
10 from PyQt5.QtCore import pyqtSlot, Qt, QFileInfo, QFile, QIODevice
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
11 from PyQt5.QtGui import QPalette, QFont
7263
c1af2e327675 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
12 from PyQt5.QtWidgets import (
c1af2e327675 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
13 QColorDialog, QFontDialog, QInputDialog, QMenu, QTreeWidgetItem, QDialog
c1af2e327675 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
14 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
16 from .ConfigurationPageBase import ConfigurationPageBase
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
17 from .Ui_EditorHighlightingStylesPage import Ui_EditorHighlightingStylesPage
6864
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
18 from ..SubstyleDefinitionDialog import SubstyleDefinitionDialog
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
20 from E5Gui import E5MessageBox, E5FileDialog
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 500
diff changeset
21
6864
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
22 import UI.PixmapCache
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
23
4698
61c0aef6a570 Added capability to select only from monospaced fonts on the highlighters styles page (for PyQt5 only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4675
diff changeset
24 try:
61c0aef6a570 Added capability to select only from monospaced fonts on the highlighters styles page (for PyQt5 only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4675
diff changeset
25 MonospacedFontsOption = QFontDialog.MonospacedFonts
61c0aef6a570 Added capability to select only from monospaced fonts on the highlighters styles page (for PyQt5 only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4675
diff changeset
26 except AttributeError:
61c0aef6a570 Added capability to select only from monospaced fonts on the highlighters styles page (for PyQt5 only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4675
diff changeset
27 MonospacedFontsOption = QFontDialog.FontDialogOptions(0x10)
61c0aef6a570 Added capability to select only from monospaced fonts on the highlighters styles page (for PyQt5 only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4675
diff changeset
28 NoFontsOption = QFontDialog.FontDialogOptions(0)
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
29
4698
61c0aef6a570 Added capability to select only from monospaced fonts on the highlighters styles page (for PyQt5 only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4675
diff changeset
30
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
31 class EditorHighlightingStylesPage(ConfigurationPageBase,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 Ui_EditorHighlightingStylesPage):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 Class implementing the Editor Highlighting Styles configuration page.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
36 FAMILYONLY = 0
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
37 SIZEONLY = 1
244
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
38 FAMILYANDSIZE = 2
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
39 FONT = 99
244
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
40
6854
f4dd76230eea PreferencesLexer, EditorHighlightingPage: got rid of the 'styles' and 'ind2style' lists (that was very old style programming).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6853
diff changeset
41 StyleRole = Qt.UserRole + 1
f4dd76230eea PreferencesLexer, EditorHighlightingPage: got rid of the 'styles' and 'ind2style' lists (that was very old style programming).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6853
diff changeset
42 SubstyleRole = Qt.UserRole + 2
f4dd76230eea PreferencesLexer, EditorHighlightingPage: got rid of the 'styles' and 'ind2style' lists (that was very old style programming).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6853
diff changeset
43
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 def __init__(self, lexers):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 @param lexers reference to the lexers dictionary
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2408
diff changeset
50 super(EditorHighlightingStylesPage, self).__init__()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 self.setupUi(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 self.setObjectName("EditorHighlightingStylesPage")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53
6878
79008f970902 EditorHighlightingStylesPage: added a button to reset the sub-styles of a base style to its default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6867
diff changeset
54 self.defaultSubstylesButton.setIcon(UI.PixmapCache.getIcon("editUndo"))
6864
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
55 self.addSubstyleButton.setIcon(UI.PixmapCache.getIcon("plus"))
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
56 self.deleteSubstyleButton.setIcon(UI.PixmapCache.getIcon("minus"))
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
57 self.editSubstyleButton.setIcon(UI.PixmapCache.getIcon("edit"))
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
58 self.copySubstyleButton.setIcon(UI.PixmapCache.getIcon("editCopy"))
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
59
244
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
60 self.__fontButtonMenu = QMenu()
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
61 act = self.__fontButtonMenu.addAction(self.tr("Font"))
244
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
62 act.setData(self.FONT)
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
63 self.__fontButtonMenu.addSeparator()
3010
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
64 act = self.__fontButtonMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
65 self.tr("Family and Size only"))
244
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
66 act.setData(self.FAMILYANDSIZE)
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
67 act = self.__fontButtonMenu.addAction(self.tr("Family only"))
244
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
68 act.setData(self.FAMILYONLY)
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
69 act = self.__fontButtonMenu.addAction(self.tr("Size only"))
244
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
70 act.setData(self.SIZEONLY)
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 454
diff changeset
71 self.__fontButtonMenu.triggered.connect(self.__fontButtonMenuTriggered)
244
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
72 self.fontButton.setMenu(self.__fontButtonMenu)
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
73
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
74 self.__allFontsButtonMenu = QMenu()
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
75 act = self.__allFontsButtonMenu.addAction(self.tr("Font"))
244
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
76 act.setData(self.FONT)
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
77 self.__allFontsButtonMenu.addSeparator()
3010
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
78 act = self.__allFontsButtonMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
79 self.tr("Family and Size only"))
244
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
80 act.setData(self.FAMILYANDSIZE)
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
81 act = self.__allFontsButtonMenu.addAction(self.tr("Family only"))
244
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
82 act.setData(self.FAMILYONLY)
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
83 act = self.__allFontsButtonMenu.addAction(self.tr("Size only"))
244
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
84 act.setData(self.SIZEONLY)
3010
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
85 self.__allFontsButtonMenu.triggered.connect(
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
86 self.__allFontsButtonMenuTriggered)
244
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
87 self.allFontsButton.setMenu(self.__allFontsButtonMenu)
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
88
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 self.lexer = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 self.lexers = lexers
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 # set initial values
5427
614e88cfbd84 Added some eye candy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
93 import QScintilla.Lexers
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
94 languages = sorted([''] + list(self.lexers.keys()))
5427
614e88cfbd84 Added some eye candy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
95 for language in languages:
614e88cfbd84 Added some eye candy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
96 self.lexerLanguageComboBox.addItem(
614e88cfbd84 Added some eye candy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
97 QScintilla.Lexers.getLanguageIcon(language, False),
614e88cfbd84 Added some eye candy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
98 language)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 self.on_lexerLanguageComboBox_activated("")
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
100
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 def save(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 Public slot to save the Editor Highlighting Styles configuration.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 """
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
105 for lexer in list(self.lexers.values()):
6853
0922aa829e5e PreferencesLexer: started to prepare it for handling of sub-style aware lexers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
106 lexer.writeSettings()
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
107
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 @pyqtSlot(str)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 def on_lexerLanguageComboBox_activated(self, language):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 Private slot to fill the style combo of the source page.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 @param language The lexer language (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 self.styleElementList.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 self.styleGroup.setEnabled(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 self.lexer = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 self.exportCurrentButton.setEnabled(language != "")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 self.importCurrentButton.setEnabled(language != "")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 if not language:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 self.lexer = self.lexers[language]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 except KeyError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 self.styleGroup.setEnabled(True)
6854
f4dd76230eea PreferencesLexer, EditorHighlightingPage: got rid of the 'styles' and 'ind2style' lists (that was very old style programming).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6853
diff changeset
131 for description, styleNo, subStyleNo in self.lexer.getStyles():
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
132 if subStyleNo >= 0:
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
133 parent = self.styleElementList.findItems(
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
134 self.lexer.description(styleNo), Qt.MatchExactly)[0]
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
135 parent.setExpanded(True)
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
136 else:
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
137 parent = self.styleElementList
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
138 itm = QTreeWidgetItem(parent, [description])
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
139 itm.setData(0, self.StyleRole, styleNo)
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
140 itm.setData(0, self.SubstyleRole, subStyleNo)
3103
451f60e70434 Made the editor highlighting styles page more colorful (i.e. show the colors and fonts in line).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
141 self.__styleAllItems()
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
142 self.styleElementList.setCurrentItem(
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
143 self.styleElementList.topLevelItem(0))
6854
f4dd76230eea PreferencesLexer, EditorHighlightingPage: got rid of the 'styles' and 'ind2style' lists (that was very old style programming).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6853
diff changeset
144
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
145 def __stylesForItem(self, itm):
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
146 """
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
147 Private method to get the style and sub-style number of the given item.
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
148
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
149 @param itm reference to the item to extract the styles from
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
150 @type QTreeWidgetItem
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
151 @return tuple containing the style and sub-style numbers
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
152 @rtype tuple of (int, int)
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
153 """
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
154 style = itm.data(0, self.StyleRole)
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
155 substyle = itm.data(0, self.SubstyleRole)
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
156
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
157 return (style, substyle)
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
158
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
159 def __currentStyles(self):
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
160 """
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
161 Private method to get the styles of the current item.
6855
4d80c8cc99a1 SubstyledLexer: continued implementing the getter and setter methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6854
diff changeset
162
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
163 @return tuple containing the style and sub-style numbers
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
164 @rtype tuple of (int, int)
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
165 """
6867
97e86d2426a9 Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6864
diff changeset
166 itm = self.styleElementList.currentItem()
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
167 if itm is None:
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
168 styles = (0, -1) # return default style
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
169 else:
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
170 styles = self.__stylesForItem(itm)
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
171
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
172 return styles
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
173
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
174 def __styleOneItem(self, item, style, substyle):
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
175 """
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
176 Private method to style one item of the style element list.
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
177
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
178 @param item reference to the item to be styled
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
179 @type QTreeWidgetItem
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
180 @param style base style number
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
181 @type int
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
182 @param substyle sub-style number
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
183 @type int
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
184 """
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
185 colour = self.lexer.color(style, substyle)
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
186 paper = self.lexer.paper(style, substyle)
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
187 font = self.lexer.font(style, substyle)
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
188 eolfill = self.lexer.eolFill(style, substyle)
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
189
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
190 item.setFont(0, font)
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
191 item.setBackground(0, paper)
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
192 item.setForeground(0, colour)
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
193 if eolfill:
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
194 item.setCheckState(0, Qt.Checked)
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
195 else:
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
196 item.setCheckState(0, Qt.Unchecked)
6855
4d80c8cc99a1 SubstyledLexer: continued implementing the getter and setter methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6854
diff changeset
197
3103
451f60e70434 Made the editor highlighting styles page more colorful (i.e. show the colors and fonts in line).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
198 def __styleAllItems(self):
451f60e70434 Made the editor highlighting styles page more colorful (i.e. show the colors and fonts in line).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
199 """
451f60e70434 Made the editor highlighting styles page more colorful (i.e. show the colors and fonts in line).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
200 Private method to style all items of the style element list.
451f60e70434 Made the editor highlighting styles page more colorful (i.e. show the colors and fonts in line).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
201 """
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
202 itm = self.styleElementList.topLevelItem(0)
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
203 while itm is not None:
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
204 style, substyle = self.__stylesForItem(itm)
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
205 self.__styleOneItem(itm, style, substyle)
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
206 itm = self.styleElementList.itemBelow(itm)
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
207
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
208 @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem)
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
209 def on_styleElementList_currentItemChanged(self, current, previous):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 """
6854
f4dd76230eea PreferencesLexer, EditorHighlightingPage: got rid of the 'styles' and 'ind2style' lists (that was very old style programming).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6853
diff changeset
211 Private method to handle a change of the current row.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
213 @param current reference to the current item
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
214 @type QTreeWidgetItem
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
215 @param previous reference to the previous item
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
216 @type QTreeWidgetItem
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 """
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
218 if current is None:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
221 style, substyle = self.__stylesForItem(current)
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
222 colour = self.lexer.color(style, substyle)
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
223 paper = self.lexer.paper(style, substyle)
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
224 eolfill = self.lexer.eolFill(style, substyle)
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
225 font = self.lexer.font(style, substyle)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 self.sampleText.setFont(font)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 pl = self.sampleText.palette()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 pl.setColor(QPalette.Text, colour)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 pl.setColor(QPalette.Base, paper)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 self.sampleText.setPalette(pl)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 self.sampleText.repaint()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 self.eolfillCheckBox.setChecked(eolfill)
6864
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
234
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
235 selectedOne = len(self.styleElementList.selectedItems()) == 1
6878
79008f970902 EditorHighlightingStylesPage: added a button to reset the sub-styles of a base style to its default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6867
diff changeset
236 self.defaultSubstylesButton.setEnabled(
79008f970902 EditorHighlightingStylesPage: added a button to reset the sub-styles of a base style to its default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6867
diff changeset
237 selectedOne and substyle < 0 and self.lexer.isBaseStyle(style))
6864
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
238 self.addSubstyleButton.setEnabled(
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
239 selectedOne and substyle < 0 and self.lexer.isBaseStyle(style))
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
240 self.deleteSubstyleButton.setEnabled(selectedOne and substyle >= 0)
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
241 self.editSubstyleButton.setEnabled(selectedOne and substyle >= 0)
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
242 self.copySubstyleButton.setEnabled(selectedOne and substyle >= 0)
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
243
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 def on_foregroundButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 """
3010
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
247 Private method used to select the foreground colour of the selected
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
248 style and lexer.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 """
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
250 style, substyle = self.__currentStyles()
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
251 colour = QColorDialog.getColor(self.lexer.color(style, substyle))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 if colour.isValid():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 pl = self.sampleText.palette()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 pl.setColor(QPalette.Text, colour)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 self.sampleText.setPalette(pl)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 self.sampleText.repaint()
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
257 for selItem in self.styleElementList.selectedItems():
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
258 style, substyle = self.__stylesForItem(selItem)
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
259 self.lexer.setColor(colour, style, substyle)
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
260 selItem.setForeground(0, colour)
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
261
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 def on_backgroundButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 """
3010
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
265 Private method used to select the background colour of the selected
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
266 style and lexer.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 """
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
268 style, substyle = self.__currentStyles()
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
269 colour = QColorDialog.getColor(self.lexer.paper(style, substyle))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 if colour.isValid():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 pl = self.sampleText.palette()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 pl.setColor(QPalette.Base, colour)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 self.sampleText.setPalette(pl)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 self.sampleText.repaint()
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
275 for selItem in self.styleElementList.selectedItems():
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
276 style, substyle = self.__stylesForItem(selItem)
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
277 self.lexer.setPaper(colour, style, substyle)
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
278 selItem.setBackground(0, colour)
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
279
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 def on_allBackgroundColoursButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
283 Private method used to select the background colour of all styles of a
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 selected lexer.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 """
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
286 style, substyle = self.__currentStyles()
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
287 colour = QColorDialog.getColor(self.lexer.paper(style, substyle))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 if colour.isValid():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 pl = self.sampleText.palette()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 pl.setColor(QPalette.Base, colour)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291 self.sampleText.setPalette(pl)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 self.sampleText.repaint()
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
293
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
294 itm = self.styleElementList.topLevelItem(0)
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
295 while itm is not None:
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
296 style, substyle = self.__stylesForItem(itm)
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
297 self.lexer.setPaper(colour, style, substyle)
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
298 itm = self.styleElementList.itemBelow(itm)
3103
451f60e70434 Made the editor highlighting styles page more colorful (i.e. show the colors and fonts in line).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
299 self.__styleAllItems()
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
300
244
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
301 def __changeFont(self, doAll, familyOnly, sizeOnly):
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
302 """
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
303 Private slot to change the highlighter font.
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
304
3010
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
305 @param doAll flag indicating to change the font for all styles
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
306 (boolean)
244
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
307 @param familyOnly flag indicating to set the font family only (boolean)
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
308 @param sizeOnly flag indicating to set the font size only (boolean
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 """
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
310 def setFont(font, style, substyle, familyOnly, sizeOnly):
244
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
311 """
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
312 Local function to set the font.
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
313
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
314 @param font font to be set
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
315 @type QFont
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
316 @param style style number
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
317 @type int
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
318 @param substyle sub-style number
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
319 @type int
3010
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
320 @param familyOnly flag indicating to set the font family only
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
321 @type bool
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
322 @param sizeOnly flag indicating to set the font size only
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
323 @type bool
244
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
324 """
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
325 if familyOnly or sizeOnly:
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
326 newFont = QFont(self.lexer.font(style))
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
327 if familyOnly:
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
328 newFont.setFamily(font.family())
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
329 if sizeOnly:
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
330 newFont.setPointSize(font.pointSize())
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
331 self.lexer.setFont(newFont, style, substyle)
244
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
332 else:
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
333 self.lexer.setFont(font, style, substyle)
244
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
334
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
335 def setSampleFont(font, familyOnly, sizeOnly):
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
336 """
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
337 Local function to set the font of the sample text.
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
338
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
339 @param font font to be set (QFont)
3010
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
340 @param familyOnly flag indicating to set the font family only
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
341 (boolean)
244
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
342 @param sizeOnly flag indicating to set the font size only (boolean
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
343 """
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
344 if familyOnly or sizeOnly:
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
345 style, substyle = self.__currentStyles()
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
346 newFont = QFont(self.lexer.font(style, substyle))
244
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
347 if familyOnly:
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
348 newFont.setFamily(font.family())
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
349 if sizeOnly:
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
350 newFont.setPointSize(font.pointSize())
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
351 self.sampleText.setFont(newFont)
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
352 else:
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
353 self.sampleText.setFont(font)
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
354
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
355 style, substyle = self.__currentStyles()
4698
61c0aef6a570 Added capability to select only from monospaced fonts on the highlighters styles page (for PyQt5 only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4675
diff changeset
356 if self.monospacedButton.isChecked():
61c0aef6a570 Added capability to select only from monospaced fonts on the highlighters styles page (for PyQt5 only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4675
diff changeset
357 options = MonospacedFontsOption
61c0aef6a570 Added capability to select only from monospaced fonts on the highlighters styles page (for PyQt5 only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4675
diff changeset
358 else:
61c0aef6a570 Added capability to select only from monospaced fonts on the highlighters styles page (for PyQt5 only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4675
diff changeset
359 options = NoFontsOption
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
360 font, ok = QFontDialog.getFont(self.lexer.font(style, substyle), self,
4698
61c0aef6a570 Added capability to select only from monospaced fonts on the highlighters styles page (for PyQt5 only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4675
diff changeset
361 "", options)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362 if ok:
244
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
363 setSampleFont(font, familyOnly, sizeOnly)
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
364 if doAll:
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
365 itm = self.styleElementList.topLevelItem(0)
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
366 while itm is not None:
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
367 style, substyle = self.__stylesForItem(itm)
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
368 setFont(font, style, substyle, familyOnly, sizeOnly)
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
369 itm = self.styleElementList.itemBelow(itm)
3103
451f60e70434 Made the editor highlighting styles page more colorful (i.e. show the colors and fonts in line).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
370 self.__styleAllItems()
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
371 else:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
372 for selItem in self.styleElementList.selectedItems():
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
373 style, substyle = self.__stylesForItem(selItem)
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
374 setFont(font, style, substyle, familyOnly, sizeOnly)
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
375 itmFont = self.lexer.font(style, substyle)
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
376 selItem.setFont(0, itmFont)
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
377
244
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
378 def __fontButtonMenuTriggered(self, act):
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
379 """
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
380 Private slot used to select the font of the selected style and lexer.
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
381
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
382 @param act reference to the triggering action (QAction)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383 """
244
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
384 if act is None:
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
385 return
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
386
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
387 familyOnly = act.data() in [self.FAMILYANDSIZE, self.FAMILYONLY]
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
388 sizeOnly = act.data() in [self.FAMILYANDSIZE, self.SIZEONLY]
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
389 self.__changeFont(False, familyOnly, sizeOnly)
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
390
244
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
391 def __allFontsButtonMenuTriggered(self, act):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392 """
244
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
393 Private slot used to change the font of all styles of a selected lexer.
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
394
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
395 @param act reference to the triggering action (QAction)
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
396 """
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
397 if act is None:
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
398 return
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
399
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
400 familyOnly = act.data() in [self.FAMILYANDSIZE, self.FAMILYONLY]
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
401 sizeOnly = act.data() in [self.FAMILYANDSIZE, self.SIZEONLY]
30be2b4a9721 Added a menu to the highlighting styles config page to change individual aspects of a font only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
402 self.__changeFont(True, familyOnly, sizeOnly)
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
403
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
404 @pyqtSlot(bool)
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
405 def on_eolfillCheckBox_clicked(self, on):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406 """
3010
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
407 Private method used to set the eolfill for the selected style and
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
408 lexer.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409
3107
5b496e690984 Another little enhancement to the highlighter style config page to show the eol-fill status in the style list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3103
diff changeset
410 @param on flag indicating enabled or disabled state (boolean)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
411 """
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
412 style, substyle = self.__currentStyles()
3107
5b496e690984 Another little enhancement to the highlighter style config page to show the eol-fill status in the style list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3103
diff changeset
413 checkState = Qt.Checked if on else Qt.Unchecked
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
414 for selItem in self.styleElementList.selectedItems():
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
415 style, substyle = self.__stylesForItem(selItem)
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
416 self.lexer.setEolFill(on, style, substyle)
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
417 selItem.setCheckState(0, checkState)
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
418
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
419 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
420 def on_allEolFillButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
421 """
3010
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
422 Private method used to set the eolfill for all styles of a selected
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
423 lexer.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
424 """
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
425 on = self.tr("Enabled")
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
426 off = self.tr("Disabled")
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 537
diff changeset
427 selection, ok = QInputDialog.getItem(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
428 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
429 self.tr("Fill to end of line"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
430 self.tr("Select fill to end of line for all styles"),
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
431 [on, off],
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
432 0, False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
433 if ok:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
434 enabled = selection == on
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
435 self.eolfillCheckBox.setChecked(enabled)
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
436
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
437 itm = self.styleElementList.topLevelItem(0)
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
438 while itm is not None:
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
439 style, substyle = self.__stylesForItem(itm)
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
440 self.lexer.setEolFill(enabled, style, substyle)
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
441 itm = self.styleElementList.itemBelow(itm)
3107
5b496e690984 Another little enhancement to the highlighter style config page to show the eol-fill status in the style list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3103
diff changeset
442 self.__styleAllItems()
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
443
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
444 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
445 def on_defaultButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
446 """
2763
e4794166ad70 Fixed a serious typo.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2408
diff changeset
447 Private method to set the current style to its default values.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
448 """
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
449 for selItem in self.styleElementList.selectedItems():
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
450 style, substyle = self.__stylesForItem(selItem)
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
451 self.__setToDefault(style, substyle)
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
452 self.on_styleElementList_currentItemChanged(
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
453 self.styleElementList.currentItem(), None)
3103
451f60e70434 Made the editor highlighting styles page more colorful (i.e. show the colors and fonts in line).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
454 self.__styleAllItems()
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
455
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
456 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
457 def on_allDefaultButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
458 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
459 Private method to set all styles to their default values.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
460 """
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
461 itm = self.styleElementList.topLevelItem(0)
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
462 while itm is not None:
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
463 style, substyle = self.__stylesForItem(itm)
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
464 self.__setToDefault(style, substyle)
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
465 itm = self.styleElementList.itemBelow(itm)
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
466 self.on_styleElementList_currentItemChanged(
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
467 self.styleElementList.currentItem(), None)
3103
451f60e70434 Made the editor highlighting styles page more colorful (i.e. show the colors and fonts in line).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
468 self.__styleAllItems()
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
469
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
470 def __setToDefault(self, style, substyle):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
471 """
2763
e4794166ad70 Fixed a serious typo.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2408
diff changeset
472 Private method to set a specific style to its default values.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
473
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
474 @param style style number
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
475 @type int
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
476 @param substyle sub-style number
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
477 @type int
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
478 """
6860
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
479 self.lexer.setColor(self.lexer.defaultColor(style, substyle),
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
480 style, substyle)
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
481 self.lexer.setPaper(self.lexer.defaultPaper(style, substyle),
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
482 style, substyle)
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
483 self.lexer.setFont(self.lexer.defaultFont(style, substyle),
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
484 style, substyle)
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
485 self.lexer.setEolFill(self.lexer.defaultEolFill(style, substyle),
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
486 style, substyle)
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
487
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
488 #######################################################################
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
489 ## Importing and exporting of styles
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
490 #######################################################################
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
491
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
492 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
493 def on_importCurrentButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
494 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
495 Private slot to import the styles of the current lexer.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
496 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
497 self.__importStyles({self.lexer.language(): self.lexer})
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
498
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
499 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
500 def on_exportCurrentButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
501 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
502 Private slot to export the styles of the current lexer.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
503 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
504 self.__exportStyles([self.lexer])
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
505
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
506 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
507 def on_importAllButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
508 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
509 Private slot to import the styles of all lexers.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
510 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
511 self.__importStyles(self.lexers)
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
512
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
513 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
514 def on_exportAllButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
515 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
516 Private slot to export the styles of all lexers.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
517 """
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
518 self.__exportStyles(list(self.lexers.values()))
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
519
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
520 def __exportStyles(self, lexers):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
521 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
522 Private method to export the styles of the given lexers.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
523
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
524 @param lexers list of lexer objects for which to export the styles
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
525 """
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
526 from eric6config import getConfig
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
527 stylesDir = getConfig("ericStylesDir")
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
528
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
529 fn, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
530 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
531 self.tr("Export Highlighting Styles"),
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
532 stylesDir,
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
533 self.tr("Highlighting styles file (*.e6h)"),
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
534 "",
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
535 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
536
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
537 if not fn:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
538 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
539
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
540 ext = QFileInfo(fn).suffix()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
541 if not ext:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
542 ex = selectedFilter.split("(*")[1].split(")")[0]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
543 if ex:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
544 fn += ex
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
545
593
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
546 f = QFile(fn)
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
547 if f.open(QIODevice.WriteOnly):
2408
dc3a7c9d8f6e Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
548 from E5XML.HighlightingStylesWriter import HighlightingStylesWriter
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
549 HighlightingStylesWriter(f, lexers).writeXML()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
550 f.close()
593
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
551 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3010
diff changeset
552 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3010
diff changeset
553 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
554 self.tr("Export Highlighting Styles"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
555 self.tr(
3010
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
556 """<p>The highlighting styles could not be exported"""
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
557 """ to file <b>{0}</b>.</p><p>Reason: {1}</p>""")
3038
7fe9a53280bd Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
558 .format(fn, f.errorString())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
559 )
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
560
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
561 def __importStyles(self, lexers):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
562 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
563 Private method to import the styles of the given lexers.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
564
3010
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
565 @param lexers dictionary of lexer objects for which to import the
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
566 styles
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
567 """
5976
549918576245 Added a dark style (*.qss and Python lexers) provided by Giuseppe Corbelli.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
568 from eric6config import getConfig
549918576245 Added a dark style (*.qss and Python lexers) provided by Giuseppe Corbelli.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
569 stylesDir = getConfig("ericStylesDir")
549918576245 Added a dark style (*.qss and Python lexers) provided by Giuseppe Corbelli.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
570
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
571 fn = E5FileDialog.getOpenFileName(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
572 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
573 self.tr("Import Highlighting Styles"),
5976
549918576245 Added a dark style (*.qss and Python lexers) provided by Giuseppe Corbelli.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
574 stylesDir,
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
575 self.tr("Highlighting styles file (*.e6h *.e4h)"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
576
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
577 if not fn:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
578 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
579
593
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
580 f = QFile(fn)
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
581 if f.open(QIODevice.ReadOnly):
2408
dc3a7c9d8f6e Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
582 from E5XML.HighlightingStylesReader import HighlightingStylesReader
593
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
583 reader = HighlightingStylesReader(f, lexers)
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
584 reader.readXML()
594
cded89ee3e30 Added forgotten close() statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 593
diff changeset
585 f.close()
593
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
586 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3010
diff changeset
587 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3010
diff changeset
588 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
589 self.tr("Import Highlighting Styles"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
590 self.tr(
3010
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
591 """<p>The highlighting styles could not be read"""
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
592 """ from file <b>{0}</b>.</p><p>Reason: {1}</p>""")
3038
7fe9a53280bd Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
593 .format(fn, f.errorString())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
594 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
595 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
596
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
597 self.on_lexerLanguageComboBox_activated(
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
598 self.lexerLanguageComboBox.currentText())
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
599
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
600 #######################################################################
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
601 ## Methods to save and restore the state
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
602 #######################################################################
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
603
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
604 def saveState(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
605 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
606 Public method to save the current state of the widget.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
607
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
608 @return list containing the index of the selected lexer language
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
609 and a tuple containing the index of the parent selected lexer
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
610 entry and the index of the selected entry
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
611 @rtype list of int and tuple of (int, int)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
612 """
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
613 itm = self.styleElementList.currentItem()
7743
817a81a2e6aa Editor: added support for TOML files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
614 if itm:
817a81a2e6aa Editor: added support for TOML files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
615 parent = itm.parent()
817a81a2e6aa Editor: added support for TOML files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
616 if parent is None:
817a81a2e6aa Editor: added support for TOML files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
617 currentData = (
817a81a2e6aa Editor: added support for TOML files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
618 None, self.styleElementList.indexOfTopLevelItem(itm))
817a81a2e6aa Editor: added support for TOML files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
619 else:
817a81a2e6aa Editor: added support for TOML files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
620 currentData = (
817a81a2e6aa Editor: added support for TOML files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
621 self.styleElementList.indexOfTopLevelItem(parent),
817a81a2e6aa Editor: added support for TOML files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
622 parent.indexOfChild(itm)
817a81a2e6aa Editor: added support for TOML files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
623 )
817a81a2e6aa Editor: added support for TOML files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
624
817a81a2e6aa Editor: added support for TOML files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
625 savedState = [
817a81a2e6aa Editor: added support for TOML files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
626 self.lexerLanguageComboBox.currentIndex(),
817a81a2e6aa Editor: added support for TOML files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
627 currentData,
817a81a2e6aa Editor: added support for TOML files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
628 ]
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
629 else:
7743
817a81a2e6aa Editor: added support for TOML files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
630 savedState = []
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
631 return savedState
6862
6f4237ccf576 EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6860
diff changeset
632
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
633 def setState(self, state):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
634 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
635 Public method to set the state of the widget.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
636
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
637 @param state state data generated by saveState
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
638 """
7743
817a81a2e6aa Editor: added support for TOML files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
639 if state:
817a81a2e6aa Editor: added support for TOML files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
640 self.lexerLanguageComboBox.setCurrentIndex(state[0])
817a81a2e6aa Editor: added support for TOML files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
641 self.on_lexerLanguageComboBox_activated(
817a81a2e6aa Editor: added support for TOML files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
642 self.lexerLanguageComboBox.currentText())
817a81a2e6aa Editor: added support for TOML files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
643
817a81a2e6aa Editor: added support for TOML files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
644 parentIndex, index = state[1]
817a81a2e6aa Editor: added support for TOML files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
645 if parentIndex is None:
817a81a2e6aa Editor: added support for TOML files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
646 itm = self.styleElementList.topLevelItem(index)
817a81a2e6aa Editor: added support for TOML files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
647 else:
817a81a2e6aa Editor: added support for TOML files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
648 parent = self.styleElementList.topLevelItem(parentIndex)
817a81a2e6aa Editor: added support for TOML files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
649 itm = parent.child(index)
817a81a2e6aa Editor: added support for TOML files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
650 self.styleElementList.setCurrentItem(itm)
6864
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
651
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
652 #######################################################################
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
653 ## Methods to add, delete and edit sub-styles and their definitions
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
654 #######################################################################
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
655
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
656 @pyqtSlot()
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
657 def on_addSubstyleButton_clicked(self):
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
658 """
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
659 Private slot to add a new sub-style.
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
660 """
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
661 style, substyle = self.__currentStyles()
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
662 dlg = SubstyleDefinitionDialog(
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
663 self.lexer, style, substyle, parent=self)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7743
diff changeset
664 if dlg.exec() == QDialog.Accepted:
6864
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
665 description, words = dlg.getData()
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
666 substyle = self.lexer.addSubstyle(style)
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
667 self.lexer.setDescription(description, style, substyle)
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
668 self.lexer.setWords(words, style, substyle)
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
669
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
670 parent = self.styleElementList.findItems(
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
671 self.lexer.description(style), Qt.MatchExactly)[0]
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
672 parent.setExpanded(True)
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
673 itm = QTreeWidgetItem(parent, [description])
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
674 itm.setData(0, self.StyleRole, style)
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
675 itm.setData(0, self.SubstyleRole, substyle)
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
676 self.__styleOneItem(itm, style, substyle)
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
677
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
678 @pyqtSlot()
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
679 def on_deleteSubstyleButton_clicked(self):
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
680 """
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
681 Private slot to delete the selected sub-style.
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
682 """
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
683 style, substyle = self.__currentStyles()
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
684 ok = E5MessageBox.yesNo(
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
685 self,
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
686 self.tr("Delete Sub-Style"),
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
687 self.tr("""<p>Shall the sub-style <b>{0}</b> really be"""
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
688 """ deleted?</p>""").format(
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
689 self.lexer.description(style, substyle))
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
690 )
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
691 if ok:
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
692 self.lexer.delSubstyle(style, substyle)
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
693
6867
97e86d2426a9 Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6864
diff changeset
694 itm = self.styleElementList.currentItem()
6864
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
695 parent = itm.parent()
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
696 index = parent.indexOfChild(itm)
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
697 parent.takeChild(index)
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
698 del itm
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
699
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
700 @pyqtSlot()
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
701 def on_editSubstyleButton_clicked(self):
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
702 """
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
703 Private slot to edit the selected sub-style entry.
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
704 """
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
705 style, substyle = self.__currentStyles()
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
706 dlg = SubstyleDefinitionDialog(
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
707 self.lexer, style, substyle, parent=self)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7743
diff changeset
708 if dlg.exec() == QDialog.Accepted:
6864
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
709 description, words = dlg.getData()
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
710 self.lexer.setDescription(description, style, substyle)
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
711 self.lexer.setWords(words, style, substyle)
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
712
6867
97e86d2426a9 Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6864
diff changeset
713 itm = self.styleElementList.currentItem()
6864
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
714 itm.setText(0, description)
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
715
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
716 @pyqtSlot()
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
717 def on_copySubstyleButton_clicked(self):
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
718 """
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
719 Private slot to copy the selected sub-style.
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
720 """
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
721 style, substyle = self.__currentStyles()
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
722 newSubstyle = self.lexer.addSubstyle(style)
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
723
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
724 description = self.tr("{0} - Copy").format(
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
725 self.lexer.description(style, substyle))
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
726 self.lexer.setDescription(description, style, newSubstyle)
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
727 self.lexer.setWords(self.lexer.words(style, substyle),
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
728 style, newSubstyle)
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
729 self.lexer.setColor(self.lexer.color(style, substyle),
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
730 style, newSubstyle)
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
731 self.lexer.setPaper(self.lexer.paper(style, substyle),
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
732 style, newSubstyle)
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
733 self.lexer.setFont(self.lexer.font(style, substyle),
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
734 style, newSubstyle)
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
735 self.lexer.setEolFill(self.lexer.eolFill(style, substyle),
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
736 style, newSubstyle)
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
737
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
738 parent = self.styleElementList.findItems(
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
739 self.lexer.description(style), Qt.MatchExactly)[0]
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
740 parent.setExpanded(True)
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
741 itm = QTreeWidgetItem(parent, [description])
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
742 itm.setData(0, self.StyleRole, style)
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
743 itm.setData(0, self.SubstyleRole, newSubstyle)
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6862
diff changeset
744 self.__styleOneItem(itm, style, newSubstyle)
6878
79008f970902 EditorHighlightingStylesPage: added a button to reset the sub-styles of a base style to its default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6867
diff changeset
745
79008f970902 EditorHighlightingStylesPage: added a button to reset the sub-styles of a base style to its default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6867
diff changeset
746 @pyqtSlot()
79008f970902 EditorHighlightingStylesPage: added a button to reset the sub-styles of a base style to its default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6867
diff changeset
747 def on_defaultSubstylesButton_clicked(self):
79008f970902 EditorHighlightingStylesPage: added a button to reset the sub-styles of a base style to its default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6867
diff changeset
748 """
79008f970902 EditorHighlightingStylesPage: added a button to reset the sub-styles of a base style to its default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6867
diff changeset
749 Private slot to reset all substyles to default values.
79008f970902 EditorHighlightingStylesPage: added a button to reset the sub-styles of a base style to its default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6867
diff changeset
750 """
79008f970902 EditorHighlightingStylesPage: added a button to reset the sub-styles of a base style to its default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6867
diff changeset
751 style, substyle = self.__currentStyles()
79008f970902 EditorHighlightingStylesPage: added a button to reset the sub-styles of a base style to its default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6867
diff changeset
752 ok = E5MessageBox.yesNo(
79008f970902 EditorHighlightingStylesPage: added a button to reset the sub-styles of a base style to its default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6867
diff changeset
753 self,
79008f970902 EditorHighlightingStylesPage: added a button to reset the sub-styles of a base style to its default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6867
diff changeset
754 self.tr("Reset Sub-Styles to Default"),
79008f970902 EditorHighlightingStylesPage: added a button to reset the sub-styles of a base style to its default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6867
diff changeset
755 self.tr("<p>Do you really want to reset all defined sub-styles of"
6883
57a2dc333cea Fixed a code style issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6878
diff changeset
756 " <b>{0}</b> to the default values?</p>""")
57a2dc333cea Fixed a code style issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6878
diff changeset
757 .format(self.lexer.description(style, substyle))
57a2dc333cea Fixed a code style issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6878
diff changeset
758 )
6878
79008f970902 EditorHighlightingStylesPage: added a button to reset the sub-styles of a base style to its default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6867
diff changeset
759 if ok:
79008f970902 EditorHighlightingStylesPage: added a button to reset the sub-styles of a base style to its default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6867
diff changeset
760 # 1. reset sub-styles
79008f970902 EditorHighlightingStylesPage: added a button to reset the sub-styles of a base style to its default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6867
diff changeset
761 self.lexer.loadDefaultSubStyles(style)
79008f970902 EditorHighlightingStylesPage: added a button to reset the sub-styles of a base style to its default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6867
diff changeset
762
79008f970902 EditorHighlightingStylesPage: added a button to reset the sub-styles of a base style to its default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6867
diff changeset
763 # 2. delete all existing sub-style items
79008f970902 EditorHighlightingStylesPage: added a button to reset the sub-styles of a base style to its default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6867
diff changeset
764 parent = self.styleElementList.currentItem()
79008f970902 EditorHighlightingStylesPage: added a button to reset the sub-styles of a base style to its default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6867
diff changeset
765 while parent.childCount() > 0:
79008f970902 EditorHighlightingStylesPage: added a button to reset the sub-styles of a base style to its default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6867
diff changeset
766 itm = parent.takeChild(0) # __IGNORE_WARNING__
79008f970902 EditorHighlightingStylesPage: added a button to reset the sub-styles of a base style to its default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6867
diff changeset
767 del itm
79008f970902 EditorHighlightingStylesPage: added a button to reset the sub-styles of a base style to its default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6867
diff changeset
768
79008f970902 EditorHighlightingStylesPage: added a button to reset the sub-styles of a base style to its default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6867
diff changeset
769 # 3. create the new list of sub-style items
79008f970902 EditorHighlightingStylesPage: added a button to reset the sub-styles of a base style to its default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6867
diff changeset
770 for description, _, substyle in self.lexer.getSubStyles(style):
79008f970902 EditorHighlightingStylesPage: added a button to reset the sub-styles of a base style to its default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6867
diff changeset
771 itm = QTreeWidgetItem(parent, [description])
79008f970902 EditorHighlightingStylesPage: added a button to reset the sub-styles of a base style to its default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6867
diff changeset
772 itm.setData(0, self.StyleRole, style)
79008f970902 EditorHighlightingStylesPage: added a button to reset the sub-styles of a base style to its default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6867
diff changeset
773 itm.setData(0, self.SubstyleRole, substyle)
79008f970902 EditorHighlightingStylesPage: added a button to reset the sub-styles of a base style to its default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6867
diff changeset
774 self.__styleOneItem(itm, style, substyle)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
775
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
776
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
777 def create(dlg):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
778 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
779 Module function to create the configuration page.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
780
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
781 @param dlg reference to the configuration dialog
2964
84b65fb9e780 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2763
diff changeset
782 @return reference to the instantiated page (ConfigurationPageBase)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
783 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
784 page = EditorHighlightingStylesPage(dlg.getLexers())
593
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
785 return page

eric ide

mercurial