src/eric7/Preferences/__init__.py

branch
eric7
changeset 9482
a2bc06a54d9d
parent 9473
3f23dbf37dbe
child 9498
d48061567354
equal deleted inserted replaced
9481:0b936ff1bbb9 9482:a2bc06a54d9d
47 QWebEngineSettings = None 47 QWebEngineSettings = None
48 48
49 from eric7 import Globals 49 from eric7 import Globals
50 from eric7.EricNetwork.EricFtp import EricFtpProxyType 50 from eric7.EricNetwork.EricFtp import EricFtpProxyType
51 from eric7.EricWidgets import EricFileDialog 51 from eric7.EricWidgets import EricFileDialog
52 from eric7.EricWidgets.EricApplication import ericApp
52 from eric7.EricWidgets.EricIconBar import EricIconBar 53 from eric7.EricWidgets.EricIconBar import EricIconBar
53 from eric7.Project.ProjectBrowserFlags import ( 54 from eric7.Project.ProjectBrowserFlags import (
54 AllBrowsersFlag, 55 AllBrowsersFlag,
55 FormsBrowserFlag, 56 FormsBrowserFlag,
56 InterfacesBrowserFlag, 57 InterfacesBrowserFlag,
59 ResourcesBrowserFlag, 60 ResourcesBrowserFlag,
60 SourcesBrowserFlag, 61 SourcesBrowserFlag,
61 TranslationsBrowserFlag, 62 TranslationsBrowserFlag,
62 ) 63 )
63 from eric7.QScintilla.Shell import ShellHistoryStyle 64 from eric7.QScintilla.Shell import ShellHistoryStyle
65 from eric7.Utilities.crypto import pwConvert
66 from eric7.Utilities.crypto.py3PBKDF2 import hashPassword
64 67
65 68
66 class Prefs: 69 class Prefs:
67 """ 70 """
68 A class to hold all configuration items for the application. 71 A class to hold all configuration items for the application.
1789 venvName = Prefs.settings.value( 1792 venvName = Prefs.settings.value(
1790 "Debugger/" + newKey, Prefs.debuggerDefaults[newKey] 1793 "Debugger/" + newKey, Prefs.debuggerDefaults[newKey]
1791 ) 1794 )
1792 if venvName: 1795 if venvName:
1793 try: 1796 try:
1794 from eric7.EricWidgets.EricApplication import ericApp
1795
1796 virtualenvManager = ericApp().getObject("VirtualEnvManager") 1797 virtualenvManager = ericApp().getObject("VirtualEnvManager")
1797 except KeyError: 1798 except KeyError:
1798 from eric7.VirtualEnv.VirtualenvManager import VirtualenvManager 1799 from eric7.VirtualEnv.VirtualenvManager import ( # __IGNORE_WARNING__
1800 VirtualenvManager,
1801 )
1799 1802
1800 virtualenvManager = VirtualenvManager() 1803 virtualenvManager = VirtualenvManager()
1801 interpreter = virtualenvManager.getVirtualenvInterpreter(venvName) 1804 interpreter = virtualenvManager.getVirtualenvInterpreter(venvName)
1802 else: 1805 else:
1803 interpreter = "" 1806 interpreter = ""
2004 elif key in [ 2007 elif key in [
2005 "ProxyPassword/Http", 2008 "ProxyPassword/Http",
2006 "ProxyPassword/Https", 2009 "ProxyPassword/Https",
2007 "ProxyPassword/Ftp", 2010 "ProxyPassword/Ftp",
2008 ]: 2011 ]:
2009 from eric7.Utilities.crypto import pwConvert
2010
2011 return pwConvert( 2012 return pwConvert(
2012 Prefs.settings.value("UI/" + key, Prefs.uiDefaults[key]), encode=False 2013 Prefs.settings.value("UI/" + key, Prefs.uiDefaults[key]), encode=False
2013 ) 2014 )
2014 elif key in ("LogStdErrColour", "IconBarColor"): 2015 elif key in ("LogStdErrColour", "IconBarColor"):
2015 col = Prefs.settings.value("UI/" + key) 2016 col = Prefs.settings.value("UI/" + key)
2082 elif key in [ 2083 elif key in [
2083 "ProxyPassword/Http", 2084 "ProxyPassword/Http",
2084 "ProxyPassword/Https", 2085 "ProxyPassword/Https",
2085 "ProxyPassword/Ftp", 2086 "ProxyPassword/Ftp",
2086 ]: 2087 ]:
2087 from eric7.Utilities.crypto import pwConvert
2088
2089 Prefs.settings.setValue("UI/" + key, pwConvert(value, encode=True)) 2088 Prefs.settings.setValue("UI/" + key, pwConvert(value, encode=True))
2090 elif key in [ 2089 elif key in [
2091 "ProxyType/Ftp", 2090 "ProxyType/Ftp",
2092 ]: 2091 ]:
2093 # value is an enum.Enum derived item 2092 # value is an enum.Enum derived item
2393 Module function to retrieve all lexer associations. 2392 Module function to retrieve all lexer associations.
2394 2393
2395 @return a reference to the list of lexer associations 2394 @return a reference to the list of lexer associations
2396 (dictionary of strings) 2395 (dictionary of strings)
2397 """ 2396 """
2397 from eric7.QScintilla import Lexers
2398
2398 editorLexerAssoc = {} 2399 editorLexerAssoc = {}
2399 Prefs.settings.beginGroup("Editor/LexerAssociations") 2400 Prefs.settings.beginGroup("Editor/LexerAssociations")
2400 keyList = Prefs.settings.childKeys() 2401 keyList = Prefs.settings.childKeys()
2401 Prefs.settings.endGroup() 2402 Prefs.settings.endGroup()
2402
2403 from eric7.QScintilla import Lexers
2404 2403
2405 editorLexerAssocDefaults = Lexers.getDefaultLexerAssociations() 2404 editorLexerAssocDefaults = Lexers.getDefaultLexerAssociations()
2406 2405
2407 if len(keyList) == 0: 2406 if len(keyList) == 0:
2408 # build from scratch 2407 # build from scratch
2868 icon = Prefs.settings.value("Icon") 2867 icon = Prefs.settings.value("Icon")
2869 feeds.append((url, title, icon)) 2868 feeds.append((url, title, icon))
2870 Prefs.settings.endArray() 2869 Prefs.settings.endArray()
2871 return feeds 2870 return feeds
2872 elif key in ["SyncFtpPassword", "SyncEncryptionKey"]: 2871 elif key in ["SyncFtpPassword", "SyncEncryptionKey"]:
2873 from eric7.Utilities.crypto import pwConvert
2874
2875 return pwConvert( 2872 return pwConvert(
2876 Prefs.settings.value("WebBrowser/" + key, Prefs.webBrowserDefaults[key]), 2873 Prefs.settings.value("WebBrowser/" + key, Prefs.webBrowserDefaults[key]),
2877 encode=False, 2874 encode=False,
2878 ) 2875 )
2879 elif key in ( 2876 elif key in (
3047 Prefs.settings.setValue("URL", v[0]) 3044 Prefs.settings.setValue("URL", v[0])
3048 Prefs.settings.setValue("Title", v[1]) 3045 Prefs.settings.setValue("Title", v[1])
3049 Prefs.settings.setValue("Icon", v[2]) 3046 Prefs.settings.setValue("Icon", v[2])
3050 Prefs.settings.endArray() 3047 Prefs.settings.endArray()
3051 elif key in ["SyncFtpPassword", "SyncEncryptionKey"]: 3048 elif key in ["SyncFtpPassword", "SyncEncryptionKey"]:
3052 from eric7.Utilities.crypto import pwConvert
3053
3054 Prefs.settings.setValue("WebBrowser/" + key, pwConvert(value, encode=True)) 3049 Prefs.settings.setValue("WebBrowser/" + key, pwConvert(value, encode=True))
3055 elif key in ["SafeBrowsingUpdateDateTime"]: 3050 elif key in ["SafeBrowsingUpdateDateTime"]:
3056 # value is a QDateTime 3051 # value is a QDateTime
3057 Prefs.settings.setValue( 3052 Prefs.settings.setValue(
3058 "WebBrowser/" + key, value.toString(Qt.DateFormat.ISODate) 3053 "WebBrowser/" + key, value.toString(Qt.DateFormat.ISODate)
3191 3186
3192 @param key the key of the value to get 3187 @param key the key of the value to get
3193 @return the requested user setting 3188 @return the requested user setting
3194 """ 3189 """
3195 if key == "MailServerPassword": 3190 if key == "MailServerPassword":
3196 from eric7.Utilities.crypto import pwConvert
3197
3198 return pwConvert( 3191 return pwConvert(
3199 Prefs.settings.value("User/" + key, Prefs.userDefaults[key]), encode=False 3192 Prefs.settings.value("User/" + key, Prefs.userDefaults[key]), encode=False
3200 ) 3193 )
3201 elif key in ["MailServerPort"]: 3194 elif key in ["MailServerPort"]:
3202 try: 3195 try:
3230 3223
3231 @param key the key of the setting to be set 3224 @param key the key of the setting to be set
3232 @param value the value to be set 3225 @param value the value to be set
3233 """ 3226 """
3234 if key == "MailServerPassword": 3227 if key == "MailServerPassword":
3235 from eric7.Utilities.crypto import pwConvert
3236
3237 Prefs.settings.setValue("User/" + key, pwConvert(value, encode=True)) 3228 Prefs.settings.setValue("User/" + key, pwConvert(value, encode=True))
3238 elif key == "MasterPassword": 3229 elif key == "MasterPassword":
3239 from eric7.Utilities.crypto.py3PBKDF2 import hashPassword
3240
3241 Prefs.settings.setValue("User/" + key, hashPassword(value)) 3230 Prefs.settings.setValue("User/" + key, hashPassword(value))
3242 else: 3231 else:
3243 Prefs.settings.setValue("User/" + key, value) 3232 Prefs.settings.setValue("User/" + key, value)
3244 3233
3245 3234

eric ide

mercurial