Skip to content
Permalink
Browse files

[processing] Add a setParameters method to AlgorithmDialog

Allows pre-populating the dialog with non-default parameter
values.
  • Loading branch information
nyalldawson committed Dec 21, 2017
1 parent 595b981 commit edcd058e3235acf6e8a06d1a8c81645efe8afa7f
@@ -80,6 +80,9 @@ def runAsBatch(self):
dlg.show()
dlg.exec_()

def setParameters(self, parameters):
self.mainWidget().setParameters(parameters)

def getParameterValues(self):
parameters = {}

@@ -266,6 +266,12 @@ def selectDirectory(self):
self.leText.setText(QDir.toNativeSeparators(dirName))
settings.setValue('/Processing/LastOutputPath', dirName)

def setValue(self, value):
if value == 'memory:':
self.saveToTemporary()
else:
self.leText.setText(value)

def getValue(self):
key = None
if self.use_temporary and isinstance(self.parameter, QgsProcessingParameterFeatureSink):
@@ -181,6 +181,21 @@ def initWidgets(self):
for wrapper in list(self.wrappers.values()):
wrapper.postInitialize(list(self.wrappers.values()))

def setParameters(self, parameters):
for param in self.alg.parameterDefinitions():
if param.flags() & QgsProcessingParameterDefinition.FlagHidden:
continue

if not param.name() in parameters:
continue

if not param.isDestination():
wrapper = self.wrappers[param.name()]
wrapper.setValue(parameters[param.name()])
else:
dest_widget = self.outputWidgets[param.name()]
dest_widget.setValue(parameters[param.name()])

def buttonToggled(self, value):
if value:
sender = self.sender()

0 comments on commit edcd058

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