Preferences/ConfigurationPages/HelpAppearancePage.py

changeset 0
de9c2efb9d02
child 7
c679fb30c8f3
equal deleted inserted replaced
-1:000000000000 0:de9c2efb9d02
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2006 - 2009 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the Help Viewers configuration page.
8 """
9
10 from PyQt4.QtCore import QDir, pyqtSlot
11 from PyQt4.QtGui import QFileDialog
12
13 from E4Gui.E4Completers import E4FileCompleter
14
15 from ConfigurationPageBase import ConfigurationPageBase
16 from Ui_HelpAppearancePage import Ui_HelpAppearancePage
17
18 import Preferences
19 import Utilities
20
21 class HelpAppearancePage(ConfigurationPageBase, Ui_HelpAppearancePage):
22 """
23 Class implementing the Help Viewer Appearance page.
24 """
25 def __init__(self):
26 """
27 Constructor
28 """
29 ConfigurationPageBase.__init__(self)
30 self.setupUi(self)
31 self.setObjectName("HelpAppearancePage")
32
33 self.styleSheetCompleter = E4FileCompleter(self.styleSheetEdit)
34
35 self.helpColours = {}
36
37 # set initial values
38 self.standardFont = Preferences.getHelp("StandardFont")
39 self.standardFontSample.setFont(self.standardFont)
40 self.standardFontSample.setText("{0} {1}"\
41 .format(self.standardFont.family(),
42 self.standardFont.pointSize()))
43
44 self.fixedFont = Preferences.getHelp("FixedFont")
45 self.fixedFontSample.setFont(self.fixedFont)
46 self.fixedFontSample.setText("{0} {1}"\
47 .format(self.fixedFont.family(),
48 self.fixedFont.pointSize()))
49
50 self.helpColours["SaveUrlColor"] = \
51 self.initColour("SaveUrlColor", self.secureURLsColourButton,
52 Preferences.getHelp)
53
54 self.autoLoadImagesCheckBox.setChecked(Preferences.getHelp("AutoLoadImages"))
55
56 self.styleSheetEdit.setText(Preferences.getHelp("UserStyleSheet"))
57
58 def save(self):
59 """
60 Public slot to save the Help Viewers configuration.
61 """
62 Preferences.setHelp("StandardFont", self.standardFont)
63 Preferences.setHelp("FixedFont", self.fixedFont)
64
65 Preferences.setHelp("AutoLoadImages",
66 int(self.autoLoadImagesCheckBox.isChecked()))
67
68 Preferences.setHelp("UserStyleSheet", self.styleSheetEdit.text())
69
70 for key in self.helpColours.keys():
71 Preferences.setHelp(key, self.helpColours[key])
72
73 @pyqtSlot()
74 def on_standardFontButton_clicked(self):
75 """
76 Private method used to select the standard font.
77 """
78 self.standardFont = \
79 self.selectFont(self.standardFontSample, self.standardFont, True)
80
81 @pyqtSlot()
82 def on_fixedFontButton_clicked(self):
83 """
84 Private method used to select the fixed-width font.
85 """
86 self.fixedFont = \
87 self.selectFont(self.fixedFontSample, self.fixedFont, True)
88
89 @pyqtSlot()
90 def on_secureURLsColourButton_clicked(self):
91 """
92 Private slot to set the colour for secure URLs.
93 """
94 self.helpColours["SaveUrlColor"] = \
95 self.selectColour(self.secureURLsColourButton,
96 self.helpColours["SaveUrlColor"])
97
98 @pyqtSlot()
99 def on_styleSheetButton_clicked(self):
100 """
101 Private slot to handle the user style sheet selection.
102 """
103 file = QFileDialog.getOpenFileName(\
104 self,
105 self.trUtf8("Select Style Sheet"),
106 self.styleSheetEdit.text(),
107 "")
108
109 if file:
110 self.styleSheetEdit.setText(Utilities.toNativeSeparators(file))
111
112 def create(dlg):
113 """
114 Module function to create the configuration page.
115
116 @param dlg reference to the configuration dialog
117 """
118 page = HelpAppearancePage()
119 return page

eric ide

mercurial