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