@@ -133,6 +133,8 @@ class ColorMapManager(QW.QDialog):
133
133
that the colormap cannot be removed.
134
134
"""
135
135
136
+ SIG_APPLY_COLORMAP = QC .Signal (str )
137
+
136
138
def __init__ (
137
139
self ,
138
140
parent : QW .QWidget | None = None ,
@@ -196,13 +198,16 @@ def __init__(
196
198
self ._cmap_choice .currentIndexChanged .connect (self .set_colormap )
197
199
198
200
self .bbox = QW .QDialogButtonBox (
199
- QW .QDialogButtonBox .Save
201
+ QW .QDialogButtonBox .Apply
202
+ | QW .QDialogButtonBox .Save
200
203
| QW .QDialogButtonBox .Ok
201
204
| QW .QDialogButtonBox .Cancel
202
205
)
203
206
self ._changes_saved = True
204
207
self ._save_btn = self .bbox .button (QW .QDialogButtonBox .Save )
205
208
self ._save_btn .setEnabled (False ) # type: ignore
209
+ self ._apply_btn = self .bbox .button (QW .QDialogButtonBox .Apply )
210
+ self ._apply_btn .setEnabled (False ) # type: ignore
206
211
self .bbox .clicked .connect (self .button_clicked )
207
212
208
213
dialog_layout = QW .QVBoxLayout ()
@@ -220,7 +225,12 @@ def button_clicked(self, button: QW.QAbstractButton) -> None:
220
225
Args:
221
226
button: button clicked
222
227
"""
223
- if button is self ._save_btn :
228
+ if button is self ._apply_btn :
229
+ if not self .current_changes_saved and not self .save_colormap ():
230
+ return
231
+ self ._apply_btn .setEnabled (False )
232
+ self .SIG_APPLY_COLORMAP .emit (self .colormap_editor .get_colormap ().name )
233
+ elif button is self ._save_btn :
224
234
self .save_colormap ()
225
235
elif self .bbox .buttonRole (button ) == QW .QDialogButtonBox .AcceptRole :
226
236
self .accept ()
@@ -231,6 +241,7 @@ def _changes_not_saved(self) -> None:
231
241
"""Callback function to be called when the colormap is modified. Enables the
232
242
save button and sets the current_changes_saved attribute to False."""
233
243
self ._save_btn .setEnabled (True ) # type: ignore
244
+ self ._apply_btn .setEnabled (True ) # type: ignore
234
245
self ._changes_saved = False
235
246
236
247
@property
0 commit comments