|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 """ |
|
4 Module implementing the Interface configuration page (variant for web browser). |
|
5 """ |
|
6 |
|
7 from PyQt4.QtCore import pyqtSlot |
|
8 from PyQt4.QtGui import QStyleFactory |
|
9 |
|
10 from E5Gui.E5Completers import E5FileCompleter |
|
11 from E5Gui import E5FileDialog |
|
12 |
|
13 from .ConfigurationPageBase import ConfigurationPageBase |
|
14 from .Ui_HelpInterfacePage import Ui_HelpInterfacePage |
|
15 |
|
16 import Preferences |
|
17 import Utilities |
|
18 |
|
19 |
|
20 class HelpInterfacePage(ConfigurationPageBase, Ui_HelpInterfacePage): |
|
21 """ |
|
22 Class implementing the Interface configuration page (variant for web browser). |
|
23 """ |
|
24 def __init__(self): |
|
25 """ |
|
26 Constructor |
|
27 """ |
|
28 super().__init__() |
|
29 self.setupUi(self) |
|
30 self.setObjectName("InterfacePage") |
|
31 |
|
32 self.styleSheetCompleter = E5FileCompleter(self.styleSheetEdit) |
|
33 |
|
34 # set initial values |
|
35 self.__populateStyleCombo() |
|
36 self.styleSheetEdit.setText(Preferences.getUI("StyleSheet")) |
|
37 |
|
38 def save(self): |
|
39 """ |
|
40 Public slot to save the Interface configuration. |
|
41 """ |
|
42 # save the style settings |
|
43 styleIndex = self.styleComboBox.currentIndex() |
|
44 style = self.styleComboBox.itemData(styleIndex) |
|
45 Preferences.setUI("Style", style) |
|
46 Preferences.setUI("StyleSheet", |
|
47 self.styleSheetEdit.text()) |
|
48 |
|
49 def __populateStyleCombo(self): |
|
50 """ |
|
51 Private method to populate the style combo box. |
|
52 """ |
|
53 curStyle = Preferences.getUI("Style") |
|
54 styles = sorted(list(QStyleFactory.keys())) |
|
55 self.styleComboBox.addItem(self.trUtf8('System'), "System") |
|
56 for style in styles: |
|
57 self.styleComboBox.addItem(style, style) |
|
58 currentIndex = self.styleComboBox.findData(curStyle) |
|
59 if currentIndex == -1: |
|
60 currentIndex = 0 |
|
61 self.styleComboBox.setCurrentIndex(currentIndex) |
|
62 |
|
63 @pyqtSlot() |
|
64 def on_styleSheetButton_clicked(self): |
|
65 """ |
|
66 Private method to select the style sheet file via a dialog. |
|
67 """ |
|
68 file = E5FileDialog.getOpenFileName( |
|
69 self, |
|
70 self.trUtf8("Select style sheet file"), |
|
71 self.styleSheetEdit.text(), |
|
72 self.trUtf8("Qt Style Sheets (*.qss);;Cascading Style Sheets (*.css);;" |
|
73 "All files (*)")) |
|
74 |
|
75 if file: |
|
76 self.styleSheetEdit.setText(Utilities.toNativeSeparators(file)) |
|
77 |
|
78 |
|
79 def create(dlg): |
|
80 """ |
|
81 Module function to create the configuration page. |
|
82 |
|
83 @param dlg reference to the configuration dialog |
|
84 """ |
|
85 page = HelpInterfacePage() |
|
86 return page |