7 Module implementing the Interface configuration page (variant for web browser). |
7 Module implementing the Interface configuration page (variant for web browser). |
8 """ |
8 """ |
9 |
9 |
10 from __future__ import unicode_literals |
10 from __future__ import unicode_literals |
11 |
11 |
12 from PyQt5.QtCore import pyqtSlot |
|
13 from PyQt5.QtWidgets import QStyleFactory |
12 from PyQt5.QtWidgets import QStyleFactory |
14 |
13 |
15 from E5Gui.E5Completers import E5FileCompleter |
14 from E5Gui.E5PathPicker import E5PathPickerModes |
16 from E5Gui import E5FileDialog |
|
17 |
15 |
18 from .ConfigurationPageBase import ConfigurationPageBase |
16 from .ConfigurationPageBase import ConfigurationPageBase |
19 from .Ui_HelpInterfacePage import Ui_HelpInterfacePage |
17 from .Ui_HelpInterfacePage import Ui_HelpInterfacePage |
20 |
18 |
21 import Preferences |
19 import Preferences |
22 import Utilities |
|
23 import UI.PixmapCache |
|
24 |
20 |
25 |
21 |
26 class HelpInterfacePage(ConfigurationPageBase, Ui_HelpInterfacePage): |
22 class HelpInterfacePage(ConfigurationPageBase, Ui_HelpInterfacePage): |
27 """ |
23 """ |
28 Class implementing the Interface configuration page (variant for web |
24 Class implementing the Interface configuration page (variant for web |
34 """ |
30 """ |
35 super(HelpInterfacePage, self).__init__() |
31 super(HelpInterfacePage, self).__init__() |
36 self.setupUi(self) |
32 self.setupUi(self) |
37 self.setObjectName("InterfacePage") |
33 self.setObjectName("InterfacePage") |
38 |
34 |
39 self.styleSheetButton.setIcon(UI.PixmapCache.getIcon("open.png")) |
35 self.styleSheetPicker.setMode(E5PathPickerModes.OpenFileMode) |
40 |
36 self.styleSheetPicker.setFilters(self.tr( |
41 self.styleSheetCompleter = E5FileCompleter(self.styleSheetEdit) |
37 "Qt Style Sheets (*.qss);;Cascading Style Sheets (*.css);;" |
|
38 "All files (*)")) |
42 |
39 |
43 # set initial values |
40 # set initial values |
44 self.__populateStyleCombo() |
41 self.__populateStyleCombo() |
45 self.styleSheetEdit.setText(Preferences.getUI("StyleSheet")) |
42 self.styleSheetPicker.setText(Preferences.getUI("StyleSheet")) |
46 |
43 |
47 def save(self): |
44 def save(self): |
48 """ |
45 """ |
49 Public slot to save the Interface configuration. |
46 Public slot to save the Interface configuration. |
50 """ |
47 """ |
52 styleIndex = self.styleComboBox.currentIndex() |
49 styleIndex = self.styleComboBox.currentIndex() |
53 style = self.styleComboBox.itemData(styleIndex) |
50 style = self.styleComboBox.itemData(styleIndex) |
54 Preferences.setUI("Style", style) |
51 Preferences.setUI("Style", style) |
55 Preferences.setUI( |
52 Preferences.setUI( |
56 "StyleSheet", |
53 "StyleSheet", |
57 self.styleSheetEdit.text()) |
54 self.styleSheetPicker.text()) |
58 |
55 |
59 def __populateStyleCombo(self): |
56 def __populateStyleCombo(self): |
60 """ |
57 """ |
61 Private method to populate the style combo box. |
58 Private method to populate the style combo box. |
62 """ |
59 """ |
67 self.styleComboBox.addItem(style, style) |
64 self.styleComboBox.addItem(style, style) |
68 currentIndex = self.styleComboBox.findData(curStyle) |
65 currentIndex = self.styleComboBox.findData(curStyle) |
69 if currentIndex == -1: |
66 if currentIndex == -1: |
70 currentIndex = 0 |
67 currentIndex = 0 |
71 self.styleComboBox.setCurrentIndex(currentIndex) |
68 self.styleComboBox.setCurrentIndex(currentIndex) |
72 |
|
73 @pyqtSlot() |
|
74 def on_styleSheetButton_clicked(self): |
|
75 """ |
|
76 Private method to select the style sheet file via a dialog. |
|
77 """ |
|
78 file = E5FileDialog.getOpenFileName( |
|
79 self, |
|
80 self.tr("Select style sheet file"), |
|
81 self.styleSheetEdit.text(), |
|
82 self.tr( |
|
83 "Qt Style Sheets (*.qss);;Cascading Style Sheets (*.css);;" |
|
84 "All files (*)")) |
|
85 |
|
86 if file: |
|
87 self.styleSheetEdit.setText(Utilities.toNativeSeparators(file)) |
|
88 |
69 |
89 |
70 |
90 def create(dlg): |
71 def create(dlg): |
91 """ |
72 """ |
92 Module function to create the configuration page. |
73 Module function to create the configuration page. |