@@ -171,14 +171,13 @@ def __init__(
171171 self .colormap_editor = ColorMapEditor (
172172 self , colormap = deepcopy (self ._cmap_choice .currentData ())
173173 )
174- edit_gbox = QW .QGroupBox (_ ("Edit the selected colormap" ))
174+ self . _edit_gbox = QW .QGroupBox (_ ("Edit the selected colormap" ))
175175 edit_gbox_layout = QW .QVBoxLayout ()
176176 edit_gbox_layout .setContentsMargins (0 , 0 , 0 , 0 )
177177 edit_gbox_layout .addWidget (self .colormap_editor )
178- edit_gbox .setLayout (edit_gbox_layout )
179- edit_gbox .setCheckable (True )
180- edit_gbox .setChecked (False )
181- add_btn .clicked .connect (lambda : edit_gbox .setChecked (True ))
178+ self ._edit_gbox .setLayout (edit_gbox_layout )
179+ self ._edit_gbox .setCheckable (True )
180+ self ._edit_gbox .setChecked (False )
182181 self .colormap_editor .colormap_widget .COLORMAP_CHANGED .connect (
183182 self ._changes_not_saved
184183 )
@@ -197,7 +196,7 @@ def __init__(
197196
198197 dialog_layout = QW .QVBoxLayout ()
199198 dialog_layout .addWidget (select_gbox )
200- dialog_layout .addWidget (edit_gbox )
199+ dialog_layout .addWidget (self . _edit_gbox )
201200 dialog_layout .addWidget (self .bbox )
202201 self .setLayout (dialog_layout )
203202
@@ -307,7 +306,11 @@ def __get_new_colormap_name(self, title: str, name: str) -> str | None:
307306 def add_colormap (self ) -> None :
308307 """Create a new colormap and set it as the current colormap."""
309308 cmap = EditableColormap (QG .QColor (0 ), QG .QColor (4294967295 ), name = _ ("New" ))
310- self .save_colormap (cmap )
309+ if self .save_colormap (cmap ):
310+ # If the colormap save dialog was accepted, then we enable the colormap
311+ # editor group box.
312+ # Otherwise, we leave the colormap editor group box at its current state.
313+ self ._edit_gbox .setChecked (True )
311314
312315 def remove_colormap (self ) -> None :
313316 """Remove the current colormap."""
0 commit comments