|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2006 - 2009 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the Help Viewers configuration page. |
|
8 """ |
|
9 |
|
10 from PyQt4.QtCore import QDir, pyqtSlot |
|
11 from PyQt4.QtGui import QButtonGroup, QFileDialog |
|
12 |
|
13 from E4Gui.E4Completers import E4FileCompleter |
|
14 |
|
15 from ConfigurationPageBase import ConfigurationPageBase |
|
16 from Ui_HelpViewersPage import Ui_HelpViewersPage |
|
17 |
|
18 import Preferences |
|
19 import Utilities |
|
20 |
|
21 class HelpViewersPage(ConfigurationPageBase, Ui_HelpViewersPage): |
|
22 """ |
|
23 Class implementing the Help Viewers configuration page. |
|
24 """ |
|
25 def __init__(self): |
|
26 """ |
|
27 Constructor |
|
28 """ |
|
29 ConfigurationPageBase.__init__(self) |
|
30 self.setupUi(self) |
|
31 self.setObjectName("HelpViewersPage") |
|
32 |
|
33 self.helpViewerGroup = QButtonGroup() |
|
34 self.helpViewerGroup.addButton(self.helpBrowserButton) |
|
35 self.helpViewerGroup.addButton(self.qtAssistantButton) |
|
36 self.helpViewerGroup.addButton(self.webBrowserButton) |
|
37 self.helpViewerGroup.addButton(self.customViewerButton) |
|
38 |
|
39 self.customViewerCompleter = E4FileCompleter(self.customViewerEdit) |
|
40 |
|
41 # set initial values |
|
42 hvId = Preferences.getHelp("HelpViewerType") |
|
43 if hvId == 1: |
|
44 self.helpBrowserButton.setChecked(True) |
|
45 elif hvId == 2: |
|
46 self.qtAssistantButton.setChecked(True) |
|
47 elif hvId == 3: |
|
48 self.webBrowserButton.setChecked(True) |
|
49 else: |
|
50 self.customViewerButton.setChecked(True) |
|
51 self.customViewerEdit.setText(\ |
|
52 Preferences.getHelp("CustomViewer")) |
|
53 |
|
54 def save(self): |
|
55 """ |
|
56 Public slot to save the Help Viewers configuration. |
|
57 """ |
|
58 if self.helpBrowserButton.isChecked(): |
|
59 hvId = 1 |
|
60 elif self.qtAssistantButton.isChecked(): |
|
61 hvId = 2 |
|
62 elif self.webBrowserButton.isChecked(): |
|
63 hvId = 3 |
|
64 elif self.customViewerButton.isChecked(): |
|
65 hvId = 4 |
|
66 Preferences.setHelp("HelpViewerType", hvId) |
|
67 Preferences.setHelp("CustomViewer", |
|
68 self.customViewerEdit.text()) |
|
69 |
|
70 @pyqtSlot() |
|
71 def on_customViewerSelectionButton_clicked(self): |
|
72 """ |
|
73 Private slot to handle the custom viewer selection. |
|
74 """ |
|
75 file = QFileDialog.getOpenFileName(\ |
|
76 self, |
|
77 self.trUtf8("Select Custom Viewer"), |
|
78 self.customViewerEdit.text(), |
|
79 "") |
|
80 |
|
81 if file: |
|
82 self.customViewerEdit.setText(Utilities.toNativeSeparators(file)) |
|
83 |
|
84 @pyqtSlot() |
|
85 def on_webbrowserButton_clicked(self): |
|
86 """ |
|
87 Private slot to handle the Web browser selection. |
|
88 """ |
|
89 file = QFileDialog.getOpenFileName(\ |
|
90 self, |
|
91 self.trUtf8("Select Web-Browser"), |
|
92 self.webbrowserEdit.text(), |
|
93 "") |
|
94 |
|
95 if file: |
|
96 self.webbrowserEdit.setText(Utilities.toNativeSeparators(file)) |
|
97 |
|
98 @pyqtSlot() |
|
99 def on_pdfviewerButton_clicked(self): |
|
100 """ |
|
101 Private slot to handle the PDF viewer selection. |
|
102 """ |
|
103 file = QFileDialog.getOpenFileName(\ |
|
104 self, |
|
105 self.trUtf8("Select PDF-Viewer"), |
|
106 self.pdfviewerEdit.text(), |
|
107 "") |
|
108 |
|
109 if file: |
|
110 self.pdfviewerEdit.setText(Utilities.toNativeSeparators(file)) |
|
111 |
|
112 @pyqtSlot() |
|
113 def on_chmviewerButton_clicked(self): |
|
114 """ |
|
115 Private slot to handle the CHM viewer selection. |
|
116 """ |
|
117 file = QFileDialog.getOpenFileName(\ |
|
118 self, |
|
119 self.trUtf8("Select CHM-Viewer"), |
|
120 self.chmviewerEdit.text(), |
|
121 "") |
|
122 |
|
123 if file: |
|
124 self.chmviewerEdit.setText(Utilities.toNativeSeparators(file)) |
|
125 |
|
126 def create(dlg): |
|
127 """ |
|
128 Module function to create the configuration page. |
|
129 |
|
130 @param dlg reference to the configuration dialog |
|
131 """ |
|
132 page = HelpViewersPage() |
|
133 return page |