Dynamically change button text for in-place editing

The button title changes if there are selected features
This commit is contained in:
Alessandro Pasotti 2018-10-05 09:21:28 +02:00
parent ca1c65d07a
commit 0782b9d869

View File

@ -81,8 +81,10 @@ class AlgorithmDialog(QgsProcessingAlgorithmDialogBase):
self.buttonBox().addButton(self.runAsBatchButton, QDialogButtonBox.ResetRole) # reset role to ensure left alignment
else:
self.runAsBatchButton = None
self.buttonBox().button(QDialogButtonBox.Ok).setText('Modify Selected Features')
self.buttonBox().button(QDialogButtonBox.Close).setText('Cancel')
has_selection = iface.activeLayer() and (iface.activeLayer().selectedFeatureCount() > 0)
self.buttonBox().button(QDialogButtonBox.Ok).setText(QCoreApplication.translate("AlgorithmDialog", "Modify Selected Features")
if has_selection else QCoreApplication.translate("AlgorithmDialog", "Modify All Features"))
self.buttonBox().button(QDialogButtonBox.Close).setText(QCoreApplication.translate("AlgorithmDialog", "Cancel"))
def getParametersPanel(self, alg, parent):
return ParametersPanel(parent, alg, self.in_place)