Preferences/ConfigurationPages/EditorTypingPage.py

changeset 0
de9c2efb9d02
child 7
c679fb30c8f3
equal deleted inserted replaced
-1:000000000000 0:de9c2efb9d02
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2007 - 2009 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the Editor Typing configuration page.
8 """
9
10 from PyQt4.QtCore import QVariant, pyqtSlot
11
12 from ConfigurationPageBase import ConfigurationPageBase
13 from Ui_EditorTypingPage import Ui_EditorTypingPage
14
15 import Preferences
16
17 class EditorTypingPage(ConfigurationPageBase, Ui_EditorTypingPage):
18 """
19 Class implementing the Editor Typing configuration page.
20 """
21 def __init__(self):
22 """
23 Constructor
24 """
25 ConfigurationPageBase.__init__(self)
26 self.setupUi(self)
27 self.setObjectName("EditorTypingPage")
28
29 # set initial values
30 self.pageIds = {}
31 self.pageIds[' '] = self.stackedWidget.indexOf(self.emptyPage)
32 self.pageIds['Python'] = self.stackedWidget.indexOf(self.pythonPage)
33 self.pageIds['Ruby'] = self.stackedWidget.indexOf(self.rubyPage)
34 languages = self.pageIds.keys()
35 languages.sort()
36 for language in languages:
37 self.languageCombo.addItem(language, QVariant(self.pageIds[language]))
38
39 # Python
40 self.pythonGroup.setChecked(\
41 Preferences.getEditorTyping("Python/EnabledTypingAids"))
42 self.pythonInsertClosingBraceCheckBox.setChecked(\
43 Preferences.getEditorTyping("Python/InsertClosingBrace"))
44 self.pythonSkipBraceCheckBox.setChecked(\
45 Preferences.getEditorTyping("Python/SkipBrace"))
46 self.pythonIndentBraceCheckBox.setChecked(\
47 Preferences.getEditorTyping("Python/IndentBrace"))
48 self.pythonInsertQuoteCheckBox.setChecked(\
49 Preferences.getEditorTyping("Python/InsertQuote"))
50 self.pythonDedentElseCheckBox.setChecked(\
51 Preferences.getEditorTyping("Python/DedentElse"))
52 self.pythonDedentExceptCheckBox.setChecked(\
53 Preferences.getEditorTyping("Python/DedentExcept"))
54 self.pythonDedentExceptPy24CheckBox.setChecked(\
55 Preferences.getEditorTyping("Python/Py24StyleTry"))
56 self.pythonInsertImportCheckBox.setChecked(\
57 Preferences.getEditorTyping("Python/InsertImport"))
58 self.pythonInsertSelfCheckBox.setChecked(\
59 Preferences.getEditorTyping("Python/InsertSelf"))
60 self.pythonInsertBlankCheckBox.setChecked(\
61 Preferences.getEditorTyping("Python/InsertBlank"))
62 self.pythonColonDetectionCheckBox.setChecked(\
63 Preferences.getEditorTyping("Python/ColonDetection"))
64 self.pythonDedentDefCheckBox.setChecked(
65 Preferences.getEditorTyping("Python/DedentDef"))
66
67 # Ruby
68 self.rubyGroup.setChecked(\
69 Preferences.getEditorTyping("Ruby/EnabledTypingAids"))
70 self.rubyInsertClosingBraceCheckBox.setChecked(\
71 Preferences.getEditorTyping("Ruby/InsertClosingBrace"))
72 self.rubySkipBraceCheckBox.setChecked(\
73 Preferences.getEditorTyping("Ruby/SkipBrace"))
74 self.rubyIndentBraceCheckBox.setChecked(\
75 Preferences.getEditorTyping("Ruby/IndentBrace"))
76 self.rubyInsertQuoteCheckBox.setChecked(\
77 Preferences.getEditorTyping("Ruby/InsertQuote"))
78 self.rubyInsertBlankCheckBox.setChecked(\
79 Preferences.getEditorTyping("Ruby/InsertBlank"))
80 self.rubyInsertHereDocCheckBox.setChecked(\
81 Preferences.getEditorTyping("Ruby/InsertHereDoc"))
82 self.rubyInsertInlineDocCheckBox.setChecked(\
83 Preferences.getEditorTyping("Ruby/InsertInlineDoc"))
84
85 self.on_languageCombo_activated(' ')
86
87 def save(self):
88 """
89 Public slot to save the Editor Typing configuration.
90 """
91 # Python
92 Preferences.setEditorTyping("Python/EnabledTypingAids",
93 int(self.pythonGroup.isChecked()))
94 Preferences.setEditorTyping("Python/InsertClosingBrace",
95 int(self.pythonInsertClosingBraceCheckBox.isChecked()))
96 Preferences.setEditorTyping("Python/SkipBrace",
97 int(self.pythonSkipBraceCheckBox.isChecked()))
98 Preferences.setEditorTyping("Python/IndentBrace",
99 int(self.pythonIndentBraceCheckBox.isChecked()))
100 Preferences.setEditorTyping("Python/InsertQuote",
101 int(self.pythonInsertQuoteCheckBox.isChecked()))
102 Preferences.setEditorTyping("Python/DedentElse",
103 int(self.pythonDedentElseCheckBox.isChecked()))
104 Preferences.setEditorTyping("Python/DedentExcept",
105 int(self.pythonDedentExceptCheckBox.isChecked()))
106 Preferences.setEditorTyping("Python/Py24StyleTry",
107 int(self.pythonDedentExceptPy24CheckBox.isChecked()))
108 Preferences.setEditorTyping("Python/InsertImport",
109 int(self.pythonInsertImportCheckBox.isChecked()))
110 Preferences.setEditorTyping("Python/InsertSelf",
111 int(self.pythonInsertSelfCheckBox.isChecked()))
112 Preferences.setEditorTyping("Python/InsertBlank",
113 int(self.pythonInsertBlankCheckBox.isChecked()))
114 Preferences.setEditorTyping("Python/ColonDetection",
115 int(self.pythonColonDetectionCheckBox.isChecked()))
116 Preferences.setEditorTyping("Python/DedentDef",
117 int(self.pythonDedentDefCheckBox.isChecked()))
118
119 # Ruby
120 Preferences.setEditorTyping("Ruby/EnabledTypingAids",
121 int(self.rubyGroup.isChecked()))
122 Preferences.setEditorTyping("Ruby/InsertClosingBrace",
123 int(self.rubyInsertClosingBraceCheckBox.isChecked()))
124 Preferences.setEditorTyping("Ruby/SkipBrace",
125 int(self.rubySkipBraceCheckBox.isChecked()))
126 Preferences.setEditorTyping("Ruby/IndentBrace",
127 int(self.rubyIndentBraceCheckBox.isChecked()))
128 Preferences.setEditorTyping("Ruby/InsertQuote",
129 int(self.rubyInsertQuoteCheckBox.isChecked()))
130 Preferences.setEditorTyping("Ruby/InsertBlank",
131 int(self.rubyInsertBlankCheckBox.isChecked()))
132 Preferences.setEditorTyping("Ruby/InsertHereDoc",
133 int(self.rubyInsertHereDocCheckBox.isChecked()))
134 Preferences.setEditorTyping("Ruby/InsertInlineDoc",
135 int(self.rubyInsertInlineDocCheckBox.isChecked()))
136
137 @pyqtSlot(str)
138 def on_languageCombo_activated(self, language):
139 """
140 Private slot to select the page related to the selected language.
141
142 @param language name of the selected language (string)
143 """
144 try:
145 index = self.pageIds[language]
146 except KeyError:
147 index = self.pageIds[' ']
148 self.stackedWidget.setCurrentIndex(index)
149
150 def create(dlg):
151 """
152 Module function to create the configuration page.
153
154 @param dlg reference to the configuration dialog
155 """
156 page = EditorTypingPage()
157 return page

eric ide

mercurial