eric6/Preferences/ConfigurationPages/ShellPage.py

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

eric ide

mercurial