Skip to content
Permalink
Browse files
Merge pull request #4287 from nyalldawson/processing_default_layer
[processing] Default to current layer in layer selection combos
  • Loading branch information
alexbruy committed Mar 22, 2017
2 parents 746d288 + ce7180c commit 060a57f12bc94e6c523798e694ab224ac55eb045
Showing with 19 additions and 1 deletion.
  1. +19 −1 python/plugins/processing/gui/wrappers.py
@@ -39,7 +39,8 @@
QgsMapLayerProxyModel,
QgsWkbTypes,
QgsSettings,
QgsProject
QgsProject,
QgsMapLayer
)
from qgis.PyQt.QtWidgets import (
QCheckBox,
@@ -63,6 +64,7 @@
QgsProjectionSelectionWidget,
)
from qgis.PyQt.QtCore import pyqtSignal, QObject, QVariant
from qgis.utils import iface

from processing.gui.NumberInputPanel import NumberInputPanel, ModellerNumberInputPanel
from processing.modeler.MultilineTextPanel import MultilineTextPanel
@@ -628,6 +630,11 @@ def createWidget(self):

self.combo.setFilters(QgsMapLayerProxyModel.RasterLayer)
self.combo.setExcludedProviders(['grass'])
try:
if iface.activeLayer().type() == QgsMapLayer.RasterLayer:
self.combo.setLayer(iface.activeLayer())
except:
pass

self.combo.currentIndexChanged.connect(lambda: self.widgetValueHasChanged.emit(self))
self.combo.currentTextChanged.connect(lambda: self.widgetValueHasChanged.emit(self))
@@ -755,6 +762,12 @@ def createWidget(self):
if QgsWkbTypes.PolygonGeometry in self.param.datatype:
filters |= QgsMapLayerProxyModel.PolygonLayer

try:
if iface.activeLayer().type() == QgsMapLayer.VectorLayer:
self.combo.setLayer(iface.activeLayer())
except:
pass

if self.param.optional:
self.combo.setAllowEmptyLayer(True)
if ProcessingConfig.getSetting(ProcessingConfig.SHOW_CRS_DEF):
@@ -989,6 +1002,11 @@ def createWidget(self):

self.combo.setFilters(QgsMapLayerProxyModel.VectorLayer)
self.combo.setExcludedProviders(['grass'])
try:
if iface.activeLayer().type() == QgsMapLayer.VectorLayer:
self.combo.setLayer(iface.activeLayer())
except:
pass

self.combo.currentIndexChanged.connect(lambda: self.widgetValueHasChanged.emit(self))
self.combo.currentTextChanged.connect(lambda: self.widgetValueHasChanged.emit(self))

0 comments on commit 060a57f

Please sign in to comment.