|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2008 - 2019 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the Editor Search configuration page. |
|
8 """ |
|
9 |
|
10 from __future__ import unicode_literals |
|
11 |
|
12 from QScintilla.QsciScintillaCompat import QSCINTILLA_VERSION |
|
13 |
|
14 from .ConfigurationPageBase import ConfigurationPageBase |
|
15 from .Ui_EditorSearchPage import Ui_EditorSearchPage |
|
16 |
|
17 import Preferences |
|
18 |
|
19 |
|
20 class EditorSearchPage(ConfigurationPageBase, Ui_EditorSearchPage): |
|
21 """ |
|
22 Class implementing the Editor Search configuration page. |
|
23 """ |
|
24 def __init__(self): |
|
25 """ |
|
26 Constructor |
|
27 """ |
|
28 super(EditorSearchPage, self).__init__() |
|
29 self.setupUi(self) |
|
30 self.setObjectName("EditorSearchPage") |
|
31 |
|
32 self.editorColours = {} |
|
33 |
|
34 # set initial values |
|
35 self.searchMarkersEnabledCheckBox.setChecked( |
|
36 Preferences.getEditor("SearchMarkersEnabled")) |
|
37 self.quicksearchMarkersEnabledCheckBox.setChecked( |
|
38 Preferences.getEditor("QuickSearchMarkersEnabled")) |
|
39 self.occurrencesMarkersEnabledCheckBox.setChecked( |
|
40 Preferences.getEditor("MarkOccurrencesEnabled")) |
|
41 |
|
42 self.markOccurrencesTimeoutSpinBox.setValue( |
|
43 Preferences.getEditor("MarkOccurrencesTimeout")) |
|
44 |
|
45 if QSCINTILLA_VERSION() < 0x020B00: |
|
46 self.regexpModeBox.setEnabled(False) |
|
47 else: |
|
48 if Preferences.getEditor("SearchRegexpMode") == 0: |
|
49 self.regexpPosixButton.setChecked(True) |
|
50 else: |
|
51 self.regexpCxx11Button.setChecked(True) |
|
52 |
|
53 self.initColour( |
|
54 "SearchMarkers", self.searchMarkerButton, |
|
55 Preferences.getEditorColour, hasAlpha=True) |
|
56 |
|
57 def save(self): |
|
58 """ |
|
59 Public slot to save the Editor Search configuration. |
|
60 """ |
|
61 Preferences.setEditor( |
|
62 "SearchMarkersEnabled", |
|
63 self.searchMarkersEnabledCheckBox.isChecked()) |
|
64 Preferences.setEditor( |
|
65 "QuickSearchMarkersEnabled", |
|
66 self.quicksearchMarkersEnabledCheckBox.isChecked()) |
|
67 Preferences.setEditor( |
|
68 "MarkOccurrencesEnabled", |
|
69 self.occurrencesMarkersEnabledCheckBox.isChecked()) |
|
70 |
|
71 Preferences.setEditor( |
|
72 "MarkOccurrencesTimeout", |
|
73 self.markOccurrencesTimeoutSpinBox.value()) |
|
74 |
|
75 if self.regexpPosixButton.isChecked(): |
|
76 mode = 0 |
|
77 else: |
|
78 mode = 1 |
|
79 Preferences.setEditor( |
|
80 "SearchRegexpMode", mode) |
|
81 |
|
82 self.saveColours(Preferences.setEditorColour) |
|
83 |
|
84 |
|
85 def create(dlg): |
|
86 """ |
|
87 Module function to create the configuration page. |
|
88 |
|
89 @param dlg reference to the configuration dialog |
|
90 @return reference to the instantiated page (ConfigurationPageBase) |
|
91 """ |
|
92 page = EditorSearchPage() |
|
93 return page |