|
36 | 36 | QgsApplication, |
37 | 37 | QgsSettings, |
38 | 38 | QgsProcessingParameterDefinition) |
39 | | -from qgis.gui import QgsProcessingParameterWidgetContext |
| 39 | +from qgis.gui import (QgsProcessingParameterWidgetContext, |
| 40 | + QgsProcessingContextGenerator) |
40 | 41 | from qgis.utils import iface |
41 | 42 |
|
42 | 43 | from processing.gui.wrappers import WidgetWrapperFactory, WidgetWrapper |
43 | 44 | from processing.gui.BatchOutputSelectionPanel import BatchOutputSelectionPanel |
44 | 45 |
|
45 | 46 | from processing.tools import dataobjects |
| 47 | +from processing.tools.dataobjects import createContext |
46 | 48 |
|
47 | 49 | pluginPath = os.path.split(os.path.dirname(__file__))[0] |
48 | 50 |
|
@@ -87,6 +89,19 @@ def __init__(self, parent, alg): |
87 | 89 | self.tblParameters.horizontalHeader().setDefaultSectionSize(250) |
88 | 90 | self.tblParameters.horizontalHeader().setMinimumSectionSize(150) |
89 | 91 |
|
| 92 | + self.processing_context = createContext() |
| 93 | + |
| 94 | + class ContextGenerator(QgsProcessingContextGenerator): |
| 95 | + |
| 96 | + def __init__(self, context): |
| 97 | + super().__init__() |
| 98 | + self.processing_context = context |
| 99 | + |
| 100 | + def processingContext(self): |
| 101 | + return self.processing_context |
| 102 | + |
| 103 | + self.context_generator = ContextGenerator(self.processing_context) |
| 104 | + |
90 | 105 | self.initWidgets() |
91 | 106 |
|
92 | 107 | def layerRegistryChanged(self): |
@@ -260,6 +275,7 @@ def setCellWrapper(self, row, column, wrapper, context): |
260 | 275 | widget_context.setMapCanvas(iface.mapCanvas()) |
261 | 276 | wrapper.setWidgetContext(widget_context) |
262 | 277 | widget = wrapper.createWrappedWidget(context) |
| 278 | + wrapper.registerProcessingContextGenerator(self.context_generator) |
263 | 279 | else: |
264 | 280 | widget = wrapper.widget |
265 | 281 |
|
|
0 commit comments