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