src/eric7/Preferences/ConfigurationPages/WebBrowserAppearancePage.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 Web Browser Appearance configuration page.
8 """
9
10 from PyQt6.QtGui import QFont
11
12 from EricWidgets.EricPathPicker import EricPathPickerModes
13
14 from .ConfigurationPageBase import ConfigurationPageBase
15 from .Ui_WebBrowserAppearancePage import Ui_WebBrowserAppearancePage
16
17 import Preferences
18
19
20 class WebBrowserAppearancePage(ConfigurationPageBase,
21 Ui_WebBrowserAppearancePage):
22 """
23 Class implementing the Web Browser Appearance page.
24 """
25 def __init__(self):
26 """
27 Constructor
28 """
29 super().__init__()
30 self.setupUi(self)
31 self.setObjectName("WebBrowserAppearancePage")
32
33 self.styleSheetPicker.setMode(EricPathPickerModes.OPEN_FILE_MODE)
34 self.styleSheetPicker.setFilters(self.tr(
35 "Cascading Style Sheets (*.css);;All files (*)"))
36
37 self.__displayMode = None
38
39 # set initial values
40 defaultFontSize = Preferences.getWebBrowser("DefaultFontSize")
41 fixedFontSize = Preferences.getWebBrowser("DefaultFixedFontSize")
42 self.defaultSizeSpinBox.setValue(defaultFontSize)
43 self.fixedSizeSpinBox.setValue(fixedFontSize)
44 self.minSizeSpinBox.setValue(
45 Preferences.getWebBrowser("MinimumFontSize"))
46 self.minLogicalSizeSpinBox.setValue(
47 Preferences.getWebBrowser("MinimumLogicalFontSize"))
48
49 self.standardFontCombo.setCurrentFont(
50 QFont([Preferences.getWebBrowser("StandardFontFamily")],
51 defaultFontSize, QFont.Weight.Normal, False))
52 self.fixedFontCombo.setCurrentFont(
53 QFont([Preferences.getWebBrowser("FixedFontFamily")],
54 fixedFontSize, QFont.Weight.Normal, False))
55 self.serifFontCombo.setCurrentFont(
56 QFont([Preferences.getWebBrowser("SerifFontFamily")],
57 defaultFontSize, QFont.Weight.Normal, False))
58 self.sansSerifFontCombo.setCurrentFont(
59 QFont([Preferences.getWebBrowser("SansSerifFontFamily")],
60 defaultFontSize, QFont.Weight.Normal, False))
61 self.cursiveFontCombo.setCurrentFont(
62 QFont([Preferences.getWebBrowser("CursiveFontFamily")],
63 defaultFontSize, QFont.Weight.Normal, True))
64 self.fantasyFontCombo.setCurrentFont(
65 QFont([Preferences.getWebBrowser("FantasyFontFamily")],
66 defaultFontSize, QFont.Weight.Normal, False))
67 self.pictographFontCombo.setCurrentFont(
68 QFont([Preferences.getWebBrowser("PictographFontFamily")],
69 defaultFontSize, QFont.Weight.Normal, False))
70
71 self.initColour("SecureUrlColor",
72 self.secureURLsColourButton,
73 Preferences.getWebBrowser)
74 self.initColour("InsecureUrlColor",
75 self.insecureURLsColourButton,
76 Preferences.getWebBrowser)
77 self.initColour("MaliciousUrlColor",
78 self.maliciousURLsColourButton,
79 Preferences.getWebBrowser)
80 self.initColour("PrivateModeUrlColor",
81 self.privateModeURLsColourButton,
82 Preferences.getWebBrowser)
83
84 self.autoLoadImagesCheckBox.setChecked(
85 Preferences.getWebBrowser("AutoLoadImages"))
86
87 self.styleSheetPicker.setText(
88 Preferences.getWebBrowser("UserStyleSheet"))
89
90 self.warnOnMultipleCloseCheckBox.setChecked(
91 Preferences.getWebBrowser("WarnOnMultipleClose"))
92
93 self.scrollbarsCheckBox.setChecked(
94 Preferences.getWebBrowser("ShowScrollBars"))
95 self.toolbarsCheckBox.setChecked(
96 Preferences.getWebBrowser("ShowToolbars"))
97
98 def setMode(self, displayMode):
99 """
100 Public method to perform mode dependent setups.
101
102 @param displayMode mode of the configuration dialog
103 (ConfigurationMode.DEFAULTMODE,
104 ConfigurationMode.WEBBROWSERMODE)
105 """
106 from ..ConfigurationDialog import ConfigurationMode
107 if displayMode in (
108 ConfigurationMode.DEFAULTMODE,
109 ConfigurationMode.WEBBROWSERMODE,
110 ):
111 self.__displayMode = displayMode
112
113 def save(self):
114 """
115 Public slot to save the Help Viewers configuration.
116 """
117 Preferences.setWebBrowser(
118 "StandardFontFamily",
119 self.standardFontCombo.currentFont().family())
120 Preferences.setWebBrowser(
121 "FixedFontFamily",
122 self.fixedFontCombo.currentFont().family())
123 Preferences.setWebBrowser(
124 "SerifFontFamily",
125 self.serifFontCombo.currentFont().family())
126 Preferences.setWebBrowser(
127 "SansSerifFontFamily",
128 self.sansSerifFontCombo.currentFont().family())
129 Preferences.setWebBrowser(
130 "CursiveFontFamily",
131 self.cursiveFontCombo.currentFont().family())
132 Preferences.setWebBrowser(
133 "FantasyFontFamily",
134 self.fantasyFontCombo.currentFont().family())
135 if self.pictographFontCombo.isEnabled():
136 Preferences.setWebBrowser(
137 "PictographFontFamily",
138 self.pictographFontCombo.currentFont().family())
139
140 Preferences.setWebBrowser(
141 "DefaultFontSize",
142 self.defaultSizeSpinBox.value())
143 Preferences.setWebBrowser(
144 "DefaultFixedFontSize",
145 self.fixedSizeSpinBox.value())
146 Preferences.setWebBrowser(
147 "MinimumFontSize",
148 self.minSizeSpinBox.value())
149 Preferences.setWebBrowser(
150 "MinimumLogicalFontSize",
151 self.minLogicalSizeSpinBox.value())
152
153 Preferences.setWebBrowser(
154 "AutoLoadImages",
155 self.autoLoadImagesCheckBox.isChecked())
156
157 Preferences.setWebBrowser(
158 "UserStyleSheet",
159 self.styleSheetPicker.text())
160
161 self.saveColours(Preferences.setWebBrowser)
162
163 Preferences.setWebBrowser(
164 "WarnOnMultipleClose",
165 self.warnOnMultipleCloseCheckBox.isChecked())
166
167 if self.scrollbarsCheckBox.isEnabled():
168 Preferences.setWebBrowser(
169 "ShowScrollBars",
170 self.scrollbarsCheckBox.isChecked())
171
172 Preferences.setWebBrowser(
173 "ShowToolbars",
174 self.toolbarsCheckBox.isChecked())
175
176
177 def create(dlg):
178 """
179 Module function to create the configuration page.
180
181 @param dlg reference to the configuration dialog
182 @return reference to the instantiated page (ConfigurationPageBase)
183 """
184 page = WebBrowserAppearancePage()
185 return page

eric ide

mercurial