src/eric7/Preferences/ConfigurationPages/EditorTypingPage.py

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

eric ide

mercurial