Preferences/ConfigurationPages/EditorHighlightingStylesPage.py

Sat, 16 Mar 2019 14:10:51 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 16 Mar 2019 14:10:51 +0100
branch
sub_styles
changeset 6862
6f4237ccf576
parent 6860
50069cc0ee49
child 6864
7837ab17f079
permissions
-rw-r--r--

EditorHighlightingStylesPage: converted the styles list to QTreeWidget in order to show sub-styles indented.

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
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
3 # Copyright (c) 2006 - 2019 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
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3142
diff changeset
10 from __future__ import unicode_literals
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
11
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
12 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
13 from PyQt5.QtGui import QPalette, QFont
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
14 from PyQt5.QtWidgets import QColorDialog, QFontDialog, QInputDialog, QMenu, \
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
15 QTreeWidgetItem
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
17 from .ConfigurationPageBase import ConfigurationPageBase
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
18 from .Ui_EditorHighlightingStylesPage import Ui_EditorHighlightingStylesPage
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
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
22 from Globals import qVersionTuple
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
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
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
54 if qVersionTuple() < (5, 0, 0):
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
55 self.monospacedButton.setChecked(False)
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
56 self.monospacedButton.hide()
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
57
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
58 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
59 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
60 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
61 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
62 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
63 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
64 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
65 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
66 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
67 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
68 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
69 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
70 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
71
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.__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
73 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
74 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
75 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
76 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
77 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
78 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
79 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
80 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
81 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
82 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
83 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
84 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
85 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
86
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 self.lexer = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 self.lexers = lexers
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 # set initial values
5427
614e88cfbd84 Added some eye candy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
91 import QScintilla.Lexers
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
92 languages = sorted([''] + list(self.lexers.keys()))
5427
614e88cfbd84 Added some eye candy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
93 for language in languages:
614e88cfbd84 Added some eye candy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
94 self.lexerLanguageComboBox.addItem(
614e88cfbd84 Added some eye candy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
95 QScintilla.Lexers.getLanguageIcon(language, False),
614e88cfbd84 Added some eye candy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
96 language)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 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
98
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 def save(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 Public slot to save the Editor Highlighting Styles configuration.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 """
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
103 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
104 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
105
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 @pyqtSlot(str)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 def on_lexerLanguageComboBox_activated(self, language):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 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
110
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 @param language The lexer language (string)
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 self.styleElementList.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 self.styleGroup.setEnabled(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 self.lexer = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 self.exportCurrentButton.setEnabled(language != "")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 self.importCurrentButton.setEnabled(language != "")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 if not language:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 self.lexer = self.lexers[language]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 except KeyError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 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
129 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
130 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
131 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
132 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
133 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
134 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
135 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
136 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
137 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
138 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
139 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
140 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
141 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
142
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
143 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
144 """
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 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
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 @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
148 @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
149 @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
150 @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
151 """
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
152 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
153 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
154
50069cc0ee49 EditorHighlightingStylesPage: added support for sub-styles and adjusted code to today's Qt.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6855
diff changeset
155 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
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 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
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 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
160
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
161 @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
162 @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
163 """
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 itm = self.styleElementList.currentItem()
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 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
166 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
167 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
168 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
169
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 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
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 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
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 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
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 @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
177 @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
178 @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
179 @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
180 @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
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 """
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 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
184 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
185 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
186 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
187
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
188 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
189 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
190 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
191 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
192 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
193 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
194 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
195
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
196 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
197 """
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 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
199 """
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
200 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
201 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
202 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
203 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
204 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
205
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 @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
207 def on_styleElementList_currentItemChanged(self, current, previous):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 """
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
209 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
210
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
211 @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
212 @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
213 @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
214 @type QTreeWidgetItem
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 """
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
216 if current is None:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218
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
219 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
220 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
221 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
222 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
223 font = self.lexer.font(style, substyle)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 self.sampleText.setFont(font)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 pl = self.sampleText.palette()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 pl.setColor(QPalette.Text, colour)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 pl.setColor(QPalette.Base, paper)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 self.sampleText.setPalette(pl)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 self.sampleText.repaint()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 self.eolfillCheckBox.setChecked(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
232
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 def on_foregroundButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 """
3010
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
236 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
237 style and lexer.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 """
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
239 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
240 colour = QColorDialog.getColor(self.lexer.color(style, substyle))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 if colour.isValid():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 pl = self.sampleText.palette()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 pl.setColor(QPalette.Text, colour)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 self.sampleText.setPalette(pl)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 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
246 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
247 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
248 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
249 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
250
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 def on_backgroundButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 """
3010
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
254 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
255 style and lexer.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 """
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 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
258 colour = QColorDialog.getColor(self.lexer.paper(style, substyle))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 if colour.isValid():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 pl = self.sampleText.palette()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 pl.setColor(QPalette.Base, colour)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 self.sampleText.setPalette(pl)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 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
264 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
265 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
266 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
267 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
268
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 def on_allBackgroundColoursButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
272 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
273 selected lexer.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 """
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 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
276 colour = QColorDialog.getColor(self.lexer.paper(style, substyle))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 if colour.isValid():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 pl = self.sampleText.palette()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 pl.setColor(QPalette.Base, colour)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 self.sampleText.setPalette(pl)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 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
282
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
283 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
284 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
285 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
286 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
287 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
288 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
289
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
290 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
291 """
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
292 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
293
3010
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
294 @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
295 (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
296 @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
297 @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
298 """
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
299 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
300 """
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 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
302
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
303 @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
304 @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
305 @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
306 @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
307 @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
308 @type int
3010
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
309 @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
310 @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
311 @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
312 @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
313 """
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
314 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
315 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
316 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
317 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
318 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
319 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
320 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
321 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
322 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
323
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 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
325 """
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 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
327
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 @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
329 @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
330 (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
331 @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
332 """
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
333 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
334 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
335 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
336 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
337 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
338 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
339 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
340 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
341 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
342 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
343
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
344 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
345 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
346 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
347 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
348 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
349 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
350 "", options)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
351 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
352 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
353 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
354 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
355 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
356 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
357 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
358 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
359 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
360 else:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361 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
362 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
363 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
364 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
365 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
366
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
367 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
368 """
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
369 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
370
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
371 @param act reference to the triggering action (QAction)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
372 """
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
373 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
374 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
375
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
376 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
377 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
378 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
379
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
380 def __allFontsButtonMenuTriggered(self, act):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381 """
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
382 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
383
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 @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
385 """
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 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
387 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
388
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 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
390 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
391 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
392
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
393 @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
394 def on_eolfillCheckBox_clicked(self, on):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395 """
3010
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
396 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
397 lexer.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
398
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
399 @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
400 """
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
401 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
402 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
403 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
404 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
405 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
406 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
407
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409 def on_allEolFillButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
410 """
3010
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
411 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
412 lexer.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
413 """
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
414 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
415 off = self.tr("Disabled")
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 537
diff changeset
416 selection, ok = QInputDialog.getItem(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
417 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
418 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
419 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
420 [on, off],
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
421 0, False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
422 if ok:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
423 enabled = selection == on
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
424 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
425
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
426 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
427 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
428 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
429 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
430 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
431 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
432
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
433 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
434 def on_defaultButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
435 """
2763
e4794166ad70 Fixed a serious typo.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2408
diff changeset
436 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
437 """
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
438 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
439 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
440 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
441 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
442 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
443 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
444
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
445 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
446 def on_allDefaultButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
447 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
448 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
449 """
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
450 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
451 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
452 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
453 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
454 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
455 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
456 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
457 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
458
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
459 def __setToDefault(self, style, substyle):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
460 """
2763
e4794166ad70 Fixed a serious typo.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2408
diff changeset
461 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
462
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
463 @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
464 @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
465 @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
466 @type int
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
467 """
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
468 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
469 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
470 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
471 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
472 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
473 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
474 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
475 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
476
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
477 #######################################################################
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
478 ## 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
479 #######################################################################
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
480
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
481 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
482 def on_importCurrentButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
483 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
484 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
485 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
486 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
487
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
488 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
489 def on_exportCurrentButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
490 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
491 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
492 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
493 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
494
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
495 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
496 def on_importAllButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
497 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
498 Private slot to import the styles of all lexers.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
499 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
500 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
501
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
502 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
503 def on_exportAllButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
504 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
505 Private slot to export the styles of all lexers.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
506 """
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
507 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
508
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
509 def __exportStyles(self, 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 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
512
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
513 @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
514 """
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
515 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
516 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
517
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
518 fn, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
519 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
520 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
521 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
522 self.tr("Highlighting styles file (*.e6h)"),
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
523 "",
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
524 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
525
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
526 if not fn:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
527 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
528
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
529 ext = QFileInfo(fn).suffix()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
530 if not ext:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
531 ex = selectedFilter.split("(*")[1].split(")")[0]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
532 if ex:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
533 fn += ex
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
534
593
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
535 f = QFile(fn)
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
536 if f.open(QIODevice.WriteOnly):
2408
dc3a7c9d8f6e Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
537 from E5XML.HighlightingStylesWriter import HighlightingStylesWriter
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
538 HighlightingStylesWriter(f, lexers).writeXML()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
539 f.close()
593
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
540 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3010
diff changeset
541 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3010
diff changeset
542 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
543 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
544 self.tr(
3010
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
545 """<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
546 """ 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
547 .format(fn, f.errorString())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
548 )
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
549
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
550 def __importStyles(self, lexers):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
551 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
552 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
553
3010
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
554 @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
555 styles
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
556 """
5976
549918576245 Added a dark style (*.qss and Python lexers) provided by Giuseppe Corbelli.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
557 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
558 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
559
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
560 fn = E5FileDialog.getOpenFileName(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
561 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
562 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
563 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
564 self.tr("Highlighting styles file (*.e6h *.e4h)"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
565
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
566 if not fn:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
567 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
568
593
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
569 f = QFile(fn)
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
570 if f.open(QIODevice.ReadOnly):
2408
dc3a7c9d8f6e Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
571 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
572 reader = HighlightingStylesReader(f, lexers)
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
573 reader.readXML()
594
cded89ee3e30 Added forgotten close() statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 593
diff changeset
574 f.close()
593
32c9b36eec53 Migrated the highlighting styles handler to highlighting styles reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
575 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3010
diff changeset
576 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3010
diff changeset
577 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
578 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
579 self.tr(
3010
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
580 """<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
581 """ 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
582 .format(fn, f.errorString())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
583 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
584 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
585
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
586 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
587 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
588
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
589 #######################################################################
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
590 ## 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
591 #######################################################################
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
592
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
593 def saveState(self):
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 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
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 @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
598 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
599 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
600 @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
601 """
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
602 itm = self.styleElementList.currentItem()
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 parent = itm.parent()
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
604 if parent is 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
605 currentData = (
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
606 None, self.styleElementList.indexOfTopLevelItem(itm))
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
607 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
608 currentData = (
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 self.styleElementList.indexOfTopLevelItem(parent),
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 parent.indexOfChild(itm)
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 )
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
612
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
613 savedState = [
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
614 self.lexerLanguageComboBox.currentIndex(),
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
615 currentData,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
616 ]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
617 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
618
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
619 def setState(self, state):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
620 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
621 Public method to set the state of the widget.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
622
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
623 @param state state data generated by saveState
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
624 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
625 self.lexerLanguageComboBox.setCurrentIndex(state[0])
3010
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
626 self.on_lexerLanguageComboBox_activated(
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
627 self.lexerLanguageComboBox.currentText())
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
628
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 parentIndex, index = state[1]
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
630 if parentIndex is 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
631 itm = self.styleElementList.topLevelItem(index)
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 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
633 parent = self.styleElementList.topLevelItem(parentIndex)
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
634 itm = parent.child(index)
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
635 self.styleElementList.setCurrentItem(itm)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
636
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
637
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
638 def create(dlg):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
639 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
640 Module function to create the configuration page.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
641
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
642 @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
643 @return reference to the instantiated page (ConfigurationPageBase)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
644 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
645 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
646 return page

eric ide

mercurial