[processing] use active layer by default in field calculator algorithm

(fix #19686)
This commit is contained in:
Alexander Bruy 2019-01-22 11:04:49 +02:00
parent ee34431214
commit 95209d134c

View File

@ -41,9 +41,10 @@ from qgis.core import (Qgis,
QgsProperty,
QgsProject,
QgsMessageLog,
QgsMapLayer,
QgsProcessingOutputLayerDefinition)
from qgis.gui import QgsEncodingFileDialog, QgsGui
from qgis.utils import OverrideCursor
from qgis.utils import OverrideCursor, iface
from processing.core.ProcessingConfig import ProcessingConfig
from processing.core.ProcessingLog import ProcessingLog
@ -86,6 +87,12 @@ class FieldsCalculatorDialog(BASE, WIDGET):
self.layer = None
self.cmbInputLayer.setFilters(QgsMapLayerProxyModel.VectorLayer)
try:
if iface.activeLayer().type() == QgsMapLayer.VectorLayer:
self.cmbInputLayer.setLayer(iface.activeLayer())
except:
pass
self.cmbInputLayer.layerChanged.connect(self.updateLayer)
self.btnBrowse.clicked.connect(self.selectFile)
self.mNewFieldGroupBox.toggled.connect(self.toggleExistingGroup)