src/eric7/Preferences/ConfigurationPages/EditorStylesPage.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
20 20
21 class EditorStylesPage(ConfigurationPageBase, Ui_EditorStylesPage): 21 class EditorStylesPage(ConfigurationPageBase, Ui_EditorStylesPage):
22 """ 22 """
23 Class implementing the Editor Styles configuration page. 23 Class implementing the Editor Styles configuration page.
24 """ 24 """
25
25 def __init__(self): 26 def __init__(self):
26 """ 27 """
27 Constructor 28 Constructor
28 """ 29 """
29 super().__init__() 30 super().__init__()
30 self.setupUi(self) 31 self.setupUi(self)
31 self.setObjectName("EditorStylesPage") 32 self.setObjectName("EditorStylesPage")
32 33
33 from QScintilla.QsciScintillaCompat import QsciScintillaCompat 34 from QScintilla.QsciScintillaCompat import QsciScintillaCompat
34 35
35 self.foldStyles = [ 36 self.foldStyles = [
36 QsciScintilla.FoldStyle.PlainFoldStyle.value, 37 QsciScintilla.FoldStyle.PlainFoldStyle.value,
37 QsciScintilla.FoldStyle.CircledFoldStyle.value, 38 QsciScintilla.FoldStyle.CircledFoldStyle.value,
38 QsciScintilla.FoldStyle.BoxedFoldStyle.value, 39 QsciScintilla.FoldStyle.BoxedFoldStyle.value,
39 QsciScintilla.FoldStyle.CircledTreeFoldStyle.value, 40 QsciScintilla.FoldStyle.CircledTreeFoldStyle.value,
40 QsciScintilla.FoldStyle.BoxedTreeFoldStyle.value, 41 QsciScintilla.FoldStyle.BoxedTreeFoldStyle.value,
41 # the below ones are not (yet) defined in QsciScintilla 42 # the below ones are not (yet) defined in QsciScintilla
42 QsciScintillaCompat.ArrowFoldStyle, 43 QsciScintillaCompat.ArrowFoldStyle,
43 QsciScintillaCompat.ArrowTreeFoldStyle, 44 QsciScintillaCompat.ArrowTreeFoldStyle,
44 ] 45 ]
45 46
46 self.edgeModes = [ 47 self.edgeModes = [
47 QsciScintilla.EdgeMode.EdgeNone, 48 QsciScintilla.EdgeMode.EdgeNone,
48 QsciScintilla.EdgeMode.EdgeLine, 49 QsciScintilla.EdgeMode.EdgeLine,
49 QsciScintilla.EdgeMode.EdgeBackground 50 QsciScintilla.EdgeMode.EdgeBackground,
50 ] 51 ]
51 52
52 self.wrapModeComboBox.addItem( 53 self.wrapModeComboBox.addItem(
53 self.tr("Disabled"), 54 self.tr("Disabled"), QsciScintilla.WrapMode.WrapNone
54 QsciScintilla.WrapMode.WrapNone) 55 )
55 self.wrapModeComboBox.addItem( 56 self.wrapModeComboBox.addItem(
56 self.tr("Word Boundary"), 57 self.tr("Word Boundary"), QsciScintilla.WrapMode.WrapWord
57 QsciScintilla.WrapMode.WrapWord) 58 )
58 self.wrapModeComboBox.addItem( 59 self.wrapModeComboBox.addItem(
59 self.tr("Character Boundary"), 60 self.tr("Character Boundary"), QsciScintilla.WrapMode.WrapCharacter
60 QsciScintilla.WrapMode.WrapCharacter) 61 )
61 self.wrapVisualComboBox.addItem( 62 self.wrapVisualComboBox.addItem(
62 self.tr("No Indicator"), 63 self.tr("No Indicator"), QsciScintilla.WrapVisualFlag.WrapFlagNone
63 QsciScintilla.WrapVisualFlag.WrapFlagNone) 64 )
64 self.wrapVisualComboBox.addItem( 65 self.wrapVisualComboBox.addItem(
65 self.tr("Indicator by Text"), 66 self.tr("Indicator by Text"), QsciScintilla.WrapVisualFlag.WrapFlagByText
66 QsciScintilla.WrapVisualFlag.WrapFlagByText) 67 )
67 self.wrapVisualComboBox.addItem( 68 self.wrapVisualComboBox.addItem(
68 self.tr("Indicator by Margin"), 69 self.tr("Indicator by Margin"),
69 QsciScintilla.WrapVisualFlag.WrapFlagByBorder) 70 QsciScintilla.WrapVisualFlag.WrapFlagByBorder,
71 )
70 self.wrapVisualComboBox.addItem( 72 self.wrapVisualComboBox.addItem(
71 self.tr("Indicator in Line Number Margin"), 73 self.tr("Indicator in Line Number Margin"),
72 QsciScintilla.WrapVisualFlag.WrapFlagInMargin) 74 QsciScintilla.WrapVisualFlag.WrapFlagInMargin,
73 75 )
76
74 self.wrapIndentComboBox.addItem( 77 self.wrapIndentComboBox.addItem(
75 self.tr("Fixed"), QsciScintilla.WrapIndentMode.WrapIndentFixed) 78 self.tr("Fixed"), QsciScintilla.WrapIndentMode.WrapIndentFixed
79 )
76 self.wrapIndentComboBox.addItem( 80 self.wrapIndentComboBox.addItem(
77 self.tr("Aligned"), QsciScintilla.WrapIndentMode.WrapIndentSame) 81 self.tr("Aligned"), QsciScintilla.WrapIndentMode.WrapIndentSame
82 )
78 self.wrapIndentComboBox.addItem( 83 self.wrapIndentComboBox.addItem(
79 self.tr("Aligned plus One"), 84 self.tr("Aligned plus One"), QsciScintilla.WrapIndentMode.WrapIndentIndented
80 QsciScintilla.WrapIndentMode.WrapIndentIndented) 85 )
81 self.wrapIndentComboBox.addItem( 86 self.wrapIndentComboBox.addItem(
82 self.tr("Aligned plus Two"), 87 self.tr("Aligned plus Two"),
83 QsciScintilla.WrapIndentMode.WrapIndentDeeplyIndented) 88 QsciScintilla.WrapIndentMode.WrapIndentDeeplyIndented,
84 89 )
90
85 # set initial values 91 # set initial values
86 try: 92 try:
87 self.foldingStyleComboBox.setCurrentIndex( 93 self.foldingStyleComboBox.setCurrentIndex(
88 self.foldStyles.index(Preferences.getEditor("FoldingStyle"))) 94 self.foldStyles.index(Preferences.getEditor("FoldingStyle"))
95 )
89 except ValueError: 96 except ValueError:
90 self.foldingStyleComboBox.setCurrentIndex(0) 97 self.foldingStyleComboBox.setCurrentIndex(0)
91 self.marginsFont = Preferences.getEditorOtherFonts("MarginsFont") 98 self.marginsFont = Preferences.getEditorOtherFonts("MarginsFont")
92 self.marginsFontSample.setFont(self.marginsFont) 99 self.marginsFontSample.setFont(self.marginsFont)
93 self.defaultFont = Preferences.getEditorOtherFonts("DefaultFont") 100 self.defaultFont = Preferences.getEditorOtherFonts("DefaultFont")
94 self.defaultFontSample.setFont(self.defaultFont) 101 self.defaultFontSample.setFont(self.defaultFont)
95 self.monospacedFont = Preferences.getEditorOtherFonts("MonospacedFont") 102 self.monospacedFont = Preferences.getEditorOtherFonts("MonospacedFont")
96 self.monospacedFontSample.setFont(self.monospacedFont) 103 self.monospacedFontSample.setFont(self.monospacedFont)
97 self.monospacedCheckBox.setChecked( 104 self.monospacedCheckBox.setChecked(Preferences.getEditor("UseMonospacedFont"))
98 Preferences.getEditor("UseMonospacedFont")) 105 self.linenoCheckBox.setChecked(Preferences.getEditor("LinenoMargin"))
99 self.linenoCheckBox.setChecked( 106 self.foldingCheckBox.setChecked(Preferences.getEditor("FoldingMargin"))
100 Preferences.getEditor("LinenoMargin")) 107
101 self.foldingCheckBox.setChecked(
102 Preferences.getEditor("FoldingMargin"))
103
104 self.caretlineVisibleCheckBox.setChecked( 108 self.caretlineVisibleCheckBox.setChecked(
105 Preferences.getEditor("CaretLineVisible")) 109 Preferences.getEditor("CaretLineVisible")
110 )
106 self.caretlineAlwaysVisibleCheckBox.setChecked( 111 self.caretlineAlwaysVisibleCheckBox.setChecked(
107 Preferences.getEditor("CaretLineAlwaysVisible")) 112 Preferences.getEditor("CaretLineAlwaysVisible")
108 self.caretWidthSpinBox.setValue( 113 )
109 Preferences.getEditor("CaretWidth")) 114 self.caretWidthSpinBox.setValue(Preferences.getEditor("CaretWidth"))
110 self.caretlineFrameWidthSpinBox.setValue( 115 self.caretlineFrameWidthSpinBox.setValue(
111 Preferences.getEditor("CaretLineFrameWidth")) 116 Preferences.getEditor("CaretLineFrameWidth")
117 )
112 self.colourizeSelTextCheckBox.setChecked( 118 self.colourizeSelTextCheckBox.setChecked(
113 Preferences.getEditor("ColourizeSelText")) 119 Preferences.getEditor("ColourizeSelText")
120 )
114 self.customSelColourCheckBox.setChecked( 121 self.customSelColourCheckBox.setChecked(
115 Preferences.getEditor("CustomSelectionColours")) 122 Preferences.getEditor("CustomSelectionColours")
123 )
116 self.extentSelEolCheckBox.setChecked( 124 self.extentSelEolCheckBox.setChecked(
117 Preferences.getEditor("ExtendSelectionToEol")) 125 Preferences.getEditor("ExtendSelectionToEol")
126 )
118 self.debugMarkerBackgroundCheckBox.setChecked( 127 self.debugMarkerBackgroundCheckBox.setChecked(
119 Preferences.getEditor("LineMarkersBackground")) 128 Preferences.getEditor("LineMarkersBackground")
120 129 )
121 self.initColour("CaretForeground", self.caretForegroundButton, 130
122 Preferences.getEditorColour) 131 self.initColour(
123 self.initColour("CaretLineBackground", self.caretlineBackgroundButton, 132 "CaretForeground", self.caretForegroundButton, Preferences.getEditorColour
124 Preferences.getEditorColour, hasAlpha=True) 133 )
125 self.initColour("SelectionForeground", self.selectionForegroundButton, 134 self.initColour(
126 Preferences.getEditorColour) 135 "CaretLineBackground",
127 self.initColour("SelectionBackground", self.selectionBackgroundButton, 136 self.caretlineBackgroundButton,
128 Preferences.getEditorColour, hasAlpha=True) 137 Preferences.getEditorColour,
129 self.initColour("CurrentMarker", self.currentLineMarkerButton, 138 hasAlpha=True,
130 Preferences.getEditorColour, hasAlpha=True) 139 )
131 self.initColour("ErrorMarker", self.errorMarkerButton, 140 self.initColour(
132 Preferences.getEditorColour, hasAlpha=True) 141 "SelectionForeground",
133 self.initColour("MarginsForeground", self.marginsForegroundButton, 142 self.selectionForegroundButton,
134 Preferences.getEditorColour) 143 Preferences.getEditorColour,
135 self.initColour("MarginsBackground", self.marginsBackgroundButton, 144 )
136 Preferences.getEditorColour) 145 self.initColour(
137 self.initColour("FoldmarginBackground", 146 "SelectionBackground",
138 self.foldmarginBackgroundButton, 147 self.selectionBackgroundButton,
139 Preferences.getEditorColour) 148 Preferences.getEditorColour,
140 self.initColour("FoldMarkersForeground", 149 hasAlpha=True,
141 self.foldmarkersForegroundButton, 150 )
142 Preferences.getEditorColour) 151 self.initColour(
143 self.initColour("FoldMarkersBackground", 152 "CurrentMarker",
144 self.foldmarkersBackgroundButton, 153 self.currentLineMarkerButton,
145 Preferences.getEditorColour) 154 Preferences.getEditorColour,
146 155 hasAlpha=True,
156 )
157 self.initColour(
158 "ErrorMarker",
159 self.errorMarkerButton,
160 Preferences.getEditorColour,
161 hasAlpha=True,
162 )
163 self.initColour(
164 "MarginsForeground",
165 self.marginsForegroundButton,
166 Preferences.getEditorColour,
167 )
168 self.initColour(
169 "MarginsBackground",
170 self.marginsBackgroundButton,
171 Preferences.getEditorColour,
172 )
173 self.initColour(
174 "FoldmarginBackground",
175 self.foldmarginBackgroundButton,
176 Preferences.getEditorColour,
177 )
178 self.initColour(
179 "FoldMarkersForeground",
180 self.foldmarkersForegroundButton,
181 Preferences.getEditorColour,
182 )
183 self.initColour(
184 "FoldMarkersBackground",
185 self.foldmarkersBackgroundButton,
186 Preferences.getEditorColour,
187 )
188
147 self.editorColours = {} 189 self.editorColours = {}
148 self.editorColours["AnnotationsWarningForeground"] = QColor( 190 self.editorColours["AnnotationsWarningForeground"] = QColor(
149 Preferences.getEditorColour("AnnotationsWarningForeground")) 191 Preferences.getEditorColour("AnnotationsWarningForeground")
192 )
150 self.editorColours["AnnotationsWarningBackground"] = QColor( 193 self.editorColours["AnnotationsWarningBackground"] = QColor(
151 Preferences.getEditorColour("AnnotationsWarningBackground")) 194 Preferences.getEditorColour("AnnotationsWarningBackground")
195 )
152 self.editorColours["AnnotationsErrorForeground"] = QColor( 196 self.editorColours["AnnotationsErrorForeground"] = QColor(
153 Preferences.getEditorColour("AnnotationsErrorForeground")) 197 Preferences.getEditorColour("AnnotationsErrorForeground")
198 )
154 self.editorColours["AnnotationsErrorBackground"] = QColor( 199 self.editorColours["AnnotationsErrorBackground"] = QColor(
155 Preferences.getEditorColour("AnnotationsErrorBackground")) 200 Preferences.getEditorColour("AnnotationsErrorBackground")
201 )
156 self.editorColours["AnnotationsStyleForeground"] = QColor( 202 self.editorColours["AnnotationsStyleForeground"] = QColor(
157 Preferences.getEditorColour("AnnotationsStyleForeground")) 203 Preferences.getEditorColour("AnnotationsStyleForeground")
204 )
158 self.editorColours["AnnotationsStyleBackground"] = QColor( 205 self.editorColours["AnnotationsStyleBackground"] = QColor(
159 Preferences.getEditorColour("AnnotationsStyleBackground")) 206 Preferences.getEditorColour("AnnotationsStyleBackground")
160 207 )
208
161 self.eolCheckBox.setChecked(Preferences.getEditor("ShowEOL")) 209 self.eolCheckBox.setChecked(Preferences.getEditor("ShowEOL"))
162 self.wrapModeComboBox.setCurrentIndex(self.wrapModeComboBox.findData( 210 self.wrapModeComboBox.setCurrentIndex(
163 Preferences.getEditor("WrapLongLinesMode"))) 211 self.wrapModeComboBox.findData(Preferences.getEditor("WrapLongLinesMode"))
212 )
164 self.wrapVisualComboBox.setCurrentIndex( 213 self.wrapVisualComboBox.setCurrentIndex(
165 self.wrapVisualComboBox.findData( 214 self.wrapVisualComboBox.findData(Preferences.getEditor("WrapVisualFlag"))
166 Preferences.getEditor("WrapVisualFlag"))) 215 )
167 self.wrapIndentComboBox.setCurrentIndex( 216 self.wrapIndentComboBox.setCurrentIndex(
168 self.wrapIndentComboBox.findData( 217 self.wrapIndentComboBox.findData(Preferences.getEditor("WrapIndentMode"))
169 Preferences.getEditor("WrapIndentMode"))) 218 )
170 self.wrapStartIndentSpinBox.setValue( 219 self.wrapStartIndentSpinBox.setValue(Preferences.getEditor("WrapStartIndent"))
171 Preferences.getEditor("WrapStartIndent")) 220
172
173 self.edgeModeCombo.setCurrentIndex( 221 self.edgeModeCombo.setCurrentIndex(
174 self.edgeModes.index(Preferences.getEditor("EdgeMode"))) 222 self.edgeModes.index(Preferences.getEditor("EdgeMode"))
175 self.edgeLineColumnSlider.setValue( 223 )
176 Preferences.getEditor("EdgeColumn")) 224 self.edgeLineColumnSlider.setValue(Preferences.getEditor("EdgeColumn"))
177 self.initColour( 225 self.initColour(
178 "Edge", self.edgeBackgroundColorButton, 226 "Edge", self.edgeBackgroundColorButton, Preferences.getEditorColour
179 Preferences.getEditorColour) 227 )
180 228
181 self.bracehighlightingCheckBox.setChecked( 229 self.bracehighlightingCheckBox.setChecked(
182 Preferences.getEditor("BraceHighlighting")) 230 Preferences.getEditor("BraceHighlighting")
183 self.initColour("MatchingBrace", self.matchingBracesButton, 231 )
184 Preferences.getEditorColour) 232 self.initColour(
185 self.initColour("MatchingBraceBack", self.matchingBracesBackButton, 233 "MatchingBrace", self.matchingBracesButton, Preferences.getEditorColour
186 Preferences.getEditorColour) 234 )
187 self.initColour("NonmatchingBrace", self.nonmatchingBracesButton, 235 self.initColour(
188 Preferences.getEditorColour) 236 "MatchingBraceBack",
189 self.initColour("NonmatchingBraceBack", 237 self.matchingBracesBackButton,
190 self.nonmatchingBracesBackButton, 238 Preferences.getEditorColour,
191 Preferences.getEditorColour) 239 )
192 240 self.initColour(
193 self.zoomfactorSlider.setValue( 241 "NonmatchingBrace",
194 Preferences.getEditor("ZoomFactor")) 242 self.nonmatchingBracesButton,
195 243 Preferences.getEditorColour,
196 self.whitespaceCheckBox.setChecked( 244 )
197 Preferences.getEditor("ShowWhitespace")) 245 self.initColour(
198 self.whitespaceSizeSpinBox.setValue( 246 "NonmatchingBraceBack",
199 Preferences.getEditor("WhitespaceSize")) 247 self.nonmatchingBracesBackButton,
200 self.initColour("WhitespaceForeground", 248 Preferences.getEditorColour,
201 self.whitespaceForegroundButton, 249 )
202 Preferences.getEditorColour) 250
203 self.initColour("WhitespaceBackground", 251 self.zoomfactorSlider.setValue(Preferences.getEditor("ZoomFactor"))
204 self.whitespaceBackgroundButton, 252
205 Preferences.getEditorColour) 253 self.whitespaceCheckBox.setChecked(Preferences.getEditor("ShowWhitespace"))
254 self.whitespaceSizeSpinBox.setValue(Preferences.getEditor("WhitespaceSize"))
255 self.initColour(
256 "WhitespaceForeground",
257 self.whitespaceForegroundButton,
258 Preferences.getEditorColour,
259 )
260 self.initColour(
261 "WhitespaceBackground",
262 self.whitespaceBackgroundButton,
263 Preferences.getEditorColour,
264 )
206 if not hasattr(QsciScintilla, "setWhitespaceForegroundColor"): 265 if not hasattr(QsciScintilla, "setWhitespaceForegroundColor"):
207 self.whitespaceSizeSpinBox.setEnabled(False) 266 self.whitespaceSizeSpinBox.setEnabled(False)
208 self.whitespaceForegroundButton.setEnabled(False) 267 self.whitespaceForegroundButton.setEnabled(False)
209 self.whitespaceBackgroundButton.setEnabled(False) 268 self.whitespaceBackgroundButton.setEnabled(False)
210 269
211 self.miniMenuCheckBox.setChecked( 270 self.miniMenuCheckBox.setChecked(Preferences.getEditor("MiniContextMenu"))
212 Preferences.getEditor("MiniContextMenu"))
213 self.hideFormatButtonsCheckBox.setChecked( 271 self.hideFormatButtonsCheckBox.setChecked(
214 Preferences.getEditor("HideFormatButtons")) 272 Preferences.getEditor("HideFormatButtons")
215 273 )
274
216 self.enableAnnotationsCheckBox.setChecked( 275 self.enableAnnotationsCheckBox.setChecked(
217 Preferences.getEditor("AnnotationsEnabled")) 276 Preferences.getEditor("AnnotationsEnabled")
218 277 )
278
219 self.editAreaOverrideCheckBox.setChecked( 279 self.editAreaOverrideCheckBox.setChecked(
220 Preferences.getEditor("OverrideEditAreaColours")) 280 Preferences.getEditor("OverrideEditAreaColours")
221 self.initColour( 281 )
222 "EditAreaForeground", self.editAreaForegroundButton, 282 self.initColour(
223 Preferences.getEditorColour) 283 "EditAreaForeground",
224 self.initColour( 284 self.editAreaForegroundButton,
225 "EditAreaBackground", self.editAreaBackgroundButton, 285 Preferences.getEditorColour,
226 Preferences.getEditorColour) 286 )
227 287 self.initColour(
288 "EditAreaBackground",
289 self.editAreaBackgroundButton,
290 Preferences.getEditorColour,
291 )
292
228 self.enableChangeTraceCheckBox.setChecked( 293 self.enableChangeTraceCheckBox.setChecked(
229 Preferences.getEditor("OnlineChangeTrace")) 294 Preferences.getEditor("OnlineChangeTrace")
295 )
230 self.changeTraceTimeoutSpinBox.setValue( 296 self.changeTraceTimeoutSpinBox.setValue(
231 Preferences.getEditor("OnlineChangeTraceInterval")) 297 Preferences.getEditor("OnlineChangeTraceInterval")
232 self.initColour("OnlineChangeTraceMarkerUnsaved", 298 )
233 self.changeMarkerUnsavedColorButton, 299 self.initColour(
234 Preferences.getEditorColour) 300 "OnlineChangeTraceMarkerUnsaved",
235 self.initColour("OnlineChangeTraceMarkerSaved", 301 self.changeMarkerUnsavedColorButton,
236 self.changeMarkerSavedColorButton, 302 Preferences.getEditorColour,
237 Preferences.getEditorColour) 303 )
238 304 self.initColour(
305 "OnlineChangeTraceMarkerSaved",
306 self.changeMarkerSavedColorButton,
307 Preferences.getEditorColour,
308 )
309
239 self.markerMapRightCheckBox.setChecked( 310 self.markerMapRightCheckBox.setChecked(
240 Preferences.getEditor("ShowMarkerMapOnRight")) 311 Preferences.getEditor("ShowMarkerMapOnRight")
241 self.initColour("BookmarksMap", 312 )
242 self.bookmarksMapButton, 313 self.initColour(
243 Preferences.getEditorColour) 314 "BookmarksMap", self.bookmarksMapButton, Preferences.getEditorColour
244 self.initColour("ErrorsMap", 315 )
245 self.errorsMapButton, 316 self.initColour("ErrorsMap", self.errorsMapButton, Preferences.getEditorColour)
246 Preferences.getEditorColour) 317 self.initColour(
247 self.initColour("WarningsMap", 318 "WarningsMap", self.warningsMapButton, Preferences.getEditorColour
248 self.warningsMapButton, 319 )
249 Preferences.getEditorColour) 320 self.initColour(
250 self.initColour("BreakpointsMap", 321 "BreakpointsMap", self.breakpointsMapButton, Preferences.getEditorColour
251 self.breakpointsMapButton, 322 )
252 Preferences.getEditorColour) 323 self.initColour("TasksMap", self.tasksMapButton, Preferences.getEditorColour)
253 self.initColour("TasksMap", 324 self.initColour(
254 self.tasksMapButton, 325 "CoverageMap", self.coverageMapButton, Preferences.getEditorColour
255 Preferences.getEditorColour) 326 )
256 self.initColour("CoverageMap", 327 self.initColour(
257 self.coverageMapButton, 328 "ChangesMap", self.changesMapButton, Preferences.getEditorColour
258 Preferences.getEditorColour) 329 )
259 self.initColour("ChangesMap", 330 self.initColour(
260 self.changesMapButton, 331 "CurrentMap", self.currentMapButton, Preferences.getEditorColour
261 Preferences.getEditorColour) 332 )
262 self.initColour("CurrentMap", 333 self.initColour(
263 self.currentMapButton, 334 "SearchMarkersMap", self.searchMarkerMapButton, Preferences.getEditorColour
264 Preferences.getEditorColour) 335 )
265 self.initColour("SearchMarkersMap", 336 self.initColour(
266 self.searchMarkerMapButton, 337 "VcsConflictMarkersMap",
267 Preferences.getEditorColour) 338 self.conflictMarkerMapButton,
268 self.initColour("VcsConflictMarkersMap", 339 Preferences.getEditorColour,
269 self.conflictMarkerMapButton, 340 )
270 Preferences.getEditorColour) 341 self.initColour(
271 self.initColour("MarkerMapBackground", 342 "MarkerMapBackground",
272 self.markerMapBackgroundButton, 343 self.markerMapBackgroundButton,
273 Preferences.getEditorColour) 344 Preferences.getEditorColour,
345 )
274 self.changesMarkerCheckBox.setChecked( 346 self.changesMarkerCheckBox.setChecked(
275 Preferences.getEditor("ShowMarkerChanges")) 347 Preferences.getEditor("ShowMarkerChanges")
348 )
276 self.coverageMarkerCheckBox.setChecked( 349 self.coverageMarkerCheckBox.setChecked(
277 Preferences.getEditor("ShowMarkerCoverage")) 350 Preferences.getEditor("ShowMarkerCoverage")
278 self.searchMarkerCheckBox.setChecked( 351 )
279 Preferences.getEditor("ShowMarkerSearch")) 352 self.searchMarkerCheckBox.setChecked(Preferences.getEditor("ShowMarkerSearch"))
280 353
281 self.indentguidesCheckBox.setChecked( 354 self.indentguidesCheckBox.setChecked(Preferences.getEditor("IndentationGuides"))
282 Preferences.getEditor("IndentationGuides")) 355 self.initColour(
283 self.initColour("IndentationGuidesBackground", 356 "IndentationGuidesBackground",
284 self.indentationGuidesBackgroundButton, 357 self.indentationGuidesBackgroundButton,
285 Preferences.getEditorColour) 358 Preferences.getEditorColour,
286 self.initColour("IndentationGuidesForeground", 359 )
287 self.indentationGuidesForegroundButton, 360 self.initColour(
288 Preferences.getEditorColour) 361 "IndentationGuidesForeground",
289 362 self.indentationGuidesForegroundButton,
290 self.initColour("HighlightMarker", 363 Preferences.getEditorColour,
291 self.highlightingBackgroundButton, 364 )
292 Preferences.getEditorColour, 365
293 hasAlpha=True) 366 self.initColour(
294 367 "HighlightMarker",
368 self.highlightingBackgroundButton,
369 Preferences.getEditorColour,
370 hasAlpha=True,
371 )
372
295 def save(self): 373 def save(self):
296 """ 374 """
297 Public slot to save the Editor Styles configuration. 375 Public slot to save the Editor Styles configuration.
298 """ 376 """
299 Preferences.setEditor( 377 Preferences.setEditor(
300 "FoldingStyle", 378 "FoldingStyle", self.foldStyles[self.foldingStyleComboBox.currentIndex()]
301 self.foldStyles[self.foldingStyleComboBox.currentIndex()]) 379 )
302 Preferences.setEditorOtherFonts( 380 Preferences.setEditorOtherFonts("MarginsFont", self.marginsFont)
303 "MarginsFont", self.marginsFont) 381 Preferences.setEditorOtherFonts("DefaultFont", self.defaultFont)
304 Preferences.setEditorOtherFonts( 382 Preferences.setEditorOtherFonts("MonospacedFont", self.monospacedFont)
305 "DefaultFont", self.defaultFont) 383 Preferences.setEditor("UseMonospacedFont", self.monospacedCheckBox.isChecked())
306 Preferences.setEditorOtherFonts( 384
307 "MonospacedFont", self.monospacedFont) 385 Preferences.setEditor("LinenoMargin", self.linenoCheckBox.isChecked())
308 Preferences.setEditor( 386 Preferences.setEditor("FoldingMargin", self.foldingCheckBox.isChecked())
309 "UseMonospacedFont", self.monospacedCheckBox.isChecked()) 387
310 388 Preferences.setEditor(
311 Preferences.setEditor( 389 "CaretLineVisible", self.caretlineVisibleCheckBox.isChecked()
312 "LinenoMargin", self.linenoCheckBox.isChecked()) 390 )
313 Preferences.setEditor( 391 Preferences.setEditor(
314 "FoldingMargin", self.foldingCheckBox.isChecked()) 392 "CaretLineAlwaysVisible", self.caretlineAlwaysVisibleCheckBox.isChecked()
315 393 )
316 Preferences.setEditor( 394 Preferences.setEditor(
317 "CaretLineVisible", self.caretlineVisibleCheckBox.isChecked()) 395 "ColourizeSelText", self.colourizeSelTextCheckBox.isChecked()
318 Preferences.setEditor( 396 )
319 "CaretLineAlwaysVisible", 397 Preferences.setEditor(
320 self.caretlineAlwaysVisibleCheckBox.isChecked()) 398 "CustomSelectionColours", self.customSelColourCheckBox.isChecked()
321 Preferences.setEditor( 399 )
322 "ColourizeSelText", self.colourizeSelTextCheckBox.isChecked()) 400 Preferences.setEditor(
323 Preferences.setEditor( 401 "ExtendSelectionToEol", self.extentSelEolCheckBox.isChecked()
324 "CustomSelectionColours", self.customSelColourCheckBox.isChecked()) 402 )
325 Preferences.setEditor( 403 Preferences.setEditor(
326 "ExtendSelectionToEol", self.extentSelEolCheckBox.isChecked()) 404 "LineMarkersBackground", self.debugMarkerBackgroundCheckBox.isChecked()
327 Preferences.setEditor( 405 )
328 "LineMarkersBackground", 406
329 self.debugMarkerBackgroundCheckBox.isChecked()) 407 Preferences.setEditor("CaretWidth", self.caretWidthSpinBox.value())
330 408 Preferences.setEditor(
331 Preferences.setEditor( 409 "CaretLineFrameWidth", self.caretlineFrameWidthSpinBox.value()
332 "CaretWidth", self.caretWidthSpinBox.value()) 410 )
333 Preferences.setEditor( 411
334 "CaretLineFrameWidth", self.caretlineFrameWidthSpinBox.value()) 412 Preferences.setEditor("ShowEOL", self.eolCheckBox.isChecked())
335 413 Preferences.setEditor(
336 Preferences.setEditor( 414 "WrapLongLinesMode",
337 "ShowEOL", self.eolCheckBox.isChecked()) 415 self.wrapModeComboBox.itemData(self.wrapModeComboBox.currentIndex()),
338 Preferences.setEditor( 416 )
339 "WrapLongLinesMode", self.wrapModeComboBox.itemData( 417 Preferences.setEditor(
340 self.wrapModeComboBox.currentIndex())) 418 "WrapVisualFlag",
341 Preferences.setEditor( 419 self.wrapVisualComboBox.itemData(self.wrapVisualComboBox.currentIndex()),
342 "WrapVisualFlag", self.wrapVisualComboBox.itemData( 420 )
343 self.wrapVisualComboBox.currentIndex())) 421 Preferences.setEditor(
344 Preferences.setEditor( 422 "WrapIndentMode",
345 "WrapIndentMode", self.wrapIndentComboBox.itemData( 423 self.wrapIndentComboBox.itemData(self.wrapIndentComboBox.currentIndex()),
346 self.wrapIndentComboBox.currentIndex())) 424 )
347 Preferences.setEditor( 425 Preferences.setEditor("WrapStartIndent", self.wrapStartIndentSpinBox.value())
348 "WrapStartIndent", self.wrapStartIndentSpinBox.value()) 426 Preferences.setEditor(
349 Preferences.setEditor( 427 "EdgeMode", self.edgeModes[self.edgeModeCombo.currentIndex()]
350 "EdgeMode", self.edgeModes[self.edgeModeCombo.currentIndex()]) 428 )
351 Preferences.setEditor( 429 Preferences.setEditor("EdgeColumn", self.edgeLineColumnSlider.value())
352 "EdgeColumn", self.edgeLineColumnSlider.value()) 430
353 431 Preferences.setEditor(
354 Preferences.setEditor( 432 "BraceHighlighting", self.bracehighlightingCheckBox.isChecked()
355 "BraceHighlighting", self.bracehighlightingCheckBox.isChecked()) 433 )
356 434
357 Preferences.setEditor( 435 Preferences.setEditor("ZoomFactor", self.zoomfactorSlider.value())
358 "ZoomFactor", self.zoomfactorSlider.value()) 436
359 437 Preferences.setEditor("ShowWhitespace", self.whitespaceCheckBox.isChecked())
360 Preferences.setEditor( 438 Preferences.setEditor("WhitespaceSize", self.whitespaceSizeSpinBox.value())
361 "ShowWhitespace", self.whitespaceCheckBox.isChecked()) 439
362 Preferences.setEditor( 440 Preferences.setEditor("MiniContextMenu", self.miniMenuCheckBox.isChecked())
363 "WhitespaceSize", self.whitespaceSizeSpinBox.value()) 441 Preferences.setEditor(
364 442 "HideFormatButtons", self.hideFormatButtonsCheckBox.isChecked()
365 Preferences.setEditor( 443 )
366 "MiniContextMenu", self.miniMenuCheckBox.isChecked()) 444
367 Preferences.setEditor( 445 Preferences.setEditor(
368 "HideFormatButtons", self.hideFormatButtonsCheckBox.isChecked()) 446 "AnnotationsEnabled", self.enableAnnotationsCheckBox.isChecked()
369 447 )
370 Preferences.setEditor( 448
371 "AnnotationsEnabled", self.enableAnnotationsCheckBox.isChecked()) 449 Preferences.setEditor(
372 450 "OverrideEditAreaColours", self.editAreaOverrideCheckBox.isChecked()
373 Preferences.setEditor( 451 )
374 "OverrideEditAreaColours", 452
375 self.editAreaOverrideCheckBox.isChecked()) 453 Preferences.setEditor(
376 454 "OnlineChangeTrace", self.enableChangeTraceCheckBox.isChecked()
377 Preferences.setEditor( 455 )
378 "OnlineChangeTrace", self.enableChangeTraceCheckBox.isChecked()) 456 Preferences.setEditor(
379 Preferences.setEditor( 457 "OnlineChangeTraceInterval", self.changeTraceTimeoutSpinBox.value()
380 "OnlineChangeTraceInterval", 458 )
381 self.changeTraceTimeoutSpinBox.value()) 459
382 460 Preferences.setEditor(
383 Preferences.setEditor( 461 "IndentationGuides", self.indentguidesCheckBox.isChecked()
384 "IndentationGuides", 462 )
385 self.indentguidesCheckBox.isChecked()) 463
386 464 Preferences.setEditor(
387 Preferences.setEditor( 465 "ShowMarkerMapOnRight", self.markerMapRightCheckBox.isChecked()
388 "ShowMarkerMapOnRight", 466 )
389 self.markerMapRightCheckBox.isChecked()) 467 Preferences.setEditor(
390 Preferences.setEditor( 468 "ShowMarkerChanges", self.changesMarkerCheckBox.isChecked()
391 "ShowMarkerChanges", 469 )
392 self.changesMarkerCheckBox.isChecked()) 470 Preferences.setEditor(
393 Preferences.setEditor( 471 "ShowMarkerCoverage", self.coverageMarkerCheckBox.isChecked()
394 "ShowMarkerCoverage", 472 )
395 self.coverageMarkerCheckBox.isChecked()) 473 Preferences.setEditor("ShowMarkerSearch", self.searchMarkerCheckBox.isChecked())
396 Preferences.setEditor( 474
397 "ShowMarkerSearch",
398 self.searchMarkerCheckBox.isChecked())
399
400 self.saveColours(Preferences.setEditorColour) 475 self.saveColours(Preferences.setEditorColour)
401 for key in list(self.editorColours.keys()): 476 for key in list(self.editorColours.keys()):
402 Preferences.setEditorColour(key, self.editorColours[key]) 477 Preferences.setEditorColour(key, self.editorColours[key])
403 478
404 @pyqtSlot() 479 @pyqtSlot()
405 def on_linenumbersFontButton_clicked(self): 480 def on_linenumbersFontButton_clicked(self):
406 """ 481 """
407 Private method used to select the font for the editor margins. 482 Private method used to select the font for the editor margins.
408 """ 483 """
409 self.marginsFont = self.selectFont( 484 self.marginsFont = self.selectFont(
410 self.marginsFontSample, self.marginsFont, 485 self.marginsFontSample,
411 options=QFontDialog.FontDialogOption.MonospacedFonts) 486 self.marginsFont,
412 487 options=QFontDialog.FontDialogOption.MonospacedFonts,
488 )
489
413 @pyqtSlot() 490 @pyqtSlot()
414 def on_defaultFontButton_clicked(self): 491 def on_defaultFontButton_clicked(self):
415 """ 492 """
416 Private method used to select the default font for the editor. 493 Private method used to select the default font for the editor.
417 """ 494 """
418 self.defaultFont = self.selectFont( 495 self.defaultFont = self.selectFont(self.defaultFontSample, self.defaultFont)
419 self.defaultFontSample, self.defaultFont) 496
420
421 @pyqtSlot() 497 @pyqtSlot()
422 def on_monospacedFontButton_clicked(self): 498 def on_monospacedFontButton_clicked(self):
423 """ 499 """
424 Private method used to select the font to be used as the monospaced 500 Private method used to select the font to be used as the monospaced
425 font. 501 font.
426 """ 502 """
427 self.monospacedFont = self.selectFont( 503 self.monospacedFont = self.selectFont(
428 self.monospacedFontSample, self.monospacedFont, 504 self.monospacedFontSample,
429 options=QFontDialog.FontDialogOption.MonospacedFonts) 505 self.monospacedFont,
430 506 options=QFontDialog.FontDialogOption.MonospacedFonts,
507 )
508
431 def __setSampleStyleSheet(self, sampleLineEdit, color, background): 509 def __setSampleStyleSheet(self, sampleLineEdit, color, background):
432 """ 510 """
433 Private method to colorize a sample with given foreground and 511 Private method to colorize a sample with given foreground and
434 background colors. 512 background colors.
435 513
436 @param sampleLineEdit line edit element to be colorized 514 @param sampleLineEdit line edit element to be colorized
437 @type QLineEdit 515 @type QLineEdit
438 @param color text color to be shown 516 @param color text color to be shown
439 @type QColor 517 @type QColor
440 @param background background color to be shown 518 @param background background color to be shown
441 @type QColor 519 @type QColor
442 """ 520 """
443 sampleLineEdit.setStyleSheet( 521 sampleLineEdit.setStyleSheet(
444 "QLineEdit {{ color: {0}; background-color: {1}; }}" 522 "QLineEdit {{ color: {0}; background-color: {1}; }}".format(
445 .format(color.name(), background.name()) 523 color.name(), background.name()
446 ) 524 )
447 525 )
526
448 def polishPage(self): 527 def polishPage(self):
449 """ 528 """
450 Public slot to perform some polishing actions. 529 Public slot to perform some polishing actions.
451 """ 530 """
452 self.marginsFontSample.setFont(self.marginsFont) 531 self.marginsFontSample.setFont(self.marginsFont)
453 self.defaultFontSample.setFont(self.defaultFont) 532 self.defaultFontSample.setFont(self.defaultFont)
454 self.monospacedFontSample.setFont(self.monospacedFont) 533 self.monospacedFontSample.setFont(self.monospacedFont)
455 534
456 self.__setSampleStyleSheet( 535 self.__setSampleStyleSheet(
457 self.annotationsWarningSample, 536 self.annotationsWarningSample,
458 self.editorColours["AnnotationsWarningForeground"], 537 self.editorColours["AnnotationsWarningForeground"],
459 self.editorColours["AnnotationsWarningBackground"]) 538 self.editorColours["AnnotationsWarningBackground"],
460 539 )
540
461 self.__setSampleStyleSheet( 541 self.__setSampleStyleSheet(
462 self.annotationsErrorSample, 542 self.annotationsErrorSample,
463 self.editorColours["AnnotationsErrorForeground"], 543 self.editorColours["AnnotationsErrorForeground"],
464 self.editorColours["AnnotationsErrorBackground"]) 544 self.editorColours["AnnotationsErrorBackground"],
465 545 )
546
466 self.__setSampleStyleSheet( 547 self.__setSampleStyleSheet(
467 self.annotationsStyleWarningSample, 548 self.annotationsStyleWarningSample,
468 self.editorColours["AnnotationsStyleForeground"], 549 self.editorColours["AnnotationsStyleForeground"],
469 self.editorColours["AnnotationsStyleBackground"]) 550 self.editorColours["AnnotationsStyleBackground"],
470 551 )
552
471 @pyqtSlot() 553 @pyqtSlot()
472 def on_annotationsWarningFgButton_clicked(self): 554 def on_annotationsWarningFgButton_clicked(self):
473 """ 555 """
474 Private slot to set the foreground colour of the warning annotations. 556 Private slot to set the foreground colour of the warning annotations.
475 """ 557 """
476 colour = QColorDialog.getColor( 558 colour = QColorDialog.getColor(
477 self.editorColours["AnnotationsWarningForeground"]) 559 self.editorColours["AnnotationsWarningForeground"]
560 )
478 if colour.isValid(): 561 if colour.isValid():
479 self.__setSampleStyleSheet( 562 self.__setSampleStyleSheet(
480 self.annotationsWarningSample, 563 self.annotationsWarningSample,
481 colour, 564 colour,
482 self.editorColours["AnnotationsWarningBackground"]) 565 self.editorColours["AnnotationsWarningBackground"],
566 )
483 self.editorColours["AnnotationsWarningForeground"] = colour 567 self.editorColours["AnnotationsWarningForeground"] = colour
484 568
485 @pyqtSlot() 569 @pyqtSlot()
486 def on_annotationsWarningBgButton_clicked(self): 570 def on_annotationsWarningBgButton_clicked(self):
487 """ 571 """
488 Private slot to set the background colour of the warning annotations. 572 Private slot to set the background colour of the warning annotations.
489 """ 573 """
490 colour = QColorDialog.getColor( 574 colour = QColorDialog.getColor(
491 self.editorColours["AnnotationsWarningBackground"]) 575 self.editorColours["AnnotationsWarningBackground"]
576 )
492 if colour.isValid(): 577 if colour.isValid():
493 self.__setSampleStyleSheet( 578 self.__setSampleStyleSheet(
494 self.annotationsWarningSample, 579 self.annotationsWarningSample,
495 self.editorColours["AnnotationsWarningForeground"], 580 self.editorColours["AnnotationsWarningForeground"],
496 colour) 581 colour,
582 )
497 self.editorColours["AnnotationsWarningBackground"] = colour 583 self.editorColours["AnnotationsWarningBackground"] = colour
498 584
499 @pyqtSlot() 585 @pyqtSlot()
500 def on_annotationsErrorFgButton_clicked(self): 586 def on_annotationsErrorFgButton_clicked(self):
501 """ 587 """
502 Private slot to set the foreground colour of the error annotations. 588 Private slot to set the foreground colour of the error annotations.
503 """ 589 """
504 colour = QColorDialog.getColor( 590 colour = QColorDialog.getColor(self.editorColours["AnnotationsErrorForeground"])
505 self.editorColours["AnnotationsErrorForeground"])
506 if colour.isValid(): 591 if colour.isValid():
507 self.__setSampleStyleSheet( 592 self.__setSampleStyleSheet(
508 self.annotationsErrorSample, 593 self.annotationsErrorSample,
509 colour, 594 colour,
510 self.editorColours["AnnotationsErrorBackground"]) 595 self.editorColours["AnnotationsErrorBackground"],
596 )
511 self.editorColours["AnnotationsErrorForeground"] = colour 597 self.editorColours["AnnotationsErrorForeground"] = colour
512 598
513 @pyqtSlot() 599 @pyqtSlot()
514 def on_annotationsErrorBgButton_clicked(self): 600 def on_annotationsErrorBgButton_clicked(self):
515 """ 601 """
516 Private slot to set the background colour of the error annotations. 602 Private slot to set the background colour of the error annotations.
517 """ 603 """
518 colour = QColorDialog.getColor( 604 colour = QColorDialog.getColor(self.editorColours["AnnotationsErrorBackground"])
519 self.editorColours["AnnotationsErrorBackground"])
520 if colour.isValid(): 605 if colour.isValid():
521 self.__setSampleStyleSheet( 606 self.__setSampleStyleSheet(
522 self.annotationsErrorSample, 607 self.annotationsErrorSample,
523 self.editorColours["AnnotationsErrorForeground"], 608 self.editorColours["AnnotationsErrorForeground"],
524 colour) 609 colour,
610 )
525 self.editorColours["AnnotationsErrorBackground"] = colour 611 self.editorColours["AnnotationsErrorBackground"] = colour
526 612
527 @pyqtSlot() 613 @pyqtSlot()
528 def on_annotationsStyleWarningFgButton_clicked(self): 614 def on_annotationsStyleWarningFgButton_clicked(self):
529 """ 615 """
530 Private slot to set the foreground colour of the style annotations. 616 Private slot to set the foreground colour of the style annotations.
531 """ 617 """
532 colour = QColorDialog.getColor( 618 colour = QColorDialog.getColor(self.editorColours["AnnotationsStyleForeground"])
533 self.editorColours["AnnotationsStyleForeground"])
534 if colour.isValid(): 619 if colour.isValid():
535 self.__setSampleStyleSheet( 620 self.__setSampleStyleSheet(
536 self.annotationsStyleWarningSample, 621 self.annotationsStyleWarningSample,
537 colour, 622 colour,
538 self.editorColours["AnnotationsStyleBackground"]) 623 self.editorColours["AnnotationsStyleBackground"],
624 )
539 self.editorColours["AnnotationsStyleForeground"] = colour 625 self.editorColours["AnnotationsStyleForeground"] = colour
540 626
541 @pyqtSlot() 627 @pyqtSlot()
542 def on_annotationsStyleWarningBgButton_clicked(self): 628 def on_annotationsStyleWarningBgButton_clicked(self):
543 """ 629 """
544 Private slot to set the background colour of the style annotations. 630 Private slot to set the background colour of the style annotations.
545 """ 631 """
546 colour = QColorDialog.getColor( 632 colour = QColorDialog.getColor(self.editorColours["AnnotationsStyleBackground"])
547 self.editorColours["AnnotationsStyleBackground"])
548 if colour.isValid(): 633 if colour.isValid():
549 self.__setSampleStyleSheet( 634 self.__setSampleStyleSheet(
550 self.annotationsStyleWarningSample, 635 self.annotationsStyleWarningSample,
551 self.editorColours["AnnotationsStyleForeground"], 636 self.editorColours["AnnotationsStyleForeground"],
552 colour) 637 colour,
638 )
553 self.editorColours["AnnotationsStyleBackground"] = colour 639 self.editorColours["AnnotationsStyleBackground"] = colour
554 640
555 641
556 def create(dlg): 642 def create(dlg):
557 """ 643 """
558 Module function to create the configuration page. 644 Module function to create the configuration page.
559 645
560 @param dlg reference to the configuration dialog 646 @param dlg reference to the configuration dialog
561 @return reference to the instantiated page (ConfigurationPageBase) 647 @return reference to the instantiated page (ConfigurationPageBase)
562 """ 648 """
563 page = EditorStylesPage() 649 page = EditorStylesPage()
564 return page 650 return page

eric ide

mercurial