src/eric7/Preferences/ConfigurationPages/ShellPage.py

branch
eric7
changeset 9209
b99e7fd55fd3
parent 8881
54e42bc2437a
child 9221
bf71ee032bb4
equal deleted inserted replaced
9208:3fc8dfeb6ebe 9209:b99e7fd55fd3
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2006 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the Shell configuration page.
8 """
9
10 from PyQt6.QtCore import pyqtSlot
11 from PyQt6.QtWidgets import QFontDialog
12
13 from .ConfigurationPageBase import ConfigurationPageBase
14 from .Ui_ShellPage import Ui_ShellPage
15
16 import Preferences
17
18 from QScintilla.Shell import ShellHistoryStyle
19
20
21 class ShellPage(ConfigurationPageBase, Ui_ShellPage):
22 """
23 Class implementing the Shell configuration page.
24 """
25 def __init__(self):
26 """
27 Constructor
28 """
29 super().__init__()
30 self.setupUi(self)
31 self.setObjectName("ShellPage")
32
33 self.shellHistoryStyleComboBox.addItem(
34 self.tr("Disabled"), ShellHistoryStyle.DISABLED.value)
35 self.shellHistoryStyleComboBox.addItem(
36 self.tr("Linux Style"), ShellHistoryStyle.LINUXSTYLE.value)
37 self.shellHistoryStyleComboBox.addItem(
38 self.tr("Windows Style"), ShellHistoryStyle.WINDOWSSTYLE.value)
39
40 # set initial values
41 self.shellLinenoCheckBox.setChecked(
42 Preferences.getShell("LinenoMargin"))
43 self.shellWordWrapCheckBox.setChecked(
44 Preferences.getShell("WrapEnabled"))
45 self.shellACEnabledCheckBox.setChecked(
46 Preferences.getShell("AutoCompletionEnabled"))
47 self.shellCTEnabledCheckBox.setChecked(
48 Preferences.getShell("CallTipsEnabled"))
49 self.shellSyntaxHighlightingCheckBox.setChecked(
50 Preferences.getShell("SyntaxHighlightingEnabled"))
51 self.rememberCheckBox.setChecked(
52 Preferences.getShell("StartWithMostRecentlyUsedEnvironment"))
53 self.shellHistorySpinBox.setValue(
54 Preferences.getShell("MaxHistoryEntries"))
55 index = self.shellHistoryStyleComboBox.findData(
56 Preferences.getShell("HistoryStyle").value)
57 self.shellHistoryStyleComboBox.setCurrentIndex(index)
58 self.shellHistoryWrapCheckBox.setChecked(
59 Preferences.getShell("HistoryWrap"))
60 self.shellHistoryCursorKeysCheckBox.setChecked(
61 Preferences.getShell("HistoryNavigateByCursor"))
62 self.stdOutErrCheckBox.setChecked(
63 Preferences.getShell("ShowStdOutErr"))
64
65 self.monospacedFont = Preferences.getShell("MonospacedFont")
66 self.monospacedFontSample.setFont(self.monospacedFont)
67 self.monospacedCheckBox.setChecked(
68 Preferences.getShell("UseMonospacedFont"))
69 self.marginsFont = Preferences.getShell("MarginsFont")
70 self.marginsFontSample.setFont(self.marginsFont)
71
72 def save(self):
73 """
74 Public slot to save the Shell configuration.
75 """
76 Preferences.setShell(
77 "LinenoMargin",
78 self.shellLinenoCheckBox.isChecked())
79 Preferences.setShell(
80 "WrapEnabled",
81 self.shellWordWrapCheckBox.isChecked())
82 Preferences.setShell(
83 "AutoCompletionEnabled",
84 self.shellACEnabledCheckBox.isChecked())
85 Preferences.setShell(
86 "CallTipsEnabled",
87 self.shellCTEnabledCheckBox.isChecked())
88 Preferences.setShell(
89 "SyntaxHighlightingEnabled",
90 self.shellSyntaxHighlightingCheckBox.isChecked())
91 Preferences.setShell(
92 "StartWithMostRecentlyUsedEnvironment",
93 self.rememberCheckBox.isChecked())
94 Preferences.setShell(
95 "MaxHistoryEntries",
96 self.shellHistorySpinBox.value())
97 Preferences.setShell(
98 "HistoryStyle",
99 ShellHistoryStyle(self.shellHistoryStyleComboBox.currentData()))
100 Preferences.setShell(
101 "HistoryWrap",
102 self.shellHistoryWrapCheckBox.isChecked())
103 Preferences.setShell(
104 "HistoryNavigateByCursor",
105 self.shellHistoryCursorKeysCheckBox.isChecked())
106 Preferences.setShell(
107 "ShowStdOutErr",
108 self.stdOutErrCheckBox.isChecked())
109
110 Preferences.setShell("MonospacedFont", self.monospacedFont)
111 Preferences.setShell(
112 "UseMonospacedFont",
113 self.monospacedCheckBox.isChecked())
114 Preferences.setShell("MarginsFont", self.marginsFont)
115
116 @pyqtSlot()
117 def on_monospacedFontButton_clicked(self):
118 """
119 Private method used to select the font to be used as the monospaced
120 font.
121 """
122 self.monospacedFont = self.selectFont(
123 self.monospacedFontSample, self.monospacedFont,
124 options=QFontDialog.FontDialogOption.MonospacedFonts)
125
126 @pyqtSlot()
127 def on_linenumbersFontButton_clicked(self):
128 """
129 Private method used to select the font for the editor margins.
130 """
131 self.marginsFont = self.selectFont(
132 self.marginsFontSample, self.marginsFont,
133 options=QFontDialog.FontDialogOption.MonospacedFonts)
134
135 def polishPage(self):
136 """
137 Public slot to perform some polishing actions.
138 """
139 self.monospacedFontSample.setFont(self.monospacedFont)
140 self.marginsFontSample.setFont(self.marginsFont)
141
142
143 def create(dlg):
144 """
145 Module function to create the configuration page.
146
147 @param dlg reference to the configuration dialog
148 @return reference to the instantiated page (ConfigurationPageBase)
149 """
150 page = ShellPage()
151 return page

eric ide

mercurial