@@ -158,20 +158,33 @@ def closeEvent(self, event):
158158 msg_box .setIcon (QtWidgets .QMessageBox .Warning ) # or QMessageBox.Information, QMessageBox.Critical, etc.
159159
160160 # Set the buttons
161- msg_box .setStandardButtons (QtWidgets .QMessageBox .Yes | QtWidgets .QMessageBox .No )
162- msg_box .setDefaultButton (QtWidgets .QMessageBox .No ) # Set the default button
161+
162+ # Save Don't Save Cancel
163+ discard = "Don't Save"
164+
165+ msg_box .setStandardButtons (QtWidgets .QMessageBox .Save | QtWidgets .QMessageBox .Discard | QtWidgets .QMessageBox .Cancel )
166+ msg_box .setDefaultButton (QtWidgets .QMessageBox .Cancel ) # Set the default button
167+
168+ # Manually rename "Discard" to "Don't Save"
169+ dont_save_button = msg_box .button (QtWidgets .QMessageBox .Discard )
170+ dont_save_button .setText ("Don't Save" )
171+
163172 result = msg_box .exec_ ()
164- if result == QtWidgets .QMessageBox .Yes :
173+ pluginObjList = list (self ._openPluginDict .values ())
174+
175+ if result == QtWidgets .QMessageBox .Save or result == QtWidgets .QMessageBox .Discard :
165176 # User clicked Yes
166177 print ("User clicked Yes" )
167- # self._openPluginDict.clear() # clears dictionary and close all the plugins
168- pluginObjList = list (self ._openPluginDict .values ())
169178 for pluginObj in pluginObjList :
170179 self .closePluginInDict (pluginObj )
180+
181+ if result == QtWidgets .QMessageBox .Save :
182+ self ._stack .save ()
171183 pass # proceed to closing stackwindow
172- else :
184+
185+ elif result == QtWidgets .QMessageBox .Cancel :
173186 # User clicked No or closed the dialog so we cancel the event
174- print ("User clicked No or closed the dialog" )
187+ print ("User clicked Cancel or closed the dialog" )
175188 # prevent window from closing
176189 event .ignore ()
177190 return
0 commit comments