eric6/Preferences/ConfigurationPages/WebBrowserInterfacePage.py

changeset 7433
386487a96672
child 7639
422fd05e9c91
equal deleted inserted replaced
7432:f5488e9ab8c6 7433:386487a96672
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2006 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the Interface configuration page (variant for web browser).
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.QtWidgets import QStyleFactory
13
14 from E5Gui.E5PathPicker import E5PathPickerModes
15
16 from .ConfigurationPageBase import ConfigurationPageBase
17 from .Ui_WebBrowserInterfacePage import Ui_WebBrowserInterfacePage
18
19 import Preferences
20
21
22 class WebBrowserInterfacePage(ConfigurationPageBase,
23 Ui_WebBrowserInterfacePage):
24 """
25 Class implementing the Interface configuration page (variant for web
26 browser).
27 """
28 def __init__(self):
29 """
30 Constructor
31 """
32 super(WebBrowserInterfacePage, self).__init__()
33 self.setupUi(self)
34 self.setObjectName("InterfacePage")
35
36 self.styleSheetPicker.setMode(E5PathPickerModes.OpenFileMode)
37 self.styleSheetPicker.setFilters(self.tr(
38 "Qt Style Sheets (*.qss);;Cascading Style Sheets (*.css);;"
39 "All files (*)"))
40
41 # set initial values
42 self.__populateStyleCombo()
43 self.styleSheetPicker.setText(Preferences.getUI("StyleSheet"))
44
45 def save(self):
46 """
47 Public slot to save the Interface configuration.
48 """
49 # save the style settings
50 styleIndex = self.styleComboBox.currentIndex()
51 style = self.styleComboBox.itemData(styleIndex)
52 Preferences.setUI("Style", style)
53 Preferences.setUI(
54 "StyleSheet",
55 self.styleSheetPicker.text())
56
57 def __populateStyleCombo(self):
58 """
59 Private method to populate the style combo box.
60 """
61 curStyle = Preferences.getUI("Style")
62 styles = sorted(list(QStyleFactory.keys()))
63 self.styleComboBox.addItem(self.tr('System'), "System")
64 for style in styles:
65 self.styleComboBox.addItem(style, style)
66 currentIndex = self.styleComboBox.findData(curStyle)
67 if currentIndex == -1:
68 currentIndex = 0
69 self.styleComboBox.setCurrentIndex(currentIndex)
70
71
72 def create(dlg):
73 """
74 Module function to create the configuration page.
75
76 @param dlg reference to the configuration dialog
77 @return reference to the instantiated page (ConfigurationPageBase)
78 """
79 page = WebBrowserInterfacePage()
80 return page

eric ide

mercurial