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