|
27 | 27 |
|
28 | 28 | __revision__ = '$Format:%H$' |
29 | 29 |
|
| 30 | +import webbrowser |
| 31 | + |
30 | 32 | from qgis.PyQt.QtCore import Qt, QUrl, QMetaObject |
31 | 33 | from qgis.PyQt.QtWidgets import (QDialog, QDialogButtonBox, QLabel, QLineEdit, |
32 | 34 | QFrame, QPushButton, QSizePolicy, QVBoxLayout, |
33 | | - QHBoxLayout, QTabWidget, QWidget, |
34 | | - QTextBrowser) |
35 | | -from qgis.PyQt.QtNetwork import QNetworkRequest, QNetworkReply |
| 35 | + QHBoxLayout, QWidget) |
36 | 36 |
|
37 | | -from qgis.core import (QgsNetworkAccessManager, |
38 | | - QgsProcessingParameterDefinition) |
| 37 | +from qgis.core import (QgsProcessingParameterDefinition) |
39 | 38 |
|
40 | 39 | from qgis.gui import (QgsMessageBar, |
41 | 40 | QgsScrollArea) |
@@ -89,7 +88,8 @@ def setupUi(self): |
89 | 88 | self.buttonBox = QDialogButtonBox() |
90 | 89 | self.buttonBox.setOrientation(Qt.Horizontal) |
91 | 90 | self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel | |
92 | | - QDialogButtonBox.Ok) |
| 91 | + + QDialogButtonBox.Ok | |
| 92 | + + QDialogButtonBox.Help) |
93 | 93 | self.setSizePolicy(QSizePolicy.Expanding, |
94 | 94 | QSizePolicy.Expanding) |
95 | 95 | self.verticalLayout = QVBoxLayout() |
@@ -182,53 +182,24 @@ def setupUi(self): |
182 | 182 | self.verticalLayout2 = QVBoxLayout() |
183 | 183 | self.verticalLayout2.setSpacing(2) |
184 | 184 | self.verticalLayout2.setMargin(0) |
185 | | - self.tabWidget = QTabWidget() |
186 | | - self.tabWidget.setMinimumWidth(300) |
| 185 | + |
187 | 186 | self.paramPanel = QWidget() |
188 | 187 | self.paramPanel.setLayout(self.verticalLayout) |
189 | 188 | self.scrollArea = QgsScrollArea() |
190 | 189 | self.scrollArea.setWidget(self.paramPanel) |
191 | 190 | self.scrollArea.setWidgetResizable(True) |
192 | | - self.tabWidget.addTab(self.scrollArea, self.tr('Parameters')) |
193 | | - |
194 | | - self.txtHelp = QTextBrowser() |
195 | 191 |
|
196 | | - html = None |
197 | | - isText, algHelp = self._alg.help() |
198 | | - if algHelp is not None: |
199 | | - algHelp = algHelp if isText else QUrl(algHelp) |
200 | | - try: |
201 | | - if isText: |
202 | | - self.txtHelp.setHtml(algHelp) |
203 | | - else: |
204 | | - html = self.tr('<p>Downloading algorithm help... Please wait.</p>') |
205 | | - self.txtHelp.setHtml(html) |
206 | | - self.tabWidget.addTab(self.txtHelp, 'Help') |
207 | | - self.reply = QgsNetworkAccessManager.instance().get(QNetworkRequest(algHelp)) |
208 | | - self.reply.finished.connect(self.requestFinished) |
209 | | - except: |
210 | | - pass |
211 | | - |
212 | | - self.verticalLayout2.addWidget(self.tabWidget) |
| 192 | + self.verticalLayout2.addWidget(self.scrollArea) |
213 | 193 | self.verticalLayout2.addWidget(self.buttonBox) |
214 | 194 | self.setLayout(self.verticalLayout2) |
215 | 195 | self.buttonBox.accepted.connect(self.okPressed) |
216 | 196 | self.buttonBox.rejected.connect(self.cancelPressed) |
| 197 | + self.buttonBox.helpRequested.connect(self.openHelp) |
217 | 198 | QMetaObject.connectSlotsByName(self) |
218 | 199 |
|
219 | 200 | for wrapper in list(self.wrappers.values()): |
220 | 201 | wrapper.postInitialize(list(self.wrappers.values())) |
221 | 202 |
|
222 | | - def requestFinished(self): |
223 | | - """Change the webview HTML content""" |
224 | | - reply = self.sender() |
225 | | - if reply.error() != QNetworkReply.NoError: |
226 | | - html = self.tr('<h2>No help available for this algorithm</h2><p>{}</p>'.format(reply.errorString())) |
227 | | - else: |
228 | | - html = str(reply.readAll()) |
229 | | - reply.deleteLater() |
230 | | - self.txtHelp.setHtml(html) |
231 | | - |
232 | 203 | def getAvailableDependencies(self): # spellok |
233 | 204 | if self._algName is None: |
234 | 205 | dependent = [] |
@@ -353,3 +324,8 @@ def okPressed(self): |
353 | 324 | def cancelPressed(self): |
354 | 325 | self.alg = None |
355 | 326 | self.close() |
| 327 | + |
| 328 | + def openHelp(self): |
| 329 | + algHelp = self._alg.help() |
| 330 | + if algHelp is not None: |
| 331 | + webbrowser.open(algHelp) |
0 commit comments