eric6/Preferences/ConfigurationPages/HelpAppearancePage.py

branch
maintenance
changeset 7286
7eb04391adf7
parent 7226
babe80d84a3e
parent 7285
1ff497f33f31
child 7287
1c17f2191bdd
equal deleted inserted replaced
7226:babe80d84a3e 7286:7eb04391adf7
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2006 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the Help Viewers 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 E5Gui.E5PathPicker import E5PathPickerModes
16
17 from .ConfigurationPageBase import ConfigurationPageBase
18 from .Ui_HelpAppearancePage import Ui_HelpAppearancePage
19
20 import Preferences
21
22 try:
23 MonospacedFontsOption = QFontDialog.MonospacedFonts
24 except AttributeError:
25 MonospacedFontsOption = QFontDialog.FontDialogOptions(0x10)
26
27
28 class HelpAppearancePage(ConfigurationPageBase, Ui_HelpAppearancePage):
29 """
30 Class implementing the Help Viewer Appearance page.
31 """
32 def __init__(self):
33 """
34 Constructor
35 """
36 super(HelpAppearancePage, self).__init__()
37 self.setupUi(self)
38 self.setObjectName("HelpAppearancePage")
39
40 self.styleSheetPicker.setMode(E5PathPickerModes.OpenFileMode)
41 self.styleSheetPicker.setFilters(self.tr(
42 "Cascading Style Sheets (*.css);;All files (*)"))
43
44 self.__displayMode = None
45
46 # set initial values
47 self.standardFont = Preferences.getHelp("StandardFont")
48 self.standardFontSample.setFont(self.standardFont)
49 self.standardFontSample.setText(
50 "{0} {1}".format(self.standardFont.family(),
51 self.standardFont.pointSize()))
52
53 self.fixedFont = Preferences.getHelp("FixedFont")
54 self.fixedFontSample.setFont(self.fixedFont)
55 self.fixedFontSample.setText(
56 "{0} {1}".format(self.fixedFont.family(),
57 self.fixedFont.pointSize()))
58
59 self.initColour("SaveUrlColor", self.secureURLsColourButton,
60 Preferences.getHelp)
61
62 self.autoLoadImagesCheckBox.setChecked(
63 Preferences.getHelp("AutoLoadImages"))
64
65 self.styleSheetPicker.setText(Preferences.getHelp("UserStyleSheet"))
66
67 self.warnOnMultipleCloseCheckBox.setChecked(
68 Preferences.getHelp("WarnOnMultipleClose"))
69
70 def setMode(self, displayMode):
71 """
72 Public method to perform mode dependent setups.
73
74 @param displayMode mode of the configuration dialog
75 (ConfigurationWidget.DefaultMode,
76 ConfigurationWidget.HelpBrowserMode,
77 ConfigurationWidget.TrayStarterMode)
78 """
79 from ..ConfigurationDialog import ConfigurationWidget
80 assert displayMode in (
81 ConfigurationWidget.DefaultMode,
82 ConfigurationWidget.HelpBrowserMode,
83 ConfigurationWidget.TrayStarterMode
84 )
85
86 self.__displayMode = displayMode
87
88 def save(self):
89 """
90 Public slot to save the Help Viewers configuration.
91 """
92 Preferences.setHelp("StandardFont", self.standardFont)
93 Preferences.setHelp("FixedFont", self.fixedFont)
94
95 Preferences.setHelp(
96 "AutoLoadImages",
97 self.autoLoadImagesCheckBox.isChecked())
98
99 Preferences.setHelp("UserStyleSheet", self.styleSheetPicker.text())
100
101 self.saveColours(Preferences.setHelp)
102
103 Preferences.setHelp(
104 "WarnOnMultipleClose",
105 self.warnOnMultipleCloseCheckBox.isChecked())
106
107 @pyqtSlot()
108 def on_standardFontButton_clicked(self):
109 """
110 Private method used to select the standard font.
111 """
112 self.standardFont = \
113 self.selectFont(self.standardFontSample, self.standardFont, True)
114
115 @pyqtSlot()
116 def on_fixedFontButton_clicked(self):
117 """
118 Private method used to select the fixed-width font.
119 """
120 self.fixedFont = self.selectFont(
121 self.fixedFontSample, self.fixedFont, True,
122 options=MonospacedFontsOption)
123
124
125 def create(dlg):
126 """
127 Module function to create the configuration page.
128
129 @param dlg reference to the configuration dialog
130 @return reference to the instantiated page (ConfigurationPageBase)
131 """
132 page = HelpAppearancePage()
133 return page

eric ide

mercurial