src/eric7/Preferences/ConfigurationPages/EditorTypingPage.py

branch
eric7
changeset 9209
b99e7fd55fd3
parent 8881
54e42bc2437a
child 9221
bf71ee032bb4
equal deleted inserted replaced
9208:3fc8dfeb6ebe 9209:b99e7fd55fd3
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2007 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the Editor Typing configuration page.
8 """
9
10 from PyQt6.QtCore import pyqtSlot
11
12 from .ConfigurationPageBase import ConfigurationPageBase
13 from .Ui_EditorTypingPage import Ui_EditorTypingPage
14
15 import Preferences
16
17
18 class EditorTypingPage(ConfigurationPageBase, Ui_EditorTypingPage):
19 """
20 Class implementing the Editor Typing configuration page.
21 """
22 def __init__(self):
23 """
24 Constructor
25 """
26 super().__init__()
27 self.setupUi(self)
28 self.setObjectName("EditorTypingPage")
29
30 # set initial values
31 self.pageIds = {
32 ' ': self.stackedWidget.indexOf(self.emptyPage),
33 'Python': self.stackedWidget.indexOf(self.pythonPage),
34 'Ruby': self.stackedWidget.indexOf(self.rubyPage),
35 'YAML': self.stackedWidget.indexOf(self.yamlPage),
36 }
37 languages = sorted(self.pageIds.keys())
38 for language in languages:
39 self.languageCombo.addItem(language, self.pageIds[language])
40
41 # Python
42 self.pythonGroup.setChecked(
43 Preferences.getEditorTyping("Python/EnabledTypingAids"))
44 self.pythonInsertClosingBraceCheckBox.setChecked(
45 Preferences.getEditorTyping("Python/InsertClosingBrace"))
46 self.pythonSkipBraceCheckBox.setChecked(
47 Preferences.getEditorTyping("Python/SkipBrace"))
48 self.pythonIndentBraceCheckBox.setChecked(
49 Preferences.getEditorTyping("Python/IndentBrace"))
50 self.pythonInsertQuoteCheckBox.setChecked(
51 Preferences.getEditorTyping("Python/InsertQuote"))
52 self.pythonDedentElseCheckBox.setChecked(
53 Preferences.getEditorTyping("Python/DedentElse"))
54 self.pythonDedentExceptCheckBox.setChecked(
55 Preferences.getEditorTyping("Python/DedentExcept"))
56 self.pythonInsertImportCheckBox.setChecked(
57 Preferences.getEditorTyping("Python/InsertImport"))
58 self.pythonImportBraceTypeCheckBox.setChecked(
59 Preferences.getEditorTyping("Python/ImportBraceType"))
60 self.pythonInsertSelfCheckBox.setChecked(
61 Preferences.getEditorTyping("Python/InsertSelf"))
62 self.pythonInsertBlankCheckBox.setChecked(
63 Preferences.getEditorTyping("Python/InsertBlank"))
64 self.pythonColonDetectionCheckBox.setChecked(
65 Preferences.getEditorTyping("Python/ColonDetection"))
66 self.pythonDedentDefCheckBox.setChecked(
67 Preferences.getEditorTyping("Python/DedentDef"))
68
69 # Ruby
70 self.rubyGroup.setChecked(
71 Preferences.getEditorTyping("Ruby/EnabledTypingAids"))
72 self.rubyInsertClosingBraceCheckBox.setChecked(
73 Preferences.getEditorTyping("Ruby/InsertClosingBrace"))
74 self.rubySkipBraceCheckBox.setChecked(
75 Preferences.getEditorTyping("Ruby/SkipBrace"))
76 self.rubyIndentBraceCheckBox.setChecked(
77 Preferences.getEditorTyping("Ruby/IndentBrace"))
78 self.rubyInsertQuoteCheckBox.setChecked(
79 Preferences.getEditorTyping("Ruby/InsertQuote"))
80 self.rubyInsertBlankCheckBox.setChecked(
81 Preferences.getEditorTyping("Ruby/InsertBlank"))
82 self.rubyInsertHereDocCheckBox.setChecked(
83 Preferences.getEditorTyping("Ruby/InsertHereDoc"))
84 self.rubyInsertInlineDocCheckBox.setChecked(
85 Preferences.getEditorTyping("Ruby/InsertInlineDoc"))
86
87 # YAML
88 self.yamlGroup.setChecked(
89 Preferences.getEditorTyping("Yaml/EnabledTypingAids"))
90 self.yamlInsertClosingBraceCheckBox.setChecked(
91 Preferences.getEditorTyping("Yaml/InsertClosingBrace"))
92 self.yamlSkipBraceCheckBox.setChecked(
93 Preferences.getEditorTyping("Yaml/SkipBrace"))
94 self.yamlInsertQuoteCheckBox.setChecked(
95 Preferences.getEditorTyping("Yaml/InsertQuote"))
96 self.yamlAutoIndentationCheckBox.setChecked(
97 Preferences.getEditorTyping("Yaml/AutoIndentation"))
98 self.yamlColonDetectionCheckBox.setChecked(
99 Preferences.getEditorTyping("Yaml/ColonDetection"))
100 self.yamlInsertBlankDashCheckBox.setChecked(
101 Preferences.getEditorTyping("Yaml/InsertBlankDash"))
102 self.yamlInsertBlankColonCheckBox.setChecked(
103 Preferences.getEditorTyping("Yaml/InsertBlankColon"))
104 self.yamlInsertBlankQuestionCheckBox.setChecked(
105 Preferences.getEditorTyping("Yaml/InsertBlankQuestion"))
106 self.yamlInsertBlankCommaCheckBox.setChecked(
107 Preferences.getEditorTyping("Yaml/InsertBlankComma"))
108
109 self.on_languageCombo_activated(0)
110
111 def save(self):
112 """
113 Public slot to save the Editor Typing configuration.
114 """
115 # Python
116 Preferences.setEditorTyping(
117 "Python/EnabledTypingAids",
118 self.pythonGroup.isChecked())
119 Preferences.setEditorTyping(
120 "Python/InsertClosingBrace",
121 self.pythonInsertClosingBraceCheckBox.isChecked())
122 Preferences.setEditorTyping(
123 "Python/SkipBrace",
124 self.pythonSkipBraceCheckBox.isChecked())
125 Preferences.setEditorTyping(
126 "Python/IndentBrace",
127 self.pythonIndentBraceCheckBox.isChecked())
128 Preferences.setEditorTyping(
129 "Python/InsertQuote",
130 self.pythonInsertQuoteCheckBox.isChecked())
131 Preferences.setEditorTyping(
132 "Python/DedentElse",
133 self.pythonDedentElseCheckBox.isChecked())
134 Preferences.setEditorTyping(
135 "Python/DedentExcept",
136 self.pythonDedentExceptCheckBox.isChecked())
137 Preferences.setEditorTyping(
138 "Python/InsertImport",
139 self.pythonInsertImportCheckBox.isChecked())
140 Preferences.setEditorTyping(
141 "Python/ImportBraceType",
142 self.pythonImportBraceTypeCheckBox.isChecked())
143 Preferences.setEditorTyping(
144 "Python/InsertSelf",
145 self.pythonInsertSelfCheckBox.isChecked())
146 Preferences.setEditorTyping(
147 "Python/InsertBlank",
148 self.pythonInsertBlankCheckBox.isChecked())
149 Preferences.setEditorTyping(
150 "Python/ColonDetection",
151 self.pythonColonDetectionCheckBox.isChecked())
152 Preferences.setEditorTyping(
153 "Python/DedentDef",
154 self.pythonDedentDefCheckBox.isChecked())
155
156 # Ruby
157 Preferences.setEditorTyping(
158 "Ruby/EnabledTypingAids",
159 self.rubyGroup.isChecked())
160 Preferences.setEditorTyping(
161 "Ruby/InsertClosingBrace",
162 self.rubyInsertClosingBraceCheckBox.isChecked())
163 Preferences.setEditorTyping(
164 "Ruby/SkipBrace",
165 self.rubySkipBraceCheckBox.isChecked())
166 Preferences.setEditorTyping(
167 "Ruby/IndentBrace",
168 self.rubyIndentBraceCheckBox.isChecked())
169 Preferences.setEditorTyping(
170 "Ruby/InsertQuote",
171 self.rubyInsertQuoteCheckBox.isChecked())
172 Preferences.setEditorTyping(
173 "Ruby/InsertBlank",
174 self.rubyInsertBlankCheckBox.isChecked())
175 Preferences.setEditorTyping(
176 "Ruby/InsertHereDoc",
177 self.rubyInsertHereDocCheckBox.isChecked())
178 Preferences.setEditorTyping(
179 "Ruby/InsertInlineDoc",
180 self.rubyInsertInlineDocCheckBox.isChecked())
181
182 # YAML
183 Preferences.setEditorTyping(
184 "Yaml/EnabledTypingAids",
185 self.yamlGroup.isChecked())
186 Preferences.setEditorTyping(
187 "Yaml/InsertClosingBrace",
188 self.yamlInsertClosingBraceCheckBox.isChecked())
189 Preferences.setEditorTyping(
190 "Yaml/SkipBrace",
191 self.yamlSkipBraceCheckBox.isChecked())
192 Preferences.setEditorTyping(
193 "Yaml/InsertQuote",
194 self.yamlInsertQuoteCheckBox.isChecked())
195 Preferences.setEditorTyping(
196 "Yaml/AutoIndentation",
197 self.yamlAutoIndentationCheckBox.isChecked())
198 Preferences.setEditorTyping(
199 "Yaml/ColonDetection",
200 self.yamlColonDetectionCheckBox.isChecked())
201 Preferences.setEditorTyping(
202 "Yaml/InsertBlankDash",
203 self.yamlInsertBlankDashCheckBox.isChecked())
204 Preferences.setEditorTyping(
205 "Yaml/InsertBlankColon",
206 self.yamlInsertBlankColonCheckBox.isChecked())
207 Preferences.setEditorTyping(
208 "Yaml/InsertBlankQuestion",
209 self.yamlInsertBlankQuestionCheckBox.isChecked())
210 Preferences.setEditorTyping(
211 "Yaml/InsertBlankComma",
212 self.yamlInsertBlankCommaCheckBox.isChecked())
213
214 @pyqtSlot(int)
215 def on_languageCombo_activated(self, index):
216 """
217 Private slot to select the page related to the selected language.
218
219 @param index index of the selected entry
220 @type int
221 """
222 language = self.languageCombo.itemText(index)
223 try:
224 index = self.pageIds[language]
225 except KeyError:
226 index = self.pageIds[' ']
227 self.stackedWidget.setCurrentIndex(index)
228
229
230 def create(dlg):
231 """
232 Module function to create the configuration page.
233
234 @param dlg reference to the configuration dialog
235 @return reference to the instantiated page (ConfigurationPageBase)
236 """
237 page = EditorTypingPage()
238 return page

eric ide

mercurial