--- a/src/eric7/Preferences/__init__.py Sun Jan 14 13:02:05 2024 +0100 +++ b/src/eric7/Preferences/__init__.py Tue Jan 16 14:18:52 2024 +0100 @@ -916,7 +916,7 @@ # defaults for the multi project settings multiProjectDefaults = { - "OpenMasterAutomatically": True, + "OpenMainAutomatically": True, "TimestampFile": True, "RecentNumber": 9, "Workspace": "", @@ -1407,8 +1407,8 @@ "MailServerPort": 25, "UseSystemEmailClient": False, "UseGoogleMailOAuth2": False, - "MasterPassword": "", # stores the password hash - "UseMasterPassword": False, + "MainPassword": "", # stores the password hash + "UseMainPassword": False, "SavePasswords": False, } @@ -1819,9 +1819,20 @@ Prefs.settings.setValue("Toolgroups/Current Group", currentGroup) -def initPreferences(): - """ - Module function to initialize the central configuration store. +_Migrations = { + # dictionary with old key as key and new key as value + "User/MasterPassword": "User/MainPassword", + "User/UseMasterPassword": "User/UseMainPassword", +} + + +def initPreferences(withMigration=False): + """ + Function to initialize the central configuration store. + + @param withMigration flag indicating to migrate old keys to new ones + (defaults to False) + @type bool (optional) """ from eric7.EricWidgets.EricApplication import ericApp @@ -1841,6 +1852,14 @@ Prefs.settings.value("UI/SingleApplicationMode") + if withMigration: + for oldKey in _Migrations: + if Prefs.settings.contains(oldKey): + Prefs.settings.setValue( + _Migrations[oldKey], Prefs.settings.value(oldKey) + ) + Prefs.settings.remove(oldKey) + def getSettings(): """ @@ -1904,7 +1923,7 @@ if filename: settingsFile = Prefs.settings.fileName() shutil.copy(filename, settingsFile) - initPreferences() + initPreferences(withMigration=True) def isConfigured(): @@ -3030,7 +3049,7 @@ return int( Prefs.settings.value("MultiProject/" + key, Prefs.multiProjectDefaults[key]) ) - elif key in ["OpenMasterAutomatically", "TimestampFile"]: + elif key in ["OpenMainAutomatically", "TimestampFile"]: return toBool( Prefs.settings.value("MultiProject/" + key, Prefs.multiProjectDefaults[key]) ) @@ -3483,7 +3502,7 @@ elif key in [ "MailServerAuthentication", "UseSystemEmailClient", - "UseMasterPassword", + "UseMainPassword", "SavePasswords", "UseGoogleMailOAuth2", ]: @@ -3512,7 +3531,7 @@ """ if key == "MailServerPassword": Prefs.settings.setValue("User/" + key, pwConvert(value, encode=True)) - elif key == "MasterPassword": + elif key == "MainPassword": Prefs.settings.setValue("User/" + key, hashPassword(value)) else: Prefs.settings.setValue("User/" + key, value) @@ -4329,7 +4348,7 @@ ) -initPreferences() +initPreferences(withMigration=True) initRecentSettings() ########################################################################### @@ -4337,6 +4356,7 @@ ########################################################################### +# TODO: remove the function below dealing with eric6 settings def eric6SettingsName(): """ Function to generate the settings file name for eric6.