QGIS – ‘Save for All Layers’ Signal Functionality in QGIS

pyqgisqgis

Is there a way in PyQGIS (QGIS Plugin) to know when the user does 'Save for All Layers'?

In the documentation for QgisInterface I could not find this signal. But I really need to run a function after the user alters the data in the PostgreSQL tables (the layer source).

Best Answer

You can use iface.actionSaveAllEdits().triggered signal as below. run method runs after "Current edits" window is closed. It doesn't matter if the user chooses Yes or No.

def run():
    print("'Save for All Layers' was clicked")
    
iface.actionSaveAllEdits().triggered.connect(run)

But As Germán Carrillo mentioned, users could still cancel edits.

Related Question