Preferences/ConfigurationPages/HelpViewersPage.py

changeset 4577
e79a139aacc4
parent 4021
195a471c327b
child 4619
aa2319888257
equal deleted inserted replaced
4576:a258569d44db 4577:e79a139aacc4
7 Module implementing the Help Viewers configuration page. 7 Module implementing the Help Viewers configuration page.
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 QButtonGroup 12 from PyQt5.QtWidgets import QButtonGroup
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_HelpViewersPage import Ui_HelpViewersPage 17 from .Ui_HelpViewersPage import Ui_HelpViewersPage
20 18
21 import Preferences 19 import Preferences
22 import Utilities
23 import UI.PixmapCache
24 20
25 21
26 class HelpViewersPage(ConfigurationPageBase, Ui_HelpViewersPage): 22 class HelpViewersPage(ConfigurationPageBase, Ui_HelpViewersPage):
27 """ 23 """
28 Class implementing the Help Viewers configuration page. 24 Class implementing the Help Viewers configuration page.
33 """ 29 """
34 super(HelpViewersPage, self).__init__() 30 super(HelpViewersPage, self).__init__()
35 self.setupUi(self) 31 self.setupUi(self)
36 self.setObjectName("HelpViewersPage") 32 self.setObjectName("HelpViewersPage")
37 33
38 self.customViewerSelectionButton.setIcon( 34 self.customViewerPicker.setMode(E5PathPickerModes.OpenFileMode)
39 UI.PixmapCache.getIcon("open.png"))
40 35
41 self.helpViewerGroup = QButtonGroup() 36 self.helpViewerGroup = QButtonGroup()
42 self.helpViewerGroup.addButton(self.helpBrowserButton) 37 self.helpViewerGroup.addButton(self.helpBrowserButton)
43 self.helpViewerGroup.addButton(self.qtAssistantButton) 38 self.helpViewerGroup.addButton(self.qtAssistantButton)
44 self.helpViewerGroup.addButton(self.webBrowserButton) 39 self.helpViewerGroup.addButton(self.webBrowserButton)
45 self.helpViewerGroup.addButton(self.customViewerButton) 40 self.helpViewerGroup.addButton(self.customViewerButton)
46
47 self.customViewerCompleter = E5FileCompleter(self.customViewerEdit)
48 41
49 # set initial values 42 # set initial values
50 hvId = Preferences.getHelp("HelpViewerType") 43 hvId = Preferences.getHelp("HelpViewerType")
51 if hvId == 1: 44 if hvId == 1:
52 self.helpBrowserButton.setChecked(True) 45 self.helpBrowserButton.setChecked(True)
54 self.qtAssistantButton.setChecked(True) 47 self.qtAssistantButton.setChecked(True)
55 elif hvId == 3: 48 elif hvId == 3:
56 self.webBrowserButton.setChecked(True) 49 self.webBrowserButton.setChecked(True)
57 else: 50 else:
58 self.customViewerButton.setChecked(True) 51 self.customViewerButton.setChecked(True)
59 self.customViewerEdit.setText( 52 self.customViewerPicker.setText(
60 Preferences.getHelp("CustomViewer")) 53 Preferences.getHelp("CustomViewer"))
61 54
62 def save(self): 55 def save(self):
63 """ 56 """
64 Public slot to save the Help Viewers configuration. 57 Public slot to save the Help Viewers configuration.
72 elif self.customViewerButton.isChecked(): 65 elif self.customViewerButton.isChecked():
73 hvId = 4 66 hvId = 4
74 Preferences.setHelp("HelpViewerType", hvId) 67 Preferences.setHelp("HelpViewerType", hvId)
75 Preferences.setHelp( 68 Preferences.setHelp(
76 "CustomViewer", 69 "CustomViewer",
77 self.customViewerEdit.text()) 70 self.customViewerPicker.text())
78
79 @pyqtSlot()
80 def on_customViewerSelectionButton_clicked(self):
81 """
82 Private slot to handle the custom viewer selection.
83 """
84 file = E5FileDialog.getOpenFileName(
85 self,
86 self.tr("Select Custom Viewer"),
87 self.customViewerEdit.text(),
88 "")
89
90 if file:
91 self.customViewerEdit.setText(Utilities.toNativeSeparators(file))
92
93 @pyqtSlot()
94 def on_webbrowserButton_clicked(self):
95 """
96 Private slot to handle the Web browser selection.
97 """
98 file = E5FileDialog.getOpenFileName(
99 self,
100 self.tr("Select Web-Browser"),
101 self.webbrowserEdit.text(),
102 "")
103
104 if file:
105 self.webbrowserEdit.setText(Utilities.toNativeSeparators(file))
106
107 @pyqtSlot()
108 def on_pdfviewerButton_clicked(self):
109 """
110 Private slot to handle the PDF viewer selection.
111 """
112 file = E5FileDialog.getOpenFileName(
113 self,
114 self.tr("Select PDF-Viewer"),
115 self.pdfviewerEdit.text(),
116 "")
117
118 if file:
119 self.pdfviewerEdit.setText(Utilities.toNativeSeparators(file))
120
121 @pyqtSlot()
122 def on_chmviewerButton_clicked(self):
123 """
124 Private slot to handle the CHM viewer selection.
125 """
126 file = E5FileDialog.getOpenFileName(
127 self,
128 self.tr("Select CHM-Viewer"),
129 self.chmviewerEdit.text(),
130 "")
131
132 if file:
133 self.chmviewerEdit.setText(Utilities.toNativeSeparators(file))
134 71
135 72
136 def create(dlg): 73 def create(dlg):
137 """ 74 """
138 Module function to create the configuration page. 75 Module function to create the configuration page.

eric ide

mercurial