Skip to content
Permalink
Browse files

[processing] simplify modeler algorithm dialog and use new help in it

too
  • Loading branch information
alexbruy committed Jun 6, 2017
1 parent a137a7c commit ffac4f964838726a1a10f88c2a6a817b865117a0
Showing with 14 additions and 38 deletions.
  1. +14 −38 python/plugins/processing/modeler/ModelerParametersDialog.py
@@ -27,15 +27,14 @@

__revision__ = '$Format:%H$'

import webbrowser

from qgis.PyQt.QtCore import Qt, QUrl, QMetaObject
from qgis.PyQt.QtWidgets import (QDialog, QDialogButtonBox, QLabel, QLineEdit,
QFrame, QPushButton, QSizePolicy, QVBoxLayout,
QHBoxLayout, QTabWidget, QWidget,
QTextBrowser)
from qgis.PyQt.QtNetwork import QNetworkRequest, QNetworkReply
QHBoxLayout, QWidget)

from qgis.core import (QgsNetworkAccessManager,
QgsProcessingParameterDefinition)
from qgis.core import (QgsProcessingParameterDefinition)

from qgis.gui import (QgsMessageBar,
QgsScrollArea)
@@ -89,7 +88,8 @@ def setupUi(self):
self.buttonBox = QDialogButtonBox()
self.buttonBox.setOrientation(Qt.Horizontal)
self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel |
QDialogButtonBox.Ok)
+ QDialogButtonBox.Ok |
+ QDialogButtonBox.Help)
self.setSizePolicy(QSizePolicy.Expanding,
QSizePolicy.Expanding)
self.verticalLayout = QVBoxLayout()
@@ -182,53 +182,24 @@ def setupUi(self):
self.verticalLayout2 = QVBoxLayout()
self.verticalLayout2.setSpacing(2)
self.verticalLayout2.setMargin(0)
self.tabWidget = QTabWidget()
self.tabWidget.setMinimumWidth(300)

self.paramPanel = QWidget()
self.paramPanel.setLayout(self.verticalLayout)
self.scrollArea = QgsScrollArea()
self.scrollArea.setWidget(self.paramPanel)
self.scrollArea.setWidgetResizable(True)
self.tabWidget.addTab(self.scrollArea, self.tr('Parameters'))

self.txtHelp = QTextBrowser()

html = None
isText, algHelp = self._alg.help()
if algHelp is not None:
algHelp = algHelp if isText else QUrl(algHelp)
try:
if isText:
self.txtHelp.setHtml(algHelp)
else:
html = self.tr('<p>Downloading algorithm help... Please wait.</p>')
self.txtHelp.setHtml(html)
self.tabWidget.addTab(self.txtHelp, 'Help')
self.reply = QgsNetworkAccessManager.instance().get(QNetworkRequest(algHelp))
self.reply.finished.connect(self.requestFinished)
except:
pass

self.verticalLayout2.addWidget(self.tabWidget)
self.verticalLayout2.addWidget(self.scrollArea)
self.verticalLayout2.addWidget(self.buttonBox)
self.setLayout(self.verticalLayout2)
self.buttonBox.accepted.connect(self.okPressed)
self.buttonBox.rejected.connect(self.cancelPressed)
self.buttonBox.helpRequested.connect(self.openHelp)
QMetaObject.connectSlotsByName(self)

for wrapper in list(self.wrappers.values()):
wrapper.postInitialize(list(self.wrappers.values()))

def requestFinished(self):
"""Change the webview HTML content"""
reply = self.sender()
if reply.error() != QNetworkReply.NoError:
html = self.tr('<h2>No help available for this algorithm</h2><p>{}</p>'.format(reply.errorString()))
else:
html = str(reply.readAll())
reply.deleteLater()
self.txtHelp.setHtml(html)

def getAvailableDependencies(self): # spellok
if self._algName is None:
dependent = []
@@ -353,3 +324,8 @@ def okPressed(self):
def cancelPressed(self):
self.alg = None
self.close()

def openHelp(self):
algHelp = self._alg.help()
if algHelp is not None:
webbrowser.open(algHelp)

0 comments on commit ffac4f9

Please sign in to comment.
You can’t perform that action at this time.