|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2006 - 2009 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the Shell configuration page. |
|
8 """ |
|
9 |
|
10 from PyQt4.QtCore import pyqtSlot |
|
11 |
|
12 from ConfigurationPageBase import ConfigurationPageBase |
|
13 from Ui_ShellPage import Ui_ShellPage |
|
14 |
|
15 import Preferences |
|
16 |
|
17 class ShellPage(ConfigurationPageBase, Ui_ShellPage): |
|
18 """ |
|
19 Class implementing the Shell configuration page. |
|
20 """ |
|
21 def __init__(self): |
|
22 """ |
|
23 Constructor |
|
24 """ |
|
25 ConfigurationPageBase.__init__(self) |
|
26 self.setupUi(self) |
|
27 self.setObjectName("ShellPage") |
|
28 |
|
29 # set initial values |
|
30 self.shellLinenowidthSlider.setValue( |
|
31 Preferences.getShell("LinenoWidth")) |
|
32 self.shellLinenoCheckBox.setChecked( |
|
33 Preferences.getShell("LinenoMargin")) |
|
34 self.shellWordWrapCheckBox.setChecked( |
|
35 Preferences.getShell("WrapEnabled")) |
|
36 self.shellACEnabledCheckBox.setChecked( |
|
37 Preferences.getShell("AutoCompletionEnabled")) |
|
38 self.shellCTEnabledCheckBox.setChecked( |
|
39 Preferences.getShell("CallTipsEnabled")) |
|
40 self.shellSyntaxHighlightingCheckBox.setChecked( |
|
41 Preferences.getShell("SyntaxHighlightingEnabled")) |
|
42 self.shellHistorySpinBox.setValue( |
|
43 Preferences.getShell("MaxHistoryEntries")) |
|
44 self.stdOutErrCheckBox.setChecked( |
|
45 Preferences.getShell("ShowStdOutErr")) |
|
46 |
|
47 self.monospacedFont = Preferences.getShell("MonospacedFont") |
|
48 self.monospacedFontSample.setFont(self.monospacedFont) |
|
49 self.monospacedCheckBox.setChecked(\ |
|
50 Preferences.getShell("UseMonospacedFont")) |
|
51 self.marginsFont = Preferences.getShell("MarginsFont") |
|
52 self.marginsFontSample.setFont(self.marginsFont) |
|
53 |
|
54 def save(self): |
|
55 """ |
|
56 Public slot to save the Shell configuration. |
|
57 """ |
|
58 Preferences.setShell("LinenoWidth", |
|
59 self.shellLinenowidthSlider.value()) |
|
60 Preferences.setShell("LinenoMargin", |
|
61 int(self.shellLinenoCheckBox.isChecked())) |
|
62 Preferences.setShell("WrapEnabled", |
|
63 int(self.shellWordWrapCheckBox.isChecked())) |
|
64 Preferences.setShell("AutoCompletionEnabled", |
|
65 int(self.shellACEnabledCheckBox.isChecked())) |
|
66 Preferences.setShell("CallTipsEnabled", |
|
67 int(self.shellCTEnabledCheckBox.isChecked())) |
|
68 Preferences.setShell("SyntaxHighlightingEnabled", |
|
69 int(self.shellSyntaxHighlightingCheckBox.isChecked())) |
|
70 Preferences.setShell("MaxHistoryEntries", |
|
71 self.shellHistorySpinBox.value()) |
|
72 Preferences.setShell("ShowStdOutErr", |
|
73 int(self.stdOutErrCheckBox.isChecked())) |
|
74 |
|
75 Preferences.setShell("MonospacedFont", self.monospacedFont) |
|
76 Preferences.setShell("UseMonospacedFont", |
|
77 int(self.monospacedCheckBox.isChecked())) |
|
78 Preferences.setShell("MarginsFont", self.marginsFont) |
|
79 |
|
80 @pyqtSlot() |
|
81 def on_monospacedFontButton_clicked(self): |
|
82 """ |
|
83 Private method used to select the font to be used as the monospaced font. |
|
84 """ |
|
85 self.monospacedFont = \ |
|
86 self.selectFont(self.monospacedFontSample, self.monospacedFont) |
|
87 |
|
88 @pyqtSlot() |
|
89 def on_linenumbersFontButton_clicked(self): |
|
90 """ |
|
91 Private method used to select the font for the editor margins. |
|
92 """ |
|
93 self.marginsFont = self.selectFont(self.marginsFontSample, self.marginsFont) |
|
94 |
|
95 def polishPage(self): |
|
96 """ |
|
97 Public slot to perform some polishing actions. |
|
98 """ |
|
99 self.monospacedFontSample.setFont(self.monospacedFont) |
|
100 self.marginsFontSample.setFont(self.marginsFont) |
|
101 |
|
102 def create(dlg): |
|
103 """ |
|
104 Module function to create the configuration page. |
|
105 |
|
106 @param dlg reference to the configuration dialog |
|
107 """ |
|
108 page = ShellPage() |
|
109 return page |