|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2006 - 2009 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the Editor General configuration page. |
|
8 """ |
|
9 |
|
10 import QScintilla.Lexers |
|
11 |
|
12 from ConfigurationPageBase import ConfigurationPageBase |
|
13 from Ui_EditorGeneralPage import Ui_EditorGeneralPage |
|
14 |
|
15 import Preferences |
|
16 |
|
17 class EditorGeneralPage(ConfigurationPageBase, Ui_EditorGeneralPage): |
|
18 """ |
|
19 Class implementing the Editor General configuration page. |
|
20 """ |
|
21 def __init__(self): |
|
22 """ |
|
23 Constructor |
|
24 """ |
|
25 ConfigurationPageBase.__init__(self) |
|
26 self.setupUi(self) |
|
27 self.setObjectName("EditorGeneralPage") |
|
28 |
|
29 # set initial values |
|
30 self.tabwidthSlider.setValue(\ |
|
31 Preferences.getEditor("TabWidth")) |
|
32 self.indentwidthSlider.setValue(\ |
|
33 Preferences.getEditor("IndentWidth")) |
|
34 self.indentguidesCheckBox.setChecked(\ |
|
35 Preferences.getEditor("IndentationGuides")) |
|
36 self.tabforindentationCheckBox.setChecked(\ |
|
37 Preferences.getEditor("TabForIndentation")) |
|
38 self.tabindentsCheckBox.setChecked(\ |
|
39 Preferences.getEditor("TabIndents")) |
|
40 self.converttabsCheckBox.setChecked(\ |
|
41 Preferences.getEditor("ConvertTabsOnLoad")) |
|
42 self.autoindentCheckBox.setChecked(\ |
|
43 Preferences.getEditor("AutoIndentation")) |
|
44 self.comment0CheckBox.setChecked( |
|
45 Preferences.getEditor("CommentColumn0")) |
|
46 |
|
47 def save(self): |
|
48 """ |
|
49 Public slot to save the Editor General configuration. |
|
50 """ |
|
51 Preferences.setEditor("TabWidth", |
|
52 self.tabwidthSlider.value()) |
|
53 Preferences.setEditor("IndentWidth", |
|
54 self.indentwidthSlider.value()) |
|
55 Preferences.setEditor("IndentationGuides", |
|
56 int(self.indentguidesCheckBox.isChecked())) |
|
57 Preferences.setEditor("TabForIndentation", |
|
58 int(self.tabforindentationCheckBox.isChecked())) |
|
59 Preferences.setEditor("TabIndents", |
|
60 int(self.tabindentsCheckBox.isChecked())) |
|
61 Preferences.setEditor("ConvertTabsOnLoad", |
|
62 int(self.converttabsCheckBox.isChecked())) |
|
63 Preferences.setEditor("AutoIndentation", |
|
64 int(self.autoindentCheckBox.isChecked())) |
|
65 Preferences.setEditor("CommentColumn0", |
|
66 int(self.comment0CheckBox.isChecked())) |
|
67 |
|
68 def on_tabforindentationCheckBox_toggled(self, checked): |
|
69 """ |
|
70 Private slot used to set the tab conversion check box. |
|
71 |
|
72 @param checked flag received from the signal (boolean) |
|
73 """ |
|
74 if checked and self.converttabsCheckBox.isChecked(): |
|
75 self.converttabsCheckBox.setChecked(not checked) |
|
76 self.converttabsCheckBox.setEnabled(not checked) |
|
77 |
|
78 def create(dlg): |
|
79 """ |
|
80 Module function to create the configuration page. |
|
81 |
|
82 @param dlg reference to the configuration dialog |
|
83 """ |
|
84 page = EditorGeneralPage() |
|
85 return page |