|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2008 - 2009 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the Terminal configuration page. |
|
8 """ |
|
9 |
|
10 import sys |
|
11 |
|
12 from PyQt4.QtCore import pyqtSlot |
|
13 |
|
14 from ConfigurationPageBase import ConfigurationPageBase |
|
15 from Ui_TerminalPage import Ui_TerminalPage |
|
16 |
|
17 import Preferences |
|
18 import Utilities |
|
19 |
|
20 class TerminalPage(ConfigurationPageBase, Ui_TerminalPage): |
|
21 """ |
|
22 Class implementing the Terminal configuration page. |
|
23 """ |
|
24 def __init__(self): |
|
25 """ |
|
26 Constructor |
|
27 """ |
|
28 ConfigurationPageBase.__init__(self) |
|
29 self.setupUi(self) |
|
30 self.setObjectName("TerminalPage") |
|
31 |
|
32 if Utilities.isWindowsPlatform(): |
|
33 self.shellGroup.setEnabled(False) |
|
34 else: |
|
35 self.shellCombo.addItems(["ash", "bash", "csh", "ksh", "sh", "tcsh", "zsh"]) |
|
36 |
|
37 # set initial values |
|
38 self.linenowidthSlider.setValue(\ |
|
39 Preferences.getTerminal("LinenoWidth")) |
|
40 self.linenoCheckBox.setChecked(\ |
|
41 Preferences.getTerminal("LinenoMargin")) |
|
42 self.syntaxHighlightingCheckBox.setChecked(\ |
|
43 Preferences.getTerminal("SyntaxHighlightingEnabled")) |
|
44 self.historySpinBox.setValue(\ |
|
45 Preferences.getTerminal("MaxHistoryEntries")) |
|
46 |
|
47 self.monospacedFont = Preferences.getTerminal("MonospacedFont") |
|
48 self.monospacedFontSample.setFont(self.monospacedFont) |
|
49 self.monospacedCheckBox.setChecked(\ |
|
50 Preferences.getTerminal("UseMonospacedFont")) |
|
51 self.marginsFont = Preferences.getTerminal("MarginsFont") |
|
52 self.marginsFontSample.setFont(self.marginsFont) |
|
53 |
|
54 self.shellCombo.setEditText( |
|
55 Preferences.getTerminal("Shell")) |
|
56 self.interactiveCheckBox.setChecked( |
|
57 Preferences.getTerminal("ShellInteractive")) |
|
58 |
|
59 def save(self): |
|
60 """ |
|
61 Public slot to save the Shell configuration. |
|
62 """ |
|
63 Preferences.setTerminal("LinenoWidth", |
|
64 self.linenowidthSlider.value()) |
|
65 Preferences.setTerminal("LinenoMargin", |
|
66 int(self.linenoCheckBox.isChecked())) |
|
67 Preferences.setTerminal("SyntaxHighlightingEnabled", |
|
68 int(self.syntaxHighlightingCheckBox.isChecked())) |
|
69 Preferences.setTerminal("MaxHistoryEntries", |
|
70 self.historySpinBox.value()) |
|
71 |
|
72 Preferences.setTerminal("MonospacedFont", self.monospacedFont) |
|
73 Preferences.setTerminal("UseMonospacedFont", |
|
74 int(self.monospacedCheckBox.isChecked())) |
|
75 Preferences.setTerminal("MarginsFont", self.marginsFont) |
|
76 |
|
77 Preferences.setTerminal("Shell", |
|
78 self.shellCombo.currentText()) |
|
79 Preferences.setTerminal("ShellInteractive", |
|
80 int(self.interactiveCheckBox.isChecked())) |
|
81 |
|
82 @pyqtSlot() |
|
83 def on_monospacedFontButton_clicked(self): |
|
84 """ |
|
85 Private method used to select the font to be used as the monospaced font. |
|
86 """ |
|
87 self.monospacedFont = \ |
|
88 self.selectFont(self.monospacedFontSample, self.monospacedFont) |
|
89 |
|
90 @pyqtSlot() |
|
91 def on_linenumbersFontButton_clicked(self): |
|
92 """ |
|
93 Private method used to select the font for the editor margins. |
|
94 """ |
|
95 self.marginsFont = self.selectFont(self.marginsFontSample, self.marginsFont) |
|
96 |
|
97 def polishPage(self): |
|
98 """ |
|
99 Public slot to perform some polishing actions. |
|
100 """ |
|
101 self.monospacedFontSample.setFont(self.monospacedFont) |
|
102 self.marginsFontSample.setFont(self.marginsFont) |
|
103 |
|
104 def create(dlg): |
|
105 """ |
|
106 Module function to create the configuration page. |
|
107 |
|
108 @param dlg reference to the configuration dialog |
|
109 """ |
|
110 page = TerminalPage() |
|
111 return page |