@@ -297,7 +297,7 @@ def build_widgets(self):
297297 self .save_details_button .released .connect (self .on_save_details )
298298
299299 self .detail_buttons_layout = QtWidgets .QHBoxLayout ()
300- self .detail_buttons_layout .addStretch (streth = 1 )
300+ self .detail_buttons_layout .addStretch (1 )
301301 self .detail_buttons_layout .addWidget (self .save_details_button )
302302 self .detail_buttons_layout .addWidget (self .copy_details_button )
303303
@@ -314,7 +314,7 @@ def build_widgets(self):
314314 self .top_right_layout = QtWidgets .QVBoxLayout ()
315315 self .top_right_layout .addWidget (self .text_label )
316316 self .top_right_layout .addWidget (self .info_label )
317- self .top_right_layout .addStretch (streth = 1 )
317+ self .top_right_layout .addStretch (1 )
318318 self .top_right_layout .addLayout (self .buttons_layout )
319319 self .top_layout = QtWidgets .QHBoxLayout ()
320320 self .top_layout .addWidget (self .icon )
@@ -373,14 +373,16 @@ def show_message(cls, text, info, details=None):
373373
374374
375375class NxtConfirmDialog (QtWidgets .QMessageBox ):
376+ Ok = QtWidgets .QMessageBox .StandardButton .Ok
377+ Cancel = QtWidgets .QMessageBox .StandardButton .Cancel
376378 def __init__ (self , text = 'Title' , info = 'Confirm something!' ,
377379 button_text = None , icon = QtWidgets .QMessageBox .Icon .Question ):
378380 """Simple message box used for user confirmation
379381 :param text: Title text
380382 :param info: Main info text
381383 :param button_text: Custom button text dict:
382- {QtWidgets.QMessageBox.Ok: 'Custom Ok Text',
383- QtWidgets.QMessageBox.Cancel: 'Custom Cancel Text'}
384+ {QtWidgets.QMessageBox.StandardButton. Ok: 'Custom Ok Text',
385+ QtWidgets.QMessageBox.StandardButton. Cancel: 'Custom Cancel Text'}
384386 """
385387 super (NxtConfirmDialog , self ).__init__ ()
386388 self .setText (text )
@@ -389,6 +391,7 @@ def __init__(self, text='Title', info='Confirm something!',
389391 self .setIcon (icon )
390392 self .setWindowFlags (QtCore .Qt .WindowStaysOnTopHint )
391393 self .setStandardButtons (self .Ok | self .Cancel )
394+ self .setWindowTitle (text )
392395 if button_text :
393396 self .setButtonText (self .Ok , button_text .get (self .Ok , 'Ok' ))
394397 self .setButtonText (self .Cancel , button_text .get (self .Cancel ,
@@ -408,6 +411,31 @@ def show_message(cls, *args, **kwargs):
408411 return False
409412
410413
414+ class UpgradePrefsDialogue (NxtConfirmDialog ):
415+ def __int__ (self , title_text , info , button_text ):
416+ super (UpgradePrefsDialogue , self ).__init__ (text = title_text ,
417+ info = info ,
418+ button_text = button_text )
419+
420+ @classmethod
421+ def confirm_upgrade_if_possible (cls ):
422+
423+ if not user_dir .UPGRADABLE_PREFS :
424+ return
425+ from_version = user_dir .UPGRADE_PREFS_FROM_VERSION
426+ title_text = f'Copy version { from_version } Preferences?'
427+ button_text = {
428+ NxtConfirmDialog .Ok : f'Copy v{ from_version } prefs' ,
429+ NxtConfirmDialog .Cancel : 'Use default preferences'
430+ }
431+ i = ('Would you like to copy preferences from an older version of NXT?'
432+ '\n Some things like the window layout may not be preserved.' )
433+ do_upgrade = super ().show_message (text = title_text , info = i ,
434+ button_text = button_text )
435+ if do_upgrade :
436+ user_dir .upgrade_prefs (user_dir .UPGRADABLE_PREFS )
437+
438+
411439class UnsavedLayersDialogue (QtWidgets .QDialog ):
412440 @classmethod
413441 def save_before_exit (cls , stage_models , main_window ):
0 commit comments