Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Sync in-place button state
  • Loading branch information
elpaso authored and nyalldawson committed Sep 14, 2018
1 parent e75ebad commit d1ec4ac
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions python/plugins/processing/ProcessingPlugin.py
Expand Up @@ -28,6 +28,7 @@
import shutil
import os
import sys
from functools import partial

from qgis.core import (QgsApplication,
QgsProcessingUtils,
Expand Down Expand Up @@ -254,9 +255,16 @@ def initGui(self):
initializeMenus()
createMenus()

self.iface.currentLayerChanged.connect(self.layer_changed)
# In-place editing button state sync
self.iface.currentLayerChanged.connect(self.sync_in_place_button_state)
self.iface.mapCanvas().selectionChanged.connect(self.sync_in_place_button_state)
self.iface.actionToggleEditing().triggered.connect(partial(self.sync_in_place_button_state, None))
self.sync_in_place_button_state()

def layer_changed(self, layer):
def sync_in_place_button_state(self, layer=None):
"""Synchronise the button state with layer state and selection"""
if layer is None:
layer = self.iface.activeLayer()
if layer is None or layer.type() != QgsMapLayer.VectorLayer or not layer.isEditable() or not layer.selectedFeatureCount():
self.editSelectedAction.setChecked(False)
self.editSelectedAction.setEnabled(False)
Expand Down

0 comments on commit d1ec4ac

Please sign in to comment.