Open deltamarnix opened 1 month ago
Disabling is one option, but it's difficult to implement. I would raise an error here and show a QMessageBox instead.
The reason that it's difficult to implement is because there's all kinds of ways in which people may delete the layer from the underlying geopackage. Through the "Remove from Dataset" button is one, but another is through the Browser Panel. Another is running an SQLite query through QGIS's processing toolbox, or maybe via a script in the background. This means you cannot rely on the Qt signals to inform you that the button should be re-enabled (granted, >99% of deletion would occur through "Remove from Dataset").
What easier to implement is prior to creating the layer, check the layers in the geopackage. Then error message if the name already exists. To be fair this check already occurs and you could just try-except this specific ValueError and just show this error in a QMessageBox.
Expected: The button gets disabled once a layer with that name was there.