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