"Fossies" - the Fresh Open Source Software Archive

Member "eric6-20.9/eric/eric6/Preferences/__init__.py" (2 Sep 2020, 134903 Bytes) of package /linux/misc/eric6-20.9.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "__init__.py" see the Fossies "Dox" file reference documentation.

    1 # -*- coding: utf-8 -*-
    2 
    3 # Copyright (c) 2002 - 2020 Detlev Offenbach <detlev@die-offenbachs.de>
    4 #
    5 
    6 """
    7 Package implementing the preferences interface.
    8 
    9 The preferences interface consists of a class, which defines the default
   10 values for all configuration items and stores the actual values. These
   11 values are read and written to the eric6 preferences file by module
   12 functions. The data is stored in a file in a subdirectory of the users home
   13 directory. The individual configuration data is accessed by accessor functions
   14 defined on the module level. The module is simply imported wherever it is
   15 needed with the statement 'import Preferences'. Do not use
   16 'from Preferences import *' to import it.
   17 """
   18 
   19 
   20 import ast
   21 import os
   22 import fnmatch
   23 import shutil
   24 import json
   25 import sys
   26 
   27 from PyQt5.QtCore import (
   28     QDir, QPoint, QLocale, QSettings, QFileInfo, QCoreApplication, QByteArray,
   29     QSize, QUrl, Qt, QLibraryInfo, QDateTime
   30 )
   31 from PyQt5.QtGui import QColor, QFont, QPalette
   32 from PyQt5.QtWidgets import QApplication
   33 try:
   34     from PyQt5.QtWebEngineWidgets import QWebEngineSettings
   35 except ImportError:
   36     QWebEngineSettings = None
   37 from PyQt5.Qsci import QsciScintilla, QsciLexerPython
   38 
   39 from E5Gui import E5FileDialog
   40 
   41 from E5Network.E5Ftp import E5FtpProxyType
   42 
   43 import Globals
   44 
   45 from Project.ProjectBrowserFlags import (
   46     SourcesBrowserFlag, FormsBrowserFlag, ResourcesBrowserFlag,
   47     TranslationsBrowserFlag, InterfacesBrowserFlag, OthersBrowserFlag,
   48     ProtocolsBrowserFlag, AllBrowsersFlag
   49 )
   50 
   51 from WebBrowser.FlashCookieManager.FlashCookieUtilities import (
   52     flashDataPathForOS
   53 )
   54 
   55 from QScintilla.Shell import ShellHistoryStyle
   56 
   57 
   58 class Prefs(object):
   59     """
   60     A class to hold all configuration items for the application.
   61     """
   62     # defaults for the variables window
   63     varDefaults = {
   64         "LocalsFilter": "[]",
   65         "GlobalsFilter": "[]"
   66     }
   67     
   68     # defaults for the debugger
   69     debuggerDefaults = {
   70         "RemoteDbgEnabled": False,
   71         "RemoteHost": "",
   72         "RemoteExecution": "",
   73         "PassiveDbgEnabled": False,
   74         "PassiveDbgPort": 42424,
   75         "PassiveDbgType": "Python",
   76         "AutomaticReset": False,
   77         "Autosave": True,
   78         "ThreeStateBreakPoints": False,
   79         "RecentNumber": 9,
   80         # max. number of file names to be remembered for the add breakpoint
   81         # dialog
   82         "SuppressClientExit": False,
   83         "BreakAlways": False,
   84         "ShowExceptionInShell": True,
   85         "Python3VirtualEnv": "",
   86         "RubyInterpreter": "",
   87         "DebugClientType3": "standard",
   88         # supported "standard", "custom"
   89         "DebugClient3": "",
   90         "DebugEnvironmentReplace": False,
   91         "DebugEnvironment": "",
   92         "PythonRedirect": True,
   93         "PythonNoEncoding": False,
   94         "Python3Redirect": True,
   95         "Python3NoEncoding": False,
   96         "RubyRedirect": True,
   97         "ConsoleDbgEnabled": False,
   98         "ConsoleDbgCommand": "",
   99         "PathTranslation": False,
  100         "PathTranslationRemote": "",
  101         "PathTranslationLocal": "",
  102         "NetworkInterface": "127.0.0.1",
  103         "AutoViewSourceCode": False,
  104         "MaxVariableSize": 0,     # Bytes, 0 = no limit
  105         "BgColorNew": QColor("#28FFEEAA"),
  106         "BgColorChanged": QColor("#2870FF66"),
  107         "AllowedHosts": ["127.0.0.1", "::1%0"],
  108         # space separated list of Python3 extensions
  109         "Python3Extensions": ".py .pyw .py3 .pyw3"
  110     }
  111     
  112     # defaults for the UI settings
  113     uiDefaults = {
  114         "KeyboardInputInterval": 0,         # 0 = use system default
  115         "BackgroundServiceProcesses": 0,    # 0 = max. CPUs minus one
  116         "Language": "System",
  117         "Style": "System",
  118         "StyleSheet": "",
  119         "ViewManager": "tabview",
  120         "LayoutType": "Sidebars",           # "Toolboxes" or "Sidebars"
  121         "ShellPosition": "bottom",          # "left", "right" or "bottom"
  122         "SidebarDelay": 200,
  123         "BrowsersListFoldersFirst": True,
  124         "BrowsersHideNonPublic": False,
  125         "BrowsersListContentsByOccurrence": False,
  126         "BrowsersListHiddenFiles": False,
  127         "BrowsersFileFilters": "*.py[co];*.so;*.dll",
  128         "LogViewerAutoRaise": True,
  129         "LogViewerStdoutFilter": [],
  130         "LogViewerStderrFilter": [],
  131         "LogViewerStdxxxFilter": [],
  132         "SingleApplicationMode": False,
  133         "CaptionShowsFilename": True,
  134         "CaptionFilenameLength": 100,
  135         "RecentNumber": 9,
  136         "TabViewManagerFilenameLength": 40,
  137         "TabViewManagerFilenameOnly": True,
  138         "ShowFilePreview": True,
  139         "ShowFilePreviewJS": True,
  140         "ShowFilePreviewSSI": True,
  141         "ShowTemplateViewer": True,             # left side
  142         "ShowFileBrowser": True,                # left side
  143         "ShowSymbolsViewer": True,              # left side
  144         "ShowCodeDocumentationViewer": True,    # right side
  145         "ShowPyPIPackageManager": True,         # right side
  146         "ShowCondaPackageManager": True,        # right side
  147         "ShowCooperation": True,                # right side
  148         "ShowIrc": True,                        # right side
  149         "ShowMicroPython": True,                # right side
  150         "ShowNumbersViewer": True,              # bottom side
  151         "ViewProfiles2": {
  152             "edit": [
  153                 # saved state main window with toolbox windows (0)
  154                 QByteArray(),
  155                 # visibility of the toolboxes/sidebars (1)
  156                 # left, bottom, right
  157                 [True, True, True],
  158                 # saved states of the splitters and sidebars of the
  159                 # sidebars layout (2)
  160                 # left splitter, vertical splitter, left sidebar,
  161                 # bottom sidebar, right splitter, right sidebar
  162                 [QByteArray(), QByteArray(), QByteArray(),
  163                  QByteArray(), QByteArray(), QByteArray()],
  164             ],
  165             "debug": [
  166                 # saved state main window with toolbox windows (0)
  167                 QByteArray(),
  168                 # visibility of the toolboxes/sidebars (1)
  169                 # left, bottom, right
  170                 [False, True, True],
  171                 # saved states of the splitters and sidebars of the
  172                 # sidebars layout (2)
  173                 # left splitter, vertical splitter, left sidebar,
  174                 # bottom sidebar, right splitter, right sidebar
  175                 [QByteArray(), QByteArray(), QByteArray(),
  176                  QByteArray(), QByteArray(), QByteArray()],
  177             ],
  178         },
  179         "ToolbarManagerState": QByteArray(),
  180         "PreviewSplitterState": QByteArray(),
  181         "ShowSplash": True,
  182         "SplitOrientationVertical": False,
  183         "UseNativeMenuBar": True,
  184         
  185         "PerformVersionCheck": 3,
  186         # 0 = off
  187         # 1 = at startup
  188         # 2 = daily
  189         # 3 = weekly
  190         # 4 = monthly
  191         "DynamicOnlineCheck": True,
  192         "UseProxy": False,
  193         "UseSystemProxy": True,
  194         "UseHttpProxyForAll": False,
  195         "ProxyHost/Http": "",
  196         "ProxyHost/Https": "",
  197         "ProxyHost/Ftp": "",
  198         "ProxyPort/Http": 80,
  199         "ProxyPort/Https": 443,
  200         "ProxyPort/Ftp": 21,
  201         "ProxyUser/Http": "",
  202         "ProxyUser/Https": "",
  203         "ProxyUser/Ftp": "",
  204         "ProxyPassword/Http": "",
  205         "ProxyPassword/Https": "",
  206         "ProxyPassword/Ftp": "",
  207         "ProxyType/Ftp": E5FtpProxyType.NoProxy,
  208         "ProxyAccount/Ftp": "",
  209         "ProxyExceptions": "localhost,127.0.0.,::1",
  210         
  211         "PluginRepositoryUrl6":
  212         "https://eric-ide.python-projects.org/plugins6/repository.xml",
  213         "VersionsUrls6": [
  214             "https://eric-ide.python-projects.org/versions/versions6",
  215             "https://die-offenbachs.homelinux.org/eric/versions/"
  216             "versions6",
  217         ],
  218         
  219         "OpenOnStartup": 0,        # 0 = nothing
  220                                    # 1 = last file
  221                                    # 2 = last project
  222                                    # 3 = last multiproject
  223                                    # 4 = last global session
  224         "OpenCrashSessionOnStartup": True,
  225         "CrashSessionEnabled": True,
  226         
  227         "DownloadPath": "",
  228         "RequestDownloadFilename": True,
  229         "CheckErrorLog": True,
  230         "MinimumMessageTypeSeverity": 2,    # 0 = QtDebugMsg
  231                                             # 1 = QtWarningMsg
  232                                             # 2 = QtCriticalMsg, QtSystemMsg
  233                                             # 3 = QtFatalMsg
  234         
  235         "LogStdErrColour": QColor(Qt.red),
  236         "NotificationsEnabled": True,
  237         "NotificationTimeout": 5,       # time in seconds the notification
  238                                         # is shown
  239         "NotificationPosition": QPoint(10, 10),
  240         "TextMimeTypes": [
  241             "application/bookmarks.xbel",
  242             "application/x-xbel",
  243             "application/opensearchdescription+xml",
  244             "application/x-actionscript",
  245             "application/x-actionscript3",
  246             "application/x-awk",
  247             "application/x-sh",
  248             "application/x-shellscript",
  249             "application/x-shell-session",
  250             "application/x-dos-batch",
  251             "application/x-befunge",
  252             "application/x-brainfuck",
  253             "application/x-javascript+cheetah",
  254             "application/x-javascript+spitfire",
  255             "application/x-cheetah",
  256             "application/x-spitfire",
  257             "application/xml+cheetah",
  258             "application/xml+spitfire",
  259             "application/x-clojure",
  260             "application/x-coldfusion",
  261             "application/x-cython",
  262             "application/x-django-templating",
  263             "application/x-jinja",
  264             "application/xml-dtd",
  265             "application/x-ecl",
  266             "application/x-ruby-templating",
  267             "application/x-evoque",
  268             "application/xml+evoque",
  269             "application/x-fantom",
  270             "application/x-genshi",
  271             "application/x-kid",
  272             "application/x-genshi-text",
  273             "application/x-gettext",
  274             "application/x-troff",
  275             "application/xhtml+xml",
  276             "application/x-php",
  277             "application/x-httpd-php",
  278             "application/x-httpd-php3",
  279             "application/x-httpd-php4",
  280             "application/x-httpd-php5",
  281             "application/x-hybris",
  282             "application/x-javascript+django",
  283             "application/x-javascript+jinja",
  284             "application/x-javascript+ruby",
  285             "application/x-javascript+genshi",
  286             "application/javascript",
  287             "application/x-javascript",
  288             "application/x-javascript+php",
  289             "application/x-javascript+smarty",
  290             "application/json",
  291             "application/x-jsp",
  292             "application/x-julia",
  293             "application/x-httpd-lasso",
  294             "application/x-httpd-lasso[89]",
  295             "application/x-httpd-lasso8",
  296             "application/x-httpd-lasso9",
  297             "application/x-javascript+lasso",
  298             "application/xml+lasso",
  299             "application/x-lua",
  300             "application/x-javascript+mako",
  301             "application/x-mako",
  302             "application/xml+mako",
  303             "application/x-gooddata-maql",
  304             "application/x-mason",
  305             "application/x-moonscript",
  306             "application/x-javascript+myghty",
  307             "application/x-myghty",
  308             "application/xml+myghty",
  309             "application/x-newlisp",
  310             "application/x-openedge",
  311             "application/x-perl",
  312             "application/postscript",
  313             "application/x-pypylog",
  314             "application/x-python3",
  315             "application/x-python",
  316             "application/x-qml",
  317             "application/x-racket",
  318             "application/x-pygments-tokens",
  319             "application/x-ruby",
  320             "application/x-standardml",
  321             "application/x-scheme",
  322             "application/x-sh-session",
  323             "application/x-smarty",
  324             "application/x-ssp",
  325             "application/x-tcl",
  326             "application/x-csh",
  327             "application/x-urbiscript",
  328             "application/xml+velocity",
  329             "application/xquery",
  330             "application/xml+django",
  331             "application/xml+jinja",
  332             "application/xml+ruby",
  333             "application/xml",
  334             "application/rss+xml",
  335             "application/atom+xml",
  336             "application/xml+php",
  337             "application/xml+smarty",
  338             "application/xsl+xml",
  339             "application/xslt+xml",
  340             "application/x-desktop",
  341             
  342             "image/svg+xml",
  343         ],
  344     }
  345     
  346     iconsDefaults = {
  347         "Path": [],
  348         "DefaultIconsPath": "automatic",
  349         # automatic, breeze-dark, breeze-light, oxygen
  350     }
  351     
  352     # defaults for the cooperation settings
  353     cooperationDefaults = {
  354         "ServerPort": 42000,
  355         "AutoStartServer": False,
  356         "TryOtherPorts": True,
  357         "MaxPortsToTry": 100,
  358         "AutoAcceptConnections": False,
  359         "BannedUsers": [],
  360     }
  361     
  362     # defaults for the editor settings
  363     editorDefaults = {
  364         "AutosaveInterval": 0,
  365         "TabWidth": 4,
  366         "IndentWidth": 4,
  367         "TabIndentOverride": "{}",      # JSON formatted dictionary
  368         "IndentationGuides": True,
  369         "LinenoMargin": True,
  370         "FoldingMargin": True,
  371         "FoldingStyle": 1,
  372         "TabForIndentation": False,
  373         "TabIndents": True,
  374         "ConvertTabsOnLoad": False,
  375         "AutomaticEOLConversion": True,
  376         "ShowWhitespace": False,
  377         "WhitespaceSize": 1,
  378         "ShowEOL": False,
  379         "UseMonospacedFont": False,
  380         "WrapLongLinesMode": QsciScintilla.WrapNone,
  381         "WrapVisualFlag": QsciScintilla.WrapFlagNone,
  382         "WrapIndentMode": QsciScintilla.WrapIndentFixed,
  383         "WrapStartIndent": 0,
  384         "WarnFilesize": 512,
  385         "ClearBreaksOnClose": True,
  386         "StripTrailingWhitespace": False,
  387         "InsertFinalNewline": True,
  388         "CommentColumn0": True,
  389         "OverrideEditAreaColours": False,
  390         
  391         "EdgeMode": QsciScintilla.EdgeNone,
  392         "EdgeColumn": 80,
  393         
  394         "AutoIndentation": True,
  395         "BraceHighlighting": True,
  396         "CreateBackupFile": False,
  397         "CaretLineVisible": False,
  398         "CaretLineAlwaysVisible": False,
  399         "CaretWidth": 1,
  400         "CaretLineFrameWidth": 0,
  401         "ColourizeSelText": False,
  402         "CustomSelectionColours": False,
  403         "ExtendSelectionToEol": False,
  404         "LineMarkersBackground": True,
  405         
  406         "AutoPrepareAPIs": False,
  407         
  408         "AutoCompletionEnabled": False,
  409         "AutoCompletionCaseSensitivity": True,
  410         "AutoCompletionReplaceWord": False,
  411         "AutoCompletionShowSingle": False,
  412         "AutoCompletionSource": QsciScintilla.AcsDocument,
  413         "AutoCompletionThreshold": 2,
  414         # timeout in ms before auto-completion is started
  415         "AutoCompletionTimeout": 200,
  416         "AutoCompletionFillups": False,
  417         # show QScintilla completions, if plug-in fails
  418         "AutoCompletionScintillaOnFail": False,
  419         "AutoCompletionReversedList": False,
  420         "AutoCompletionCacheEnabled": True,
  421         "AutoCompletionCacheSize": 100,
  422         "AutoCompletionCacheTime": 300,     # 5 minutes
  423         "AutoCompletionWatchdogTime": 3000,     # ms
  424         "AutoCompletionMaxLines": 6,
  425         "AutoCompletionMaxChars": 40,
  426         
  427         "CallTipsEnabled": False,
  428         "CallTipsVisible": 0,
  429         "CallTipsStyle": QsciScintilla.CallTipsNoContext,
  430         # show QScintilla calltips, if plug-in fails
  431         "CallTipsScintillaOnFail": False,
  432         
  433         "AutoCheckSyntax": True,
  434         "OnlineSyntaxCheck": True,
  435         "OnlineSyntaxCheckInterval": 5,
  436         
  437         "OnlineChangeTrace": True,
  438         "OnlineChangeTraceInterval": 500,      # 1000 milliseconds
  439         
  440         "AutoReopen": False,
  441         
  442         "AnnotationsEnabled": True,
  443         
  444         "MiniContextMenu": False,
  445         "HideFormatButtons": True,
  446         
  447         "SearchMarkersEnabled": True,
  448         "QuickSearchMarkersEnabled": True,
  449         "MarkOccurrencesEnabled": True,
  450         "MarkOccurrencesTimeout": 500,     # 500 milliseconds
  451         "SearchRegexpMode": 0,             # 0: POSIX mode, 1: CXX11 mode
  452         "AdvancedEncodingDetection": True,
  453         
  454         "SpellCheckingEnabled": True,
  455         "AutoSpellCheckingEnabled": True,
  456         "AutoSpellCheckChunkSize": 30,
  457         "SpellCheckStringsOnly": True,
  458         "SpellCheckingMinWordSize": 3,
  459         "SpellCheckingDefaultLanguage": "en_US",
  460         "SpellCheckingPersonalWordList": "",
  461         "SpellCheckingPersonalExcludeList": "",
  462         "FullSpellCheckExtensions": ["md", "markdown", "rst", "txt"],
  463         "FullSpellCheckUnknown": False,
  464         
  465         "DefaultEncoding": "utf-8",
  466         "DefaultOpenFilter": QCoreApplication.translate(
  467             'Lexers', 'Python Files (*.py *.py3)'),
  468         "DefaultSaveFilter": QCoreApplication.translate(
  469             'Lexers', "Python3 Files (*.py)"),
  470         "AdditionalOpenFilters": [],
  471         "AdditionalSaveFilters": [],
  472         
  473         "ZoomFactor": 0,
  474         
  475         "PreviewRefreshWaitTimer": 500,     # wait time in milliseconds
  476         "PreviewHtmlFileNameExtensions": ["html", "htm", "svg", "asp", "kid"],
  477         "PreviewMarkdownFileNameExtensions": ["md", "markdown"],
  478         "PreviewRestFileNameExtensions": ["rst"],
  479         "PreviewQssFileNameExtensions": ["qss"],
  480         "PreviewRestUseSphinx": False,
  481         "PreviewMarkdownNLtoBR": False,
  482         "PreviewMarkdownUsePyMdownExtensions": True,
  483         "PreviewMarkdownMathJax": True,
  484         "PreviewMarkdownMermaid": True,
  485         "PreviewMarkdownHTMLFormat": "HTML5",  # XHTML1, HTML4, HTML5
  486         "PreviewRestDocutilsHTMLFormat": "HTML5",   # HTML4, HTML5
  487         
  488         "VirtualSpaceOptions": QsciScintilla.SCVS_NONE,
  489         
  490         "MouseClickHandlersEnabled": True,
  491         
  492         "ShowMarkerMapOnRight": True,
  493         "ShowMarkerChanges": True,
  494         "ShowMarkerCoverage": True,
  495         "ShowMarkerSearch": True,
  496         
  497         # All (most) lexers
  498         "AllFoldCompact": True,
  499         
  500         # Bash specifics
  501         "BashFoldComment": True,
  502         
  503         # CMake specifics
  504         "CMakeFoldAtElse": False,
  505         
  506         # C++ specifics
  507         "CppCaseInsensitiveKeywords": False,
  508         "CppFoldComment": True,
  509         "CppFoldPreprocessor": False,
  510         "CppFoldAtElse": False,
  511         "CppIndentOpeningBrace": False,
  512         "CppIndentClosingBrace": False,
  513         "CppDollarsAllowed": True,
  514         "CppStylePreprocessor": False,
  515         "CppHighlightTripleQuotedStrings": False,
  516         "CppHighlightHashQuotedStrings": False,
  517         "CppHighlightBackQuotedStrings": False,
  518         "CppHighlightEscapeSequences": False,
  519         "CppVerbatimStringEscapeSequencesAllowed": False,
  520         
  521         # CoffeeScript specifics
  522         "CoffeScriptFoldComment": False,
  523         "CoffeeScriptDollarsAllowed": True,
  524         "CoffeeScriptStylePreprocessor": False,
  525         
  526         # CSS specifics
  527         "CssFoldComment": True,
  528         "CssHssSupport": False,
  529         "CssLessSupport": False,
  530         "CssSassySupport": False,
  531         
  532         # D specifics
  533         "DFoldComment": True,
  534         "DFoldAtElse": False,
  535         "DIndentOpeningBrace": False,
  536         "DIndentClosingBrace": False,
  537         
  538         # Gettext specifics
  539         "PoFoldComment": False,
  540         
  541         # HTML specifics
  542         "HtmlFoldPreprocessor": False,
  543         "HtmlFoldScriptComments": False,
  544         "HtmlFoldScriptHeredocs": False,
  545         "HtmlCaseSensitiveTags": False,
  546         "HtmlDjangoTemplates": False,
  547         "HtmlMakoTemplates": False,
  548         
  549         # JSON specifics
  550         "JSONHightlightComments": True,
  551         "JSONHighlightEscapeSequences": True,
  552         
  553         # Pascal specifics
  554         "PascalFoldComment": True,
  555         "PascalFoldPreprocessor": False,
  556         "PascalSmartHighlighting": True,
  557         
  558         # Perl specifics
  559         "PerlFoldComment": True,
  560         "PerlFoldPackages": True,
  561         "PerlFoldPODBlocks": True,
  562         "PerlFoldAtElse": False,
  563         
  564         # PostScript specifics
  565         "PostScriptTokenize": False,
  566         "PostScriptLevel": 3,
  567         "PostScriptFoldAtElse": False,
  568         
  569         # Povray specifics
  570         "PovFoldComment": True,
  571         "PovFoldDirectives": False,
  572         
  573         # Properties specifics
  574         "PropertiesInitialSpaces": True,
  575         
  576         # Python specifics
  577         "PythonBadIndentation": QsciLexerPython.Inconsistent,
  578         "PythonFoldComment": True,
  579         "PythonFoldString": True,
  580         "PythonAutoIndent": True,
  581         "PythonAllowV2Unicode": True,
  582         "PythonAllowV3Binary": True,
  583         "PythonAllowV3Bytes": True,
  584         "PythonFoldQuotes": False,
  585         "PythonStringsOverNewLineAllowed": False,
  586         "PythonHighlightSubidentifier": True,
  587         
  588         # Ruby specifics
  589         "RubyFoldComment": False,
  590         
  591         # SQL specifics
  592         "SqlFoldComment": True,
  593         "SqlBackslashEscapes": False,
  594         "SqlDottedWords": False,
  595         "SqlFoldAtElse": False,
  596         "SqlFoldOnlyBegin": False,
  597         "SqlHashComments": False,
  598         "SqlQuotedIdentifiers": False,
  599         
  600         # TCL specifics
  601         "TclFoldComment": False,
  602         
  603         # TeX specifics
  604         "TexFoldComment": False,
  605         "TexProcessComments": False,
  606         "TexProcessIf": True,
  607         
  608         # VHDL specifics
  609         "VHDLFoldComment": True,
  610         "VHDLFoldAtElse": True,
  611         "VHDLFoldAtBegin": True,
  612         "VHDLFoldAtParenthesis": True,
  613         
  614         # XML specifics
  615         "XMLStyleScripts": True,
  616         
  617         # YAML specifics
  618         "YAMLFoldComment": False,
  619     }
  620     
  621     if Globals.isWindowsPlatform():
  622         editorDefaults["EOLMode"] = QsciScintilla.EolWindows
  623     else:
  624         editorDefaults["EOLMode"] = QsciScintilla.EolUnix
  625     
  626     try:
  627         # since QScintilla 2.7.0
  628         editorDefaults["CallTipsPosition"] = QsciScintilla.CallTipsBelowText
  629     except AttributeError:
  630         editorDefaults["CallTipsPosition"] = 0
  631     
  632     editorColourDefaults = {
  633         "CurrentMarker": QColor(Qt.yellow),
  634         "ErrorMarker": QColor(Qt.red),
  635         "MatchingBrace": QColor(Qt.green),
  636         "MatchingBraceBack": QColor(Qt.white),
  637         "NonmatchingBrace": QColor(Qt.red),
  638         "NonmatchingBraceBack": QColor(Qt.white),
  639         "CallTipsBackground": QColor(Qt.white),
  640         "CallTipsForeground": QColor("#7f7f7f"),
  641         "CallTipsHighlight": QColor("#00007f"),
  642         "CaretForeground": QColor(Qt.black),
  643         "CaretLineBackground": QColor(Qt.white),
  644         "Edge": QColor(Qt.lightGray),
  645         "SelectionBackground": QColor(Qt.black),
  646         "SelectionForeground": QColor(Qt.white),
  647         "SearchMarkers": QColor(Qt.blue),
  648         "MarginsBackground": QColor(Qt.lightGray),
  649         "MarginsForeground": QColor(Qt.black),
  650         "FoldmarginBackground": QColor("#e6e6e6"),
  651         "FoldMarkersForeground": QColor(Qt.white),
  652         "FoldMarkersBackground": QColor(Qt.black),
  653         "SpellingMarkers": QColor(Qt.red),
  654         "AnnotationsWarningForeground": QColor("#606000"),
  655         "AnnotationsWarningBackground": QColor("#ffffd0"),
  656         "AnnotationsErrorForeground": QColor("#600000"),
  657         "AnnotationsErrorBackground": QColor("#ffd0d0"),
  658         "AnnotationsStyleForeground": QColor("#000060"),
  659         "AnnotationsStyleBackground": QColor("#d0d0ff"),
  660         "WhitespaceForeground": QColor(Qt.darkGray),
  661         "WhitespaceBackground": QColor(Qt.white),
  662         "OnlineChangeTraceMarkerUnsaved": QColor("#ff8888"),
  663         "OnlineChangeTraceMarkerSaved": QColor("#88ff88"),
  664         "IndentationGuidesBackground": QColor(Qt.white),
  665         "IndentationGuidesForeground": QColor(Qt.black),
  666         "HighlightMarker": QColor("#200000FF"),     # ARGB format
  667         # colors for the marker map
  668         "BookmarksMap": QColor("#f8c700"),
  669         "ErrorsMap": QColor("#dd0000"),
  670         "WarningsMap": QColor("#606000"),
  671         "BreakpointsMap": QColor("#f55c07"),
  672         "TasksMap": QColor("#2278f8"),
  673         "CoverageMap": QColor("#ad3636"),
  674         "ChangesMap": QColor("#00b000"),
  675         "CurrentMap": QColor("#000000"),
  676         "SearchMarkersMap": QColor(Qt.blue),
  677         "VcsConflictMarkersMap": QColor("#dd00dd"),
  678         "MarkerMapBackground": QColor("#e7e7e7"),
  679     }
  680     
  681     editorOtherFontsDefaults = {
  682         "MarginsFont": "Sans Serif,10,-1,5,50,0,0,0,0,0",
  683         "DefaultFont": "Sans Serif,10,-1,5,50,0,0,0,0,0",
  684         "MonospacedFont": "Courier,10,-1,5,50,0,0,0,0,0",
  685     }
  686     
  687     editorTypingDefaults = {
  688         "Python/EnabledTypingAids": True,
  689         "Python/InsertClosingBrace": True,
  690         "Python/IndentBrace": False,
  691         "Python/SkipBrace": True,
  692         "Python/InsertQuote": True,
  693         "Python/DedentElse": True,
  694         "Python/DedentExcept": True,
  695         "Python/InsertImport": True,
  696         "Python/ImportBraceType": False,
  697         "Python/InsertSelf": True,
  698         "Python/InsertBlank": True,
  699         "Python/ColonDetection": True,
  700         "Python/DedentDef": False,
  701         
  702         "Ruby/EnabledTypingAids": True,
  703         "Ruby/InsertClosingBrace": True,
  704         "Ruby/IndentBrace": True,
  705         "Ruby/SkipBrace": True,
  706         "Ruby/InsertQuote": True,
  707         "Ruby/InsertBlank": True,
  708         "Ruby/InsertHereDoc": True,
  709         "Ruby/InsertInlineDoc": True,
  710         
  711         "Yaml/EnabledTypingAids": True,
  712         "Yaml/InsertClosingBrace": True,
  713         "Yaml/SkipBrace": True,
  714         "Yaml/InsertQuote": True,
  715         "Yaml/AutoIndentation": True,
  716         "Yaml/ColonDetection": True,
  717         "Yaml/InsertBlankDash": True,
  718         "Yaml/InsertBlankColon": True,
  719         "Yaml/InsertBlankQuestion": True,
  720         "Yaml/InsertBlankComma": True,
  721     }
  722     
  723     editorExporterDefaults = {
  724         "HTML/WYSIWYG": True,
  725         "HTML/Folding": False,
  726         "HTML/OnlyStylesUsed": False,
  727         "HTML/FullPathAsTitle": False,
  728         "HTML/UseTabs": False,
  729         
  730         "RTF/WYSIWYG": True,
  731         "RTF/UseTabs": False,
  732         "RTF/Font": "Courier New,10,-1,5,50,0,0,0,0,0",
  733         
  734         "PDF/Magnification": 0,
  735         "PDF/Font": "Helvetica",  # must be Courier, Helvetica or Times
  736         "PDF/PageSize": "A4",         # must be A4 or Letter
  737         "PDF/MarginLeft": 36,
  738         "PDF/MarginRight": 36,
  739         "PDF/MarginTop": 36,
  740         "PDF/MarginBottom": 36,
  741         
  742         "TeX/OnlyStylesUsed": False,
  743         "TeX/FullPathAsTitle": False,
  744         
  745         "ODT/WYSIWYG": True,
  746         "ODT/OnlyStylesUsed": False,
  747         "ODT/UseTabs": False,
  748     }
  749     
  750     # defaults for the printer settings
  751     printerDefaults = {
  752         "PrinterName": "",
  753         "ColorMode": True,
  754         "FirstPageFirst": True,
  755         "Magnification": -3,
  756         "Orientation": 0,
  757         "PageSize": 0,
  758         "HeaderFont": "Serif,10,-1,5,50,0,0,0,0,0",
  759         "LeftMargin": 1.0,
  760         "RightMargin": 1.0,
  761         "TopMargin": 1.0,
  762         "BottomMargin": 1.0,
  763         "Resolution": 150,      # printer resolution in DPI
  764     }
  765     
  766     # defaults for the project settings
  767     projectDefaults = {
  768         "SearchNewFiles": False,
  769         "SearchNewFilesRecursively": False,
  770         "AutoIncludeNewFiles": False,
  771         "AutoLoadSession": False,
  772         "AutoSaveSession": False,
  773         "SessionAllBreakpoints": False,
  774         "XMLTimestamp": True,
  775         "AutoCompileForms": False,
  776         "AutoCompileResources": False,
  777         "AutoExecuteMake": False,
  778         "AutoLoadDbgProperties": False,
  779         "AutoSaveDbgProperties": False,
  780         "HideGeneratedForms": False,
  781         "FollowEditor": True,
  782         "FollowCursorLine": True,
  783         "AutoPopulateItems": True,
  784         "RecentNumber": 9,
  785         "DeterminePyFromProject": True,
  786         "TasksProjectAutoSave": True,
  787         "TasksProjectRescanOnOpen": True,
  788         "DebugClientsHistory": [],
  789         "DebuggerInterpreterHistory": [],
  790         "RestartShellForProject": True,
  791     }
  792     
  793     # defaults for the multi project settings
  794     multiProjectDefaults = {
  795         "OpenMasterAutomatically": True,
  796         "XMLTimestamp": True,
  797         "RecentNumber": 9,
  798         "Workspace": "",
  799     }
  800     
  801     # defaults for the project browser flags settings
  802     projectBrowserFlagsDefaults = {
  803         "PyQt5": (
  804             SourcesBrowserFlag |
  805             FormsBrowserFlag |
  806             ResourcesBrowserFlag |
  807             TranslationsBrowserFlag |
  808             InterfacesBrowserFlag |
  809             OthersBrowserFlag |
  810             ProtocolsBrowserFlag),
  811         "PyQt5C": (
  812             SourcesBrowserFlag |
  813             ResourcesBrowserFlag |
  814             TranslationsBrowserFlag |
  815             InterfacesBrowserFlag |
  816             OthersBrowserFlag |
  817             ProtocolsBrowserFlag),
  818         "E6Plugin": (
  819             SourcesBrowserFlag |
  820             FormsBrowserFlag |
  821             ResourcesBrowserFlag |
  822             TranslationsBrowserFlag |
  823             InterfacesBrowserFlag |
  824             OthersBrowserFlag |
  825             ProtocolsBrowserFlag),
  826         "Console": (
  827             SourcesBrowserFlag |
  828             InterfacesBrowserFlag |
  829             OthersBrowserFlag |
  830             ProtocolsBrowserFlag),
  831         "Other": (
  832             SourcesBrowserFlag |
  833             InterfacesBrowserFlag |
  834             OthersBrowserFlag |
  835             ProtocolsBrowserFlag),
  836         "PySide2": (
  837             SourcesBrowserFlag |
  838             FormsBrowserFlag |
  839             ResourcesBrowserFlag |
  840             TranslationsBrowserFlag |
  841             InterfacesBrowserFlag |
  842             OthersBrowserFlag |
  843             ProtocolsBrowserFlag),
  844         "PySide2C": (
  845             SourcesBrowserFlag |
  846             ResourcesBrowserFlag |
  847             TranslationsBrowserFlag |
  848             InterfacesBrowserFlag |
  849             OthersBrowserFlag |
  850             ProtocolsBrowserFlag),
  851     }
  852     
  853     # defaults for the project browser colour settings
  854     projectBrowserColourDefaults = {
  855         "Highlighted": QColor(Qt.red),
  856         
  857         "VcsAdded": QColor(Qt.blue),
  858         "VcsConflict": QColor(Qt.red),
  859         "VcsModified": QColor(Qt.yellow),
  860         "VcsReplaced": QColor(Qt.cyan),
  861         "VcsUpdate": QColor(Qt.green),
  862         "VcsRemoved": QColor(Qt.magenta)
  863     }
  864     
  865     # defaults for the help settings
  866     helpDefaults = {
  867         "CustomViewer": "",
  868         "PythonDocDir": "",
  869         "Qt5DocDir": "",
  870         "PyQt5DocDir": "",
  871         "PySide2DocDir": "",
  872         "EricDocDir": "",
  873     }
  874     
  875     # defaults for the web browser settings
  876     webBrowserDefaults = {
  877         "SingleWebBrowserWindow": True,
  878         "ShowToolbars": False,
  879         "BookmarksToolBarVisible": True,
  880         "MenuBarVisible": False,
  881         "StatusBarVisible": True,
  882         "SaveGeometry": True,
  883         "WebBrowserState": QByteArray(),
  884         "StartupBehavior": 2,       # show speed dial
  885         # 0     open empty page
  886         # 1     open home page
  887         # 2     open speed dial
  888         # 3     restore last session
  889         # 4     ask user for session
  890         "NewTabBehavior": 2,        # show speed dial
  891         # 0     open empty page
  892         # 1     open home page
  893         # 2     open speed dial
  894         "HomePage": "eric:home",
  895         "LoadTabOnActivation": True,
  896         "WarnOnMultipleClose": True,
  897         "DefaultScheme": "https://",
  898         "UserStyleSheet": "",
  899         "ZoomValuesDB": "{}",       # empty JSON dictionary
  900         "HistoryLimit": 30,
  901         "WebSearchSuggestions": True,
  902         "WebSearchEngine": "DuckDuckGo",
  903         "WebSearchKeywords": [],    # array of two tuples (keyword,
  904                                     # search engine name)
  905         "SearchLanguage": QLocale().language(),
  906         "ImageSearchEngine": "Google",
  907         "RssFeeds": [],
  908         "ShowPreview": True,
  909         "WebInspectorPort": 42024,
  910         "WebInspectorEnabled": False,
  911         "DiskCacheEnabled": True,
  912         "DiskCacheSize": 50,        # 50 MB
  913         "SslExceptionsDB": "{}",    # empty JSON dictionary
  914         "AlwaysRejectFaultyCertificates": False,
  915         "DoNotTrack": False,
  916         "RefererSendReferer": 2,        # send always
  917         "RefererDefaultPolicy": 3,      # don't send a referer when downgrading
  918         "RefererTrimmingPolicy": 0,     # send full URL (no trimming)
  919         "SendRefererWhitelist": ["qt-apps.org", "kde-apps.org"],
  920         "AcceptCookies": 2,         # CookieJar.AcceptOnlyFromSitesNavigatedTo
  921         "KeepCookiesUntil": 0,      # CookieJar.KeepUntilExpire
  922         "FilterTrackingCookies": True,
  923         "SecureUrlColor": QColor(184, 248, 169),
  924         "InsecureUrlColor": QColor(248, 227, 169),
  925         "MaliciousUrlColor": QColor(255, 132, 140),
  926         "PrivateModeUrlColor": QColor(220, 220, 220),
  927         "UserAgent": "",
  928         "AcceptQuotaRequest": 2,            # yes/no/ask (0, 1, 2)
  929         "AcceptProtocolHandlerRequest": 2,  # yes/no/ask (0, 1, 2)
  930         # Auto Scroller
  931         "AutoScrollEnabled": True,
  932         "AutoScrollDivider": 8.0,
  933         # Tab Manager
  934         "TabManagerGroupByType": 0,     # TabManagerWidget.GroupByWindow
  935         # Grease Monkey
  936         "GreaseMonkeyDisabledScripts": [],
  937         # Downloads
  938         "DownloadManagerRemovePolicy": 0,      # never delete downloads
  939         "DownloadManagerSize": QSize(450, 600),
  940         "DownloadManagerPosition": QPoint(),
  941         "DownloadManagerDownloads": [],
  942         "DownloadManagerAutoOpen": False,
  943         "DownloadManagerAutoClose": False,
  944         # Spell Checking
  945         "SpellCheckEnabled": False,
  946         "SpellCheckLanguages": [],
  947         "SpellCheckDictionariesUrl":
  948         ("https://eric-ide.python-projects.org/qwebengine_dictionaries/"
  949          "dictionaries.xml"),
  950         # Sync
  951         "SyncEnabled": False,
  952         "SyncBookmarks": True,
  953         "SyncHistory": True,
  954         "SyncPasswords": False,
  955         "SyncUserAgents": True,
  956         "SyncSpeedDial": True,
  957         "SyncEncryptData": False,
  958         "SyncEncryptionKey": "",
  959         "SyncEncryptionKeyLength": 32,      # 16, 24 or 32
  960         "SyncEncryptPasswordsOnly": False,
  961         "SyncType": 0,
  962         "SyncFtpServer": "",
  963         "SyncFtpUser": "",
  964         "SyncFtpPassword": "",
  965         "SyncFtpPath": "",
  966         "SyncFtpPort": 21,
  967         "SyncFtpIdleTimeout": 30,
  968         "SyncDirectoryPath": "",
  969         # AdBlock
  970         "AdBlockEnabled": False,
  971         "AdBlockSubscriptions": [],
  972         "AdBlockUpdatePeriod": 1,
  973         "AdBlockExceptions": [],
  974         "AdBlockUseLimitedEasyList": True,
  975         # Flash Cookie Manager
  976         "FlashCookiesDeleteOnStartExit": False,
  977         "FlashCookieAutoRefresh": False,
  978         "FlashCookieNotify": False,
  979         "FlashCookiesWhitelist": [],
  980         "FlashCookiesBlacklist": [],
  981         "FlashCookiesDataPath": flashDataPathForOS(),
  982         # PIM:
  983         "PimFullName": "",
  984         "PimFirstName": "",
  985         "PimLastName": "",
  986         "PimEmail": "",
  987         "PimPhone": "",
  988         "PimMobile": "",
  989         "PimAddress": "",
  990         "PimCity": "",
  991         "PimZip": "",
  992         "PimState": "",
  993         "PimCountry": "",
  994         "PimHomePage": "",
  995         "PimSpecial1": "",
  996         "PimSpecial2": "",
  997         "PimSpecial3": "",
  998         "PimSpecial4": "",
  999         # VirusTotal:
 1000         "VirusTotalEnabled": False,
 1001         "VirusTotalServiceKey": "",
 1002         "VirusTotalSecure": True,
 1003         # Sessions
 1004         "SessionAutoSave": True,
 1005         "SessionAutoSaveInterval": 15,  # interval in seconds
 1006         "SessionLastActivePath": "",
 1007         # Google Safe Browsing
 1008         "SafeBrowsingEnabled": True,
 1009         "SafeBrowsingApiKey": "",       # API key
 1010         "SafeBrowsingFilterPlatform": True,
 1011         "SafeBrowsingAutoUpdate": False,
 1012         "SafeBrowsingUpdateDateTime": QDateTime(),
 1013         "SafeBrowsingUseLookupApi": False,
 1014     }
 1015     if QWebEngineSettings:
 1016         webBrowserDefaults["HelpViewerType"] = 1      # eric browser
 1017     else:
 1018         webBrowserDefaults["HelpViewerType"] = 2      # Qt Assistant
 1019     
 1020     @classmethod
 1021     def initWebEngineSettingsDefaults(cls):
 1022         """
 1023         Class method to initialize the web engine settings related defaults.
 1024         """
 1025         if QWebEngineSettings is None:
 1026             return
 1027         
 1028         webEngineSettings = QWebEngineSettings.defaultSettings()
 1029         cls.webBrowserDefaults.update({
 1030             "StandardFontFamily": webEngineSettings.fontFamily(
 1031                 QWebEngineSettings.StandardFont),
 1032             "FixedFontFamily": webEngineSettings.fontFamily(
 1033                 QWebEngineSettings.FixedFont),
 1034             "SerifFontFamily": webEngineSettings.fontFamily(
 1035                 QWebEngineSettings.StandardFont),
 1036             "SansSerifFontFamily": webEngineSettings.fontFamily(
 1037                 QWebEngineSettings.SansSerifFont),
 1038             "CursiveFontFamily": webEngineSettings.fontFamily(
 1039                 QWebEngineSettings.CursiveFont),
 1040             "FantasyFontFamily": webEngineSettings.fontFamily(
 1041                 QWebEngineSettings.FantasyFont),
 1042             "DefaultFontSize": webEngineSettings.fontSize(
 1043                 QWebEngineSettings.DefaultFontSize),
 1044             "DefaultFixedFontSize": webEngineSettings.fontSize(
 1045                 QWebEngineSettings.DefaultFixedFontSize),
 1046             "MinimumFontSize": webEngineSettings.fontSize(
 1047                 QWebEngineSettings.MinimumFontSize),
 1048             "MinimumLogicalFontSize": webEngineSettings.fontSize(
 1049                 QWebEngineSettings.MinimumLogicalFontSize),
 1050             
 1051             "AutoLoadImages": webEngineSettings.testAttribute(
 1052                 QWebEngineSettings.AutoLoadImages),
 1053             "JavaScriptEnabled": webEngineSettings.testAttribute(
 1054                 QWebEngineSettings.JavascriptEnabled),
 1055             "JavaScriptCanOpenWindows": webEngineSettings.testAttribute(
 1056                 QWebEngineSettings.JavascriptCanOpenWindows),
 1057             "JavaScriptCanAccessClipboard": webEngineSettings.testAttribute(
 1058                 QWebEngineSettings.JavascriptCanAccessClipboard),
 1059             "PluginsEnabled": webEngineSettings.testAttribute(
 1060                 QWebEngineSettings.PluginsEnabled),
 1061             "LocalStorageEnabled": webEngineSettings.testAttribute(
 1062                 QWebEngineSettings.LocalStorageEnabled),
 1063             "DefaultTextEncoding": webEngineSettings.defaultTextEncoding(),
 1064             "SpatialNavigationEnabled": webEngineSettings.testAttribute(
 1065                 QWebEngineSettings.SpatialNavigationEnabled),
 1066             "LinksIncludedInFocusChain": webEngineSettings.testAttribute(
 1067                 QWebEngineSettings.LinksIncludedInFocusChain),
 1068             "LocalContentCanAccessRemoteUrls": webEngineSettings.testAttribute(
 1069                 QWebEngineSettings.LocalContentCanAccessRemoteUrls),
 1070             "LocalContentCanAccessFileUrls": webEngineSettings.testAttribute(
 1071                 QWebEngineSettings.LocalContentCanAccessFileUrls),
 1072             "XSSAuditingEnabled": webEngineSettings.testAttribute(
 1073                 QWebEngineSettings.XSSAuditingEnabled),
 1074             "ScrollAnimatorEnabled": webEngineSettings.testAttribute(
 1075                 QWebEngineSettings.ScrollAnimatorEnabled),
 1076             "ErrorPageEnabled": webEngineSettings.testAttribute(
 1077                 QWebEngineSettings.ErrorPageEnabled),
 1078             "FullScreenSupportEnabled": webEngineSettings.testAttribute(
 1079                 QWebEngineSettings.FullScreenSupportEnabled),
 1080         })
 1081         try:
 1082             # Qt 5.7+
 1083             cls.webBrowserDefaults.update({
 1084                 "PictographFontFamily": webEngineSettings.fontFamily(
 1085                     QWebEngineSettings.PictographFont),
 1086                 
 1087                 "ScreenCaptureEnabled": webEngineSettings.testAttribute(
 1088                     QWebEngineSettings.ScreenCaptureEnabled),
 1089                 "WebGLEnabled": webEngineSettings.testAttribute(
 1090                     QWebEngineSettings.WebGLEnabled),
 1091             })
 1092         except AttributeError:
 1093             pass
 1094         try:
 1095             # Qt 5.8+
 1096             cls.webBrowserDefaults.update({
 1097                 "FocusOnNavigationEnabled": webEngineSettings.testAttribute(
 1098                     QWebEngineSettings.FocusOnNavigationEnabled),
 1099                 "PrintElementBackgrounds": webEngineSettings.testAttribute(
 1100                     QWebEngineSettings.PrintElementBackgrounds),
 1101                 "AllowRunningInsecureContent": webEngineSettings.testAttribute(
 1102                     QWebEngineSettings.AllowRunningInsecureContent),
 1103             })
 1104         except AttributeError:
 1105             pass
 1106         try:
 1107             # Qt 5.9+
 1108             cls.webBrowserDefaults.update({
 1109                 "AllowGeolocationOnInsecureOrigins":
 1110                     webEngineSettings.testAttribute(
 1111                         QWebEngineSettings.AllowGeolocationOnInsecureOrigins),
 1112             })
 1113         except AttributeError:
 1114             pass
 1115         try:
 1116             # Qt 5.10+
 1117             cls.webBrowserDefaults.update({
 1118                 "AllowWindowActivationFromJavaScript":
 1119                     webEngineSettings.testAttribute(
 1120                         QWebEngineSettings.AllowWindowActivationFromJavaScript
 1121                     ),
 1122                 "ShowScrollBars": webEngineSettings.testAttribute(
 1123                     QWebEngineSettings.ShowScrollBars),
 1124             })
 1125         except AttributeError:
 1126             pass
 1127         try:
 1128             # Qt 5.11+
 1129             cls.webBrowserDefaults.update({
 1130                 "PlaybackRequiresUserGesture":
 1131                     webEngineSettings.testAttribute(
 1132                         QWebEngineSettings.PlaybackRequiresUserGesture),
 1133                 "JavaScriptCanPaste":
 1134                     webEngineSettings.testAttribute(
 1135                         QWebEngineSettings.JavascriptCanPaste),
 1136                 "WebRTCPublicInterfacesOnly":
 1137                     webEngineSettings.testAttribute(
 1138                         QWebEngineSettings.WebRTCPublicInterfacesOnly),
 1139             })
 1140         except AttributeError:
 1141             pass
 1142         try:
 1143             # Qt 5.12+
 1144             cls.webBrowserDefaults.update({
 1145                 "DnsPrefetchEnabled":
 1146                     webEngineSettings.testAttribute(
 1147                         QWebEngineSettings.DnsPrefetchEnabled),
 1148             })
 1149         except AttributeError:
 1150             pass
 1151         try:
 1152             # Qt 5.13
 1153             cls.webBrowserDefaults.update({
 1154                 "PdfViewerEnabled":
 1155                     webEngineSettings.testAttribute(
 1156                         QWebEngineSettings.PdfViewerEnabled),
 1157             })
 1158         except AttributeError:
 1159             pass
 1160         
 1161         cls.webEngineSettingsIntitialized = True
 1162     
 1163     webEngineSettingsIntitialized = False
 1164 
 1165     # defaults for system settings
 1166     sysDefaults = {
 1167         "StringEncoding": "utf-8",
 1168         "IOEncoding": "utf-8",
 1169     }
 1170     
 1171     # defaults for the shell settings
 1172     shellDefaults = {
 1173         "LinenoMargin": True,
 1174         "AutoCompletionEnabled": True,
 1175         "CallTipsEnabled": True,
 1176         "WrapEnabled": True,
 1177         "MaxHistoryEntries": 100,
 1178         "HistoryStyle": ShellHistoryStyle.LinuxStyle,
 1179         "HistoryWrap": False,
 1180         "HistoryNavigateByCursor": False,
 1181         "SyntaxHighlightingEnabled": True,
 1182         "ShowStdOutErr": True,
 1183         "UseMonospacedFont": False,
 1184         "MonospacedFont": "Courier,10,-1,5,50,0,0,0,0,0",
 1185         "MarginsFont": "Sans Serif,10,-1,5,50,0,0,0,0,0",
 1186         "LastVirtualEnvironment": "",
 1187         "StartWithMostRecentlyUsedEnvironment": True,
 1188     }
 1189 
 1190     # defaults for Qt related stuff
 1191     qtDefaults = {
 1192         "Qt5TranslationsDir": "",
 1193         "QtToolsDir": "",
 1194         "QtToolsPrefix": "",
 1195         "QtToolsPostfix": "",
 1196         "PyuicIndent": 4,
 1197         "PyuicFromImports": False,
 1198         "PyuicExecute": True,
 1199         "PyQtToolsDir": "",
 1200         "PySide2FromImports": False,
 1201         "PySide2ToolsDir": "",
 1202     }
 1203     
 1204     # defaults for corba related stuff
 1205     corbaDefaults = {
 1206         "omniidl": ""
 1207     }
 1208     
 1209     # defaults for protobuf related stuff
 1210     protobufDefaults = {
 1211         "protoc": "",
 1212         "grpcPython": "",
 1213     }
 1214     
 1215     # defaults for user related stuff
 1216     userDefaults = {
 1217         "Email": "",
 1218         "MailServer": "",
 1219         "Signature": "",
 1220         "MailServerAuthentication": False,
 1221         "MailServerUser": "",
 1222         "MailServerPassword": "",
 1223         "MailServerEncryption": "No",   # valid values: No, SSL, TLS
 1224         "MailServerPort": 25,
 1225         "UseSystemEmailClient": False,
 1226         "UseGoogleMailOAuth2": False,
 1227         "MasterPassword": "",           # stores the password hash
 1228         "UseMasterPassword": False,
 1229         "SavePasswords": False,
 1230     }
 1231     
 1232     # defaults for vcs related stuff
 1233     vcsDefaults = {
 1234         "AutoClose": False,
 1235         "AutoSaveFiles": True,
 1236         "AutoSaveProject": True,
 1237         "AutoUpdate": False,
 1238         "StatusMonitorInterval": 30,
 1239         "MonitorLocalStatus": False,
 1240         "ShowVcsToolbar": True,
 1241     }
 1242     
 1243     # defaults for tasks related stuff
 1244     tasksDefaults = {
 1245         "TasksFixmeMarkers": "FIX" + "ME:",
 1246         "TasksWarningMarkers": "WARN" + "ING:",
 1247         "TasksTodoMarkers": "TO" + "DO:",
 1248         "TasksNoteMarkers": "NO" + "TE:",
 1249         "TasksTestMarkers": "TE" + "ST:",
 1250         "TasksDocuMarkers": "DO" + "CU:",
 1251         # needed to keep it from being recognized as a task
 1252         "TasksFixmeColor": QColor("#FFA0A0"),
 1253         "TasksWarningColor": QColor("#FFFFA0"),
 1254         "TasksTodoColor": QColor("#A0FFA0"),
 1255         "TasksNoteColor": QColor("#A0A0FF"),
 1256         "TasksTestColor": QColor("#FFD000"),
 1257         "TasksDocuColor": QColor("#FFA0FF"),
 1258         "ClearOnFileClose": True,
 1259     }
 1260     
 1261     # defaults for templates related stuff
 1262     templatesDefaults = {
 1263         "AutoOpenGroups": True,
 1264         "SingleDialog": False,
 1265         "ShowTooltip": False,
 1266         "SeparatorChar": "$",
 1267         "EditorFont": "Monospace,9,-1,5,50,0,0,0,0,0",
 1268     }
 1269     
 1270     # defaults for plugin manager related stuff
 1271     pluginManagerDefaults = {
 1272         "ActivateExternal": True,
 1273         "DownloadPath": "",
 1274         "UpdatesCheckInterval": 3,
 1275         # 0 = off
 1276         # 1 = daily
 1277         # 2 = weekly
 1278         # 3 = monthly
 1279         # 4 = always
 1280         "CheckInstalledOnly": True,
 1281         # list of plug-ins not to shown in the repo dialog
 1282         "HiddenPlugins": [],
 1283         # parameters for housekeeping
 1284         "KeepGenerations": 2,
 1285         "KeepHidden": False,
 1286         "StartupCleanup": True,
 1287     }
 1288     
 1289     # defaults for the printer settings
 1290     graphicsDefaults = {
 1291         "Font": "SansSerif,10,-1,5,50,0,0,0,0,0",
 1292         "DrawingMode": "automatic",
 1293         # automatic - determine mode depending upon desktop scheme
 1294         # black_white - black items on white background
 1295         # white_black - white items on black background
 1296     }
 1297     
 1298     # defaults for the icon editor
 1299     iconEditorDefaults = {
 1300         "IconEditorState": QByteArray(),
 1301     }
 1302     
 1303     # defaults for pyflakes
 1304     pyflakesDefaults = {
 1305         "IncludeInSyntaxCheck": True,
 1306         "IgnoreStarImportWarnings": True,
 1307     }
 1308     
 1309     # defaults for tray starter
 1310     trayStarterDefaults = {
 1311         "TrayStarterIcon": "erict",
 1312         # valid values are: erict, erict-hc,
 1313         #                   erict-bw, erict-bwi
 1314     }
 1315     
 1316     # defaults for geometry
 1317     geometryDefaults = {
 1318         "HelpViewerGeometry": QByteArray(),
 1319         "HelpInspectorGeometry": QByteArray(),
 1320         "WebBrowserGeometry": QByteArray(),
 1321         "IconEditorGeometry": QByteArray(),
 1322         "HexEditorGeometry": QByteArray(),
 1323         "MainGeometry": QByteArray(),
 1324         "MainMaximized": False,
 1325         "WebInspectorGeometry": QByteArray(),
 1326     }
 1327 
 1328     # if true, revert layouts to factory defaults
 1329     resetLayout = False
 1330     
 1331     # defaults for IRC
 1332     ircDefaults = {
 1333         "ShowTimestamps": True,
 1334         "TimestampIncludeDate": False,
 1335         "TimeFormat": "hh:mm",
 1336         "DateFormat": "yyyy-MM-dd",
 1337         
 1338         "NetworkMessageColour": "#000055",
 1339         "ServerMessageColour": "#91640A",
 1340         "ErrorMessageColour": "#FF0000",
 1341         "TimestampColour": "#709070",
 1342         "HyperlinkColour": "#0000FF",
 1343         "ChannelMessageColour": "#000000",
 1344         "OwnNickColour": "#000000",
 1345         "NickColour": "#18B33C",
 1346         "JoinChannelColour": "#72D672",
 1347         "LeaveChannelColour": "#B00000",
 1348         "ChannelInfoColour": "#9E54B3",
 1349         
 1350         "EnableIrcColours": True,
 1351         "IrcColor0": "#FFFF00",
 1352         "IrcColor1": "#000000",
 1353         "IrcColor2": "#000080",
 1354         "IrcColor3": "#008000",
 1355         "IrcColor4": "#FF0000",
 1356         "IrcColor5": "#A52A2A",
 1357         "IrcColor6": "#800080",
 1358         "IrcColor7": "#FF8000",
 1359         "IrcColor8": "#808000",
 1360         "IrcColor9": "#00FF00",
 1361         "IrcColor10": "#008080",
 1362         "IrcColor11": "#00FFFF",
 1363         "IrcColor12": "#0000FF",
 1364         "IrcColor13": "#FFC0CB",
 1365         "IrcColor14": "#A0A0A0",
 1366         "IrcColor15": "#C0C0C0",
 1367         
 1368         "ShowNotifications": True,
 1369         "NotifyJoinPart": True,
 1370         "NotifyMessage": False,
 1371         "NotifyNick": False,
 1372         
 1373         "AutoUserInfoLookup": True,
 1374         "AutoUserInfoMax": 200,
 1375         "AutoUserInfoInterval": 90,
 1376         
 1377         "MarkPositionWhenHidden": True,
 1378         "MarkerLineForegroundColour": "#000000",    # Black on
 1379         "MarkerLineBackgroundColour": "#ffff00",    # Yellow
 1380         
 1381         "AskOnShutdown": True,
 1382     }
 1383     
 1384     # defaults for Hex Editor
 1385     hexEditorDefaults = {
 1386         "HexEditorState": QByteArray(),
 1387         "AddressAreaWidth": 4,
 1388         "ShowAddressArea": True,
 1389         "ShowAsciiArea": True,
 1390         "OpenInOverwriteMode": True,
 1391         "OpenReadOnly": False,
 1392         "HighlightChanges": True,
 1393         "HighlightingBackGround": QColor(0xff, 0xff, 0x99, 0xff),
 1394         "HighlightingForeGround": QColor(Qt.black),
 1395         "SelectionBackGround": QColor("#308cc6"),
 1396         "SelectionForeGround": QColor(Qt.white),
 1397         "AddressAreaBackGround": QColor("#efedec"),
 1398         "AddressAreaForeGround": QColor(Qt.black),
 1399         "RecentNumber": 9,
 1400     }
 1401     if Globals.isWindowsPlatform():
 1402         hexEditorDefaults["Font"] = "Courier,10,-1,5,50,0,0,0,0,0"
 1403     else:
 1404         hexEditorDefaults["Font"] = "Monospace,10,-1,5,50,0,0,0,0,0"
 1405     
 1406     # defaults for Diff colors
 1407     diffColourDefaults = {
 1408         "TextColor": QColor(0, 0, 0),
 1409         "AddedColor": QColor(190, 237, 190),
 1410         "RemovedColor": QColor(237, 190, 190),
 1411         "ReplacedColor": QColor(190, 190, 237),
 1412         "ContextColor": QColor(255, 220, 168),
 1413         "HeaderColor": QColor(237, 237, 190),
 1414         "BadWhitespaceColor": QColor(255, 0, 0, 192),
 1415     }
 1416     
 1417     # defaults for Code Documentation Viewer
 1418     docuViewerDefaults = {
 1419         "ShowInfoAsRichText": False,
 1420         "Provider": "disabled",
 1421         "ShowInfoOnOpenParenthesis": True,
 1422     }
 1423     
 1424     # defaults for conda
 1425     condaDefaults = {
 1426         "CondaExecutable": "",
 1427     }
 1428     
 1429     # defaults for pip
 1430     pipDefaults = {
 1431         "PipSearchIndex": "",           # used by the search command
 1432     }
 1433     
 1434     # defaults for MicroPython
 1435     microPythonDefaults = {
 1436         "SerialTimeout": 2000,          # timeout in milliseconds
 1437         "ReplLineWrap": True,           # wrap the REPL lines
 1438         "SyncTimeAfterConnect": True,
 1439         "ShowHiddenLocal": True,
 1440         "ShowHiddenDevice": True,
 1441         "ChartColorTheme": -1,          # -1 = automatic,
 1442                                         # QChart.ChartTheme otherwise
 1443         "MpyCrossCompiler": "",         # path of the mpy-cross compiler
 1444         "DfuUtilPath": "",              # path of the dfu-util flashing tool
 1445         "IgnoredUnknownDevices": "[]",  # empty list encoded as JSON
 1446         # documentation URLs
 1447         "MicroPythonDocuUrl":
 1448             "https://docs.micropython.org/en/latest/",
 1449         "CircuitPythonDocuUrl":
 1450             "https://circuitpython.readthedocs.io/en/latest/",
 1451         "MicrobitDocuUrl":
 1452             "https://microbit-micropython.readthedocs.io/en/latest/",
 1453         "CalliopeDocuUrl":
 1454             "https://github.com/calliope-mini/calliope-mini-micropython/",
 1455         # MicroPython firmware URLs
 1456         "MicroPythonFirmwareUrl": "http://micropython.org/download/",
 1457         "CircuitPythonFirmwareUrl": "https://circuitpython.org/downloads/",
 1458         "MicrobitFirmwareUrl": "https://microbit.org/guide/firmware/",
 1459         "CalliopeFirmwareUrl":
 1460             "https://github.com/calliope-mini/calliope-mini-micropython/",
 1461     }
 1462     if Globals.isWindowsPlatform():
 1463         microPythonDefaults["ColorScheme"] = "Windows 10"
 1464     elif Globals.isMacPlatform():
 1465         microPythonDefaults["ColorScheme"] = "xterm"
 1466     else:
 1467         microPythonDefaults["ColorScheme"] = "Ubuntu"
 1468 
 1469 
 1470 def readToolGroups(prefClass=Prefs):
 1471     """
 1472     Module function to read the tool groups configuration.
 1473     
 1474     @param prefClass preferences class used as the storage area
 1475     @return list of tuples defing the tool groups
 1476     """
 1477     toolGroups = []
 1478     groups = int(prefClass.settings.value("Toolgroups/Groups", 0))
 1479     for groupIndex in range(groups):
 1480         groupName = prefClass.settings.value(
 1481             "Toolgroups/{0:02d}/Name".format(groupIndex))
 1482         group = [groupName, []]
 1483         items = int(prefClass.settings.value(
 1484             "Toolgroups/{0:02d}/Items".format(groupIndex), 0))
 1485         for ind in range(items):
 1486             menutext = prefClass.settings.value(
 1487                 "Toolgroups/{0:02d}/{1:02d}/Menutext".format(groupIndex, ind))
 1488             icon = prefClass.settings.value(
 1489                 "Toolgroups/{0:02d}/{1:02d}/Icon".format(groupIndex, ind))
 1490             executable = prefClass.settings.value(
 1491                 "Toolgroups/{0:02d}/{1:02d}/Executable".format(
 1492                     groupIndex, ind))
 1493             arguments = prefClass.settings.value(
 1494                 "Toolgroups/{0:02d}/{1:02d}/Arguments".format(groupIndex, ind))
 1495             redirect = prefClass.settings.value(
 1496                 "Toolgroups/{0:02d}/{1:02d}/Redirect".format(groupIndex, ind))
 1497             
 1498             if menutext:
 1499                 if menutext == '--':
 1500                     tool = {
 1501                         'menutext': '--',
 1502                         'icon': '',
 1503                         'executable': '',
 1504                         'arguments': '',
 1505                         'redirect': 'no',
 1506                     }
 1507                     group[1].append(tool)
 1508                 elif executable:
 1509                     tool = {
 1510                         'menutext': menutext,
 1511                         'icon': icon,
 1512                         'executable': executable,
 1513                         'arguments': arguments,
 1514                         'redirect': redirect,
 1515                     }
 1516                     group[1].append(tool)
 1517         toolGroups.append(group)
 1518     currentGroup = int(
 1519         prefClass.settings.value("Toolgroups/Current Group", -1))
 1520     return toolGroups, currentGroup
 1521     
 1522 
 1523 def saveToolGroups(toolGroups, currentGroup, prefClass=Prefs):
 1524     """
 1525     Module function to write the tool groups configuration.
 1526     
 1527     @param toolGroups reference to the list of tool groups
 1528     @param currentGroup index of the currently selected tool group (integer)
 1529     @param prefClass preferences class used as the storage area
 1530     """
 1531     # first step, remove all tool group entries
 1532     prefClass.settings.remove("Toolgroups")
 1533     
 1534     # second step, write the tool group entries
 1535     prefClass.settings.setValue("Toolgroups/Groups", len(toolGroups))
 1536     groupIndex = 0
 1537     for group in toolGroups:
 1538         prefClass.settings.setValue(
 1539             "Toolgroups/{0:02d}/Name".format(groupIndex), group[0])
 1540         prefClass.settings.setValue(
 1541             "Toolgroups/{0:02d}/Items".format(groupIndex), len(group[1]))
 1542         ind = 0
 1543         for tool in group[1]:
 1544             prefClass.settings.setValue(
 1545                 "Toolgroups/{0:02d}/{1:02d}/Menutext".format(groupIndex, ind),
 1546                 tool['menutext'])
 1547             prefClass.settings.setValue(
 1548                 "Toolgroups/{0:02d}/{1:02d}/Icon".format(groupIndex, ind),
 1549                 tool['icon'])
 1550             prefClass.settings.setValue(
 1551                 "Toolgroups/{0:02d}/{1:02d}/Executable".format(
 1552                     groupIndex, ind),
 1553                 tool['executable'])
 1554             prefClass.settings.setValue(
 1555                 "Toolgroups/{0:02d}/{1:02d}/Arguments".format(groupIndex, ind),
 1556                 tool['arguments'])
 1557             prefClass.settings.setValue(
 1558                 "Toolgroups/{0:02d}/{1:02d}/Redirect".format(groupIndex, ind),
 1559                 tool['redirect'])
 1560             ind += 1
 1561         groupIndex += 1
 1562     prefClass.settings.setValue("Toolgroups/Current Group", currentGroup)
 1563     
 1564 
 1565 def initPreferences():
 1566     """
 1567     Module function to initialize the central configuration store.
 1568     """
 1569     from E5Gui.E5Application import e5App
 1570     Prefs.settings = QSettings(
 1571         QSettings.IniFormat, QSettings.UserScope,
 1572         Globals.settingsNameOrganization, Globals.settingsNameGlobal,
 1573         e5App())
 1574     if not Globals.isWindowsPlatform():
 1575         hp = QDir.homePath()
 1576         dn = QDir(hp)
 1577         dn.mkdir(".eric6")
 1578     QCoreApplication.setOrganizationName(Globals.settingsNameOrganization)
 1579     QCoreApplication.setApplicationName(Globals.settingsNameGlobal)
 1580     try:
 1581         Prefs.settings.setAtomicSyncRequired(False)
 1582     except AttributeError:
 1583         # backward compatibility fot Qt < 5.10
 1584         pass
 1585     
 1586     Prefs.settings.value("UI/SingleApplicationMode")
 1587     
 1588 
 1589 def syncPreferences(prefClass=Prefs):
 1590     """
 1591     Module function to sync the preferences to disk.
 1592     
 1593     In addition to syncing, the central configuration store is reinitialized
 1594     as well.
 1595     
 1596     @param prefClass preferences class used as the storage area
 1597     """
 1598     prefClass.settings.setValue("General/Configured", True)
 1599     prefClass.settings.sync()
 1600     
 1601 
 1602 def exportPreferences(prefClass=Prefs):
 1603     """
 1604     Module function to export the current preferences.
 1605     
 1606     @param prefClass preferences class used as the storage area
 1607     """
 1608     filename, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
 1609         None,
 1610         QCoreApplication.translate("Preferences", "Export Preferences"),
 1611         "",
 1612         QCoreApplication.translate(
 1613             "Preferences",
 1614             "Properties File (*.ini);;All Files (*)"),
 1615         None,
 1616         E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
 1617     if filename:
 1618         ext = QFileInfo(filename).suffix()
 1619         if not ext:
 1620             ex = selectedFilter.split("(*")[1].split(")")[0]
 1621             if ex:
 1622                 filename += ex
 1623         settingsFile = prefClass.settings.fileName()
 1624         prefClass.settings = None
 1625         shutil.copy(settingsFile, filename)
 1626         initPreferences()
 1627 
 1628 
 1629 def importPreferences(prefClass=Prefs):
 1630     """
 1631     Module function to import preferences from a file previously saved by
 1632     the export function.
 1633     
 1634     @param prefClass preferences class used as the storage area
 1635     """
 1636     filename = E5FileDialog.getOpenFileName(
 1637         None,
 1638         QCoreApplication.translate("Preferences", "Import Preferences"),
 1639         "",
 1640         QCoreApplication.translate(
 1641             "Preferences",
 1642             "Properties File (*.ini);;All Files (*)"))
 1643     if filename:
 1644         settingsFile = prefClass.settings.fileName()
 1645         shutil.copy(filename, settingsFile)
 1646         initPreferences()
 1647 
 1648 
 1649 def isConfigured(prefClass=Prefs):
 1650     """
 1651     Module function to check, if the the application has been configured.
 1652     
 1653     @param prefClass preferences class used as the storage area
 1654     @return flag indicating the configured status (boolean)
 1655     """
 1656     return toBool(prefClass.settings.value("General/Configured", False))
 1657     
 1658 
 1659 def initRecentSettings():
 1660     """
 1661     Module function to initialize the central configuration store for recently
 1662     opened files and projects.
 1663     
 1664     This function is called once upon import of the module.
 1665     """
 1666     Prefs.rsettings = QSettings(
 1667         QSettings.IniFormat, QSettings.UserScope,
 1668         Globals.settingsNameOrganization, Globals.settingsNameRecent)
 1669     
 1670 
 1671 def getVarFilters(prefClass=Prefs):
 1672     """
 1673     Module function to retrieve the variables filter settings.
 1674     
 1675     @param prefClass preferences class used as the storage area
 1676     @return a tuple defining the variables filter
 1677     """
 1678     localsFilter = ast.literal_eval(prefClass.settings.value(
 1679         "Variables/LocalsFilter", prefClass.varDefaults["LocalsFilter"]))
 1680     globalsFilter = ast.literal_eval(prefClass.settings.value(
 1681         "Variables/GlobalsFilter", prefClass.varDefaults["GlobalsFilter"]))
 1682     return (localsFilter, globalsFilter)
 1683     
 1684 
 1685 def setVarFilters(filters, prefClass=Prefs):
 1686     """
 1687     Module function to store the variables filter settings.
 1688     
 1689     @param filters variable filters to set
 1690     @param prefClass preferences class used as the storage area
 1691     """
 1692     prefClass.settings.setValue("Variables/LocalsFilter", str(filters[0]))
 1693     prefClass.settings.setValue("Variables/GlobalsFilter", str(filters[1]))
 1694     
 1695 
 1696 def getDebugger(key, prefClass=Prefs):
 1697     """
 1698     Module function to retrieve the debugger settings.
 1699     
 1700     @param key the key of the value to get
 1701     @param prefClass preferences class used as the storage area
 1702     @return the requested debugger setting
 1703     """
 1704     if key in ["RemoteDbgEnabled", "PassiveDbgEnabled",
 1705                "AutomaticReset", "DebugEnvironmentReplace",
 1706                "PythonRedirect", "PythonNoEncoding",
 1707                "Python3Redirect", "Python3NoEncoding",
 1708                "RubyRedirect",
 1709                "ConsoleDbgEnabled", "PathTranslation",
 1710                "Autosave", "ThreeStateBreakPoints",
 1711                "SuppressClientExit", "BreakAlways",
 1712                "AutoViewSourceCode", "ShowExceptionInShell",
 1713                ]:
 1714         return toBool(prefClass.settings.value(
 1715             "Debugger/" + key, prefClass.debuggerDefaults[key]))
 1716     elif key in ["PassiveDbgPort", "MaxVariableSize", "RecentNumber"]:
 1717         return int(
 1718             prefClass.settings.value(
 1719                 "Debugger/" + key, prefClass.debuggerDefaults[key]))
 1720     elif key in ["AllowedHosts"]:
 1721         return toList(
 1722             prefClass.settings.value(
 1723                 "Debugger/" + key, prefClass.debuggerDefaults[key]))
 1724     elif key in ["PythonInterpreter", "Python3Interpreter"]:
 1725         # This code is here to ensure backward compatibility.
 1726         # Keep "PythonInterpreter" for backward compatibility.
 1727         newKey = "Python3VirtualEnv"
 1728         venvName = prefClass.settings.value(
 1729             "Debugger/" + newKey, prefClass.debuggerDefaults[newKey])
 1730         if venvName:
 1731             try:
 1732                 from E5Gui.E5Application import e5App
 1733                 virtualenvManager = e5App().getObject("VirtualEnvManager")
 1734             except KeyError:
 1735                 from VirtualEnv.VirtualenvManager import VirtualenvManager
 1736                 virtualenvManager = VirtualenvManager()
 1737             interpreter = virtualenvManager.getVirtualenvInterpreter(venvName)
 1738         else:
 1739             interpreter = ""
 1740         if not interpreter:
 1741             return sys.executable
 1742         return interpreter
 1743     elif key == "DebugClientType3":
 1744         debugClientType = prefClass.settings.value(
 1745             "Debugger/" + key, prefClass.debuggerDefaults[key])
 1746         # Correct obsolete entry "threaded"
 1747         if debugClientType == 'threaded':
 1748             return "standard"
 1749         else:
 1750             return debugClientType
 1751     elif key == "PythonExtensions":
 1752         # we don't support Python2 anymore
 1753         return ""
 1754     elif key == "Python2VirtualEnv":
 1755         # we don't support Python2 anymore
 1756         return ""
 1757     else:
 1758         return prefClass.settings.value(
 1759             "Debugger/" + key, prefClass.debuggerDefaults[key])
 1760     
 1761 
 1762 def setDebugger(key, value, prefClass=Prefs):
 1763     """
 1764     Module function to store the debugger settings.
 1765     
 1766     @param key the key of the setting to be set
 1767     @param value the value to be set
 1768     @param prefClass preferences class used as the storage area
 1769     """
 1770     prefClass.settings.setValue("Debugger/" + key, value)
 1771 
 1772 
 1773 def getPython(key, prefClass=Prefs):
 1774     """
 1775     Module function to retrieve the Python settings.
 1776     
 1777     @param key the key of the value to get
 1778     @param prefClass preferences class used as the storage area
 1779     @return the requested debugger setting
 1780     """
 1781     if key == "PythonExtensions":
 1782         # we don't support Python2 anymore
 1783         return []
 1784     
 1785     if key == "Python3Extensions":
 1786         exts = []
 1787         for ext in getDebugger(key, prefClass).split():
 1788             if ext.startswith("."):
 1789                 exts.append(ext)
 1790             else:
 1791                 exts.append(".{0}".format(ext))
 1792         return exts
 1793     
 1794     return None
 1795 
 1796 
 1797 def setPython(key, value, prefClass=Prefs):
 1798     """
 1799     Module function to store the Python settings.
 1800     
 1801     @param key the key of the setting to be set
 1802     @param value the value to be set
 1803     @param prefClass preferences class used as the storage area
 1804     """
 1805     if key == "Python3Extensions":
 1806         setDebugger(key, value, prefClass)
 1807 
 1808 
 1809 def getUILanguage(prefClass=Prefs):
 1810     """
 1811     Module function to retrieve the language for the user interface.
 1812     
 1813     @param prefClass preferences class used as the storage area
 1814     @return the language for the UI
 1815     """
 1816     lang = prefClass.settings.value("UI/Language",
 1817                                     prefClass.uiDefaults["Language"])
 1818     if lang == "None" or lang == "" or lang is None:
 1819         return None
 1820     else:
 1821         return lang
 1822     
 1823 
 1824 def setUILanguage(lang, prefClass=Prefs):
 1825     """
 1826     Module function to store the language for the user interface.
 1827     
 1828     @param lang the language
 1829     @param prefClass preferences class used as the storage area
 1830     """
 1831     if lang is None:
 1832         prefClass.settings.setValue("UI/Language", "None")
 1833     else:
 1834         prefClass.settings.setValue("UI/Language", lang)
 1835 
 1836 
 1837 def getViewManager(prefClass=Prefs):
 1838     """
 1839     Module function to retrieve the selected viewmanager type.
 1840     
 1841     @param prefClass preferences class used as the storage area
 1842     @return the viewmanager type
 1843     """
 1844     return prefClass.settings.value(
 1845         "UI/ViewManager", prefClass.uiDefaults["ViewManager"])
 1846     
 1847 
 1848 def setViewManager(vm, prefClass=Prefs):
 1849     """
 1850     Module function to store the selected viewmanager type.
 1851     
 1852     @param vm the viewmanager type
 1853     @param prefClass preferences class used as the storage area
 1854     """
 1855     prefClass.settings.setValue("UI/ViewManager", vm)
 1856 
 1857 
 1858 def getUI(key, prefClass=Prefs):
 1859     """
 1860     Module function to retrieve the various UI settings.
 1861     
 1862     @param key the key of the value to get
 1863     @param prefClass preferences class used as the storage area
 1864     @return the requested UI setting
 1865     """
 1866     if key in ["BrowsersListFoldersFirst", "BrowsersHideNonPublic",
 1867                "BrowsersListContentsByOccurrence", "BrowsersListHiddenFiles",
 1868                "LogViewerAutoRaise",
 1869                "SingleApplicationMode", "TabViewManagerFilenameOnly",
 1870                "ShowFilePreview", "ShowFilePreviewJS", "ShowFilePreviewSSI",
 1871                "CaptionShowsFilename", "ShowSplash",
 1872                "SplitOrientationVertical",
 1873                "UseProxy", "UseSystemProxy", "UseHttpProxyForAll",
 1874                "RequestDownloadFilename",
 1875                "CheckErrorLog", "NotificationsEnabled", "DynamicOnlineCheck",
 1876                "OpenCrashSessionOnStartup", "CrashSessionEnabled",
 1877                "ShowCodeDocumentationViewer", "ShowPyPIPackageManager",
 1878                "ShowCondaPackageManager", "ShowCooperation", "ShowIrc",
 1879                "ShowTemplateViewer", "ShowFileBrowser", "ShowSymbolsViewer",
 1880                "ShowNumbersViewer", "ShowMicroPython", "UseNativeMenuBar"]:
 1881         return toBool(prefClass.settings.value(
 1882             "UI/" + key, prefClass.uiDefaults[key]))
 1883     elif key in ["TabViewManagerFilenameLength", "CaptionFilenameLength",
 1884                  "ProxyPort/Http", "ProxyPort/Https", "ProxyPort/Ftp",
 1885                  "ProxyType/Ftp", "OpenOnStartup",
 1886                  "PerformVersionCheck", "RecentNumber", "NotificationTimeout",
 1887                  "SidebarDelay", "KeyboardInputInterval",
 1888                  "BackgroundServiceProcesses", "MinimumMessageTypeSeverity"]:
 1889         return int(prefClass.settings.value(
 1890             "UI/" + key, prefClass.uiDefaults[key]))
 1891     elif key in ["ProxyPassword/Http", "ProxyPassword/Https",
 1892                  "ProxyPassword/Ftp", ]:
 1893         from Utilities.crypto import pwConvert
 1894         return pwConvert(
 1895             prefClass.settings.value("UI/" + key, prefClass.uiDefaults[key]),
 1896             encode=False)
 1897     elif key in ["LogStdErrColour"]:
 1898         col = prefClass.settings.value("UI/" + key)
 1899         if col is not None:
 1900             return QColor(col)
 1901         else:
 1902             return prefClass.uiDefaults[key]
 1903     elif key in "ViewProfiles2":
 1904         profilesStr = prefClass.settings.value("UI/ViewProfiles2")
 1905         if profilesStr is None:
 1906             # use the defaults
 1907             viewProfiles = prefClass.uiDefaults["ViewProfiles2"]
 1908         else:
 1909             viewProfiles = {}
 1910             profiles = json.loads(profilesStr)
 1911             for name in ["edit", "debug"]:
 1912                 viewProfiles[name] = [
 1913                     QByteArray.fromBase64(profiles[name][0].encode("utf-8")),
 1914                     profiles[name][1][:],
 1915                     []
 1916                 ]
 1917                 for bs in profiles[name][2]:
 1918                     viewProfiles[name][2].append(
 1919                         QByteArray.fromBase64(bs.encode("utf-8")))
 1920         return viewProfiles
 1921     elif key in ["ToolbarManagerState", "PreviewSplitterState"]:
 1922         state = prefClass.settings.value("UI/" + key)
 1923         if state is not None:
 1924             return state
 1925         else:
 1926             return prefClass.uiDefaults[key]
 1927     elif key in ["VersionsUrls6"]:
 1928         urls = toList(
 1929             prefClass.settings.value("UI/" + key, prefClass.uiDefaults[key]))
 1930         if len(urls) == 0:
 1931             return prefClass.uiDefaults[key]
 1932         else:
 1933             return urls
 1934     elif key in ["LogViewerStdoutFilter", "LogViewerStderrFilter",
 1935                  "LogViewerStdxxxFilter", "TextMimeTypes"]:
 1936         return toList(
 1937             prefClass.settings.value("UI/" + key, prefClass.uiDefaults[key]))
 1938     else:
 1939         return prefClass.settings.value("UI/" + key, prefClass.uiDefaults[key])
 1940     
 1941 
 1942 def setUI(key, value, prefClass=Prefs):
 1943     """
 1944     Module function to store the various UI settings.
 1945     
 1946     @param key the key of the setting to be set
 1947     @param value the value to be set
 1948     @param prefClass preferences class used as the storage area
 1949     """
 1950     if key == "ViewProfiles2":
 1951         profiles = {}
 1952         for name in ["edit", "debug"]:
 1953             profiles[name] = [
 1954                 bytes(value[name][0].toBase64()).decode(),
 1955                 value[name][1][:],
 1956                 []
 1957             ]
 1958             for ba in value[name][2]:
 1959                 profiles[name][2].append(bytes(ba.toBase64()).decode())
 1960         prefClass.settings.setValue("UI/" + key, json.dumps(profiles))
 1961     elif key == "LogStdErrColour":
 1962         prefClass.settings.setValue("UI/" + key, value.name())
 1963     elif key in ["ProxyPassword/Http", "ProxyPassword/Https",
 1964                  "ProxyPassword/Ftp", ]:
 1965         from Utilities.crypto import pwConvert
 1966         prefClass.settings.setValue("UI/" + key, pwConvert(value, encode=True))
 1967     else:
 1968         prefClass.settings.setValue("UI/" + key, value)
 1969     
 1970 
 1971 def getIcons(key, prefClass=Prefs):
 1972     """
 1973     Module function to retrieve the various Icons settings.
 1974     
 1975     @param key the key of the value to get
 1976     @param prefClass preferences class used as the storage area
 1977     @return the requested Icons setting
 1978     """
 1979     dirlist = prefClass.settings.value("UI/Icons/" + key)
 1980     if dirlist is not None:
 1981         return dirlist
 1982     else:
 1983         return prefClass.iconsDefaults[key]
 1984     
 1985     if key in ["Path"]:
 1986         return toList(prefClass.settings.value(
 1987             "UI/Icons/" + key, prefClass.iconsDefaults[key]))
 1988     else:
 1989         return prefClass.settings.value(
 1990             "UI/Icons/" + key, prefClass.iconsDefaults[key])
 1991 
 1992 
 1993 def setIcons(key, value, prefClass=Prefs):
 1994     """
 1995     Module function to store the various Icons settings.
 1996     
 1997     @param key the key of the setting to be set
 1998     @param value the value to be set
 1999     @param prefClass preferences class used as the storage area
 2000     """
 2001     prefClass.settings.setValue("UI/Icons/" + key, value)
 2002     
 2003 
 2004 def getCooperation(key, prefClass=Prefs):
 2005     """
 2006     Module function to retrieve the various Cooperation settings.
 2007     
 2008     @param key the key of the value to get
 2009     @param prefClass preferences class used as the storage area
 2010     @return the requested UI setting
 2011     """
 2012     if key in ["AutoStartServer", "TryOtherPorts", "AutoAcceptConnections"]:
 2013         return toBool(prefClass.settings.value(
 2014             "Cooperation/" + key, prefClass.cooperationDefaults[key]))
 2015     elif key in ["ServerPort", "MaxPortsToTry"]:
 2016         return int(prefClass.settings.value(
 2017             "Cooperation/" + key, prefClass.cooperationDefaults[key]))
 2018     elif key in ["BannedUsers"]:
 2019         return toList(prefClass.settings.value(
 2020             "Cooperation/" + key, prefClass.cooperationDefaults[key]))
 2021     else:
 2022         return prefClass.settings.value(
 2023             "Cooperation/" + key, prefClass.cooperationDefaults[key])
 2024     
 2025 
 2026 def setCooperation(key, value, prefClass=Prefs):
 2027     """
 2028     Module function to store the various Cooperation settings.
 2029     
 2030     @param key the key of the setting to be set
 2031     @param value the value to be set
 2032     @param prefClass preferences class used as the storage area
 2033     """
 2034     prefClass.settings.setValue("Cooperation/" + key, value)
 2035 
 2036 
 2037 def getEditor(key, prefClass=Prefs):
 2038     """
 2039     Module function to retrieve the various editor settings.
 2040     
 2041     @param key the key of the value to get
 2042     @param prefClass preferences class used as the storage area
 2043     @return the requested editor setting
 2044     """
 2045     if key in ["DefaultEncoding", "DefaultOpenFilter", "DefaultSaveFilter",
 2046                "SpellCheckingDefaultLanguage", "SpellCheckingPersonalWordList",
 2047                "SpellCheckingPersonalExcludeList",
 2048                "PreviewMarkdownHTMLFormat", "PreviewRestDocutilsHTMLFormat"]:
 2049         return prefClass.settings.value(
 2050             "Editor/" + key, prefClass.editorDefaults[key])
 2051     elif key in ["AutosaveInterval", "TabWidth", "IndentWidth",
 2052                  "FoldingStyle", "WarnFilesize", "EdgeMode", "EdgeColumn",
 2053                  "CaretWidth", "CaretLineFrameWidth", "AutoCompletionSource",
 2054                  "AutoCompletionThreshold", "AutoCompletionTimeout",
 2055                  "AutoCompletionCacheSize", "AutoCompletionCacheTime",
 2056                  "AutoCompletionWatchdogTime", "AutoCompletionMaxLines",
 2057                  "AutoCompletionMaxChars", "CallTipsVisible",
 2058                  "CallTipsStyle", "MarkOccurrencesTimeout", "SearchRegexpMode",
 2059                  "AutoSpellCheckChunkSize", "SpellCheckingMinWordSize",
 2060                  "PostScriptLevel", "EOLMode", "ZoomFactor", "WhitespaceSize",
 2061                  "OnlineSyntaxCheckInterval", "OnlineChangeTraceInterval",
 2062                  "WrapLongLinesMode", "WrapVisualFlag", "WrapIndentMode",
 2063                  "WrapStartIndent", "CallTipsPosition", "VirtualSpaceOptions",
 2064                  "PreviewRefreshWaitTimer"]:
 2065         return int(prefClass.settings.value(
 2066             "Editor/" + key, prefClass.editorDefaults[key]))
 2067     elif key in ["AdditionalOpenFilters", "AdditionalSaveFilters",
 2068                  "PreviewMarkdownFileNameExtensions",
 2069                  "PreviewRestFileNameExtensions",
 2070                  "PreviewHtmlFileNameExtensions",
 2071                  "PreviewQssFileNameExtensions",
 2072                  "FullSpellCheckExtensions"]:
 2073         return toList(prefClass.settings.value(
 2074             "Editor/" + key, prefClass.editorDefaults[key]))
 2075     elif key in ["PythonBadIndentation"]:
 2076         value = prefClass.settings.value(
 2077             "Editor/" + key, prefClass.editorDefaults[key])
 2078         if value in ["true", "True"]:
 2079             value = 1
 2080         elif value in ["false", "False"]:
 2081             value = 0
 2082         return QsciLexerPython.IndentationWarning(int(value))
 2083     elif key == "TabIndentOverride":
 2084         overrideStr = prefClass.settings.value(
 2085             "Editor/" + key, prefClass.editorDefaults[key])
 2086         if overrideStr:
 2087             return json.loads(overrideStr)
 2088         else:
 2089             return {}
 2090     else:
 2091         return toBool(prefClass.settings.value(
 2092             "Editor/" + key, prefClass.editorDefaults[key]))
 2093     
 2094 
 2095 def setEditor(key, value, prefClass=Prefs):
 2096     """
 2097     Module function to store the various editor settings.
 2098     
 2099     @param key the key of the setting to be set
 2100     @param value the value to be set
 2101     @param prefClass preferences class used as the storage area
 2102     """
 2103     if key == "TabIndentOverride":
 2104         prefClass.settings.setValue("Editor/" + key, json.dumps(value))
 2105     else:
 2106         prefClass.settings.setValue("Editor/" + key, value)
 2107     
 2108 
 2109 def getEditorColour(key, prefClass=Prefs):
 2110     """
 2111     Module function to retrieve the various editor marker colours.
 2112     
 2113     @param key the key of the value to get
 2114     @param prefClass preferences class used as the storage area
 2115     @return the requested editor colour
 2116     """
 2117     col = prefClass.settings.value("Editor/Colour/" + key)
 2118     if col is not None:
 2119         if len(col) == 9:
 2120             # color string with alpha
 2121             return QColor.fromRgba(int(col[1:], 16))
 2122         else:
 2123             return QColor(col)
 2124     else:
 2125         # palette based defaults here because of Qt5
 2126         if key == "EditAreaForeground":
 2127             return QApplication.palette().color(QPalette.Active, QPalette.Base)
 2128         elif key == "EditAreaBackground":
 2129             return QApplication.palette().color(QPalette.Active, QPalette.Text)
 2130         else:
 2131             return prefClass.editorColourDefaults[key]
 2132     
 2133 
 2134 def setEditorColour(key, value, prefClass=Prefs):
 2135     """
 2136     Module function to store the various editor marker colours.
 2137     
 2138     @param key the key of the colour to be set
 2139     @param value the colour to be set
 2140     @param prefClass preferences class used as the storage area
 2141     """
 2142     if value.alpha() < 255:
 2143         val = "#{0:8x}".format(value.rgba())
 2144     else:
 2145         val = value.name()
 2146     prefClass.settings.setValue("Editor/Colour/" + key, val)
 2147     
 2148 
 2149 def getEditorOtherFonts(key, prefClass=Prefs):
 2150     """
 2151     Module function to retrieve the various editor fonts except the lexer
 2152     fonts.
 2153     
 2154     @param key the key of the value to get
 2155     @param prefClass preferences class used as the storage area
 2156     @return the requested editor font (QFont)
 2157     """
 2158     f = QFont()
 2159     f.fromString(prefClass.settings.value(
 2160         "Editor/Other Fonts/" + key, prefClass.editorOtherFontsDefaults[key]))
 2161     return f
 2162     
 2163 
 2164 def setEditorOtherFonts(key, font, prefClass=Prefs):
 2165     """
 2166     Module function to store the various editor fonts except the lexer fonts.
 2167     
 2168     @param key the key of the font to be set
 2169     @param font the font to be set (QFont)
 2170     @param prefClass preferences class used as the storage area
 2171     """
 2172     prefClass.settings.setValue("Editor/Other Fonts/" + key, font.toString())
 2173     
 2174 
 2175 def getEditorAPI(language, projectType="", prefClass=Prefs):
 2176     """
 2177     Module function to retrieve the various lists of API files.
 2178     
 2179     @param language language of the API list
 2180     @type str
 2181     @param projectType project type of the API list
 2182     @type str
 2183     @param prefClass preferences class used as the storage area
 2184     @type Prefs
 2185     @return requested list of API files
 2186     @rtype list of str
 2187     """
 2188     if projectType:
 2189         key = "{0}_{1}".format(language, projectType)
 2190     else:
 2191         key = language
 2192     apis = prefClass.settings.value("Editor/APIs/" + key)
 2193     if apis is not None:
 2194         if len(apis) and apis[0] == "":
 2195             return []
 2196         else:
 2197             return apis
 2198     else:
 2199         if projectType:
 2200             # try again without project type
 2201             return getEditorAPI(language, prefClass=prefClass)
 2202         
 2203         return []
 2204     
 2205 
 2206 def setEditorAPI(language, projectType, apilist, prefClass=Prefs):
 2207     """
 2208     Module function to store the various lists of API files.
 2209     
 2210     @param language language of the API list
 2211     @type str
 2212     @param projectType project type of the API list
 2213     @type str
 2214     @param apilist list of API files
 2215     @type list of str
 2216     @param prefClass preferences class used as the storage area
 2217     @type Prefs
 2218     """
 2219     if projectType:
 2220         key = "{0}_{1}".format(language, projectType)
 2221     else:
 2222         key = language
 2223     prefClass.settings.setValue("Editor/APIs/" + key, apilist)
 2224     
 2225 
 2226 def getEditorKeywords(key, prefClass=Prefs):
 2227     """
 2228     Module function to retrieve the various lists of language keywords.
 2229     
 2230     @param key the key of the value to get
 2231     @param prefClass preferences class used as the storage area
 2232     @return the requested list of language keywords (list of strings)
 2233     """
 2234     keywords = prefClass.settings.value("Editor/Keywords/" + key)
 2235     if keywords is not None:
 2236         return keywords
 2237     else:
 2238         return []
 2239     
 2240 
 2241 def setEditorKeywords(key, keywordsLists, prefClass=Prefs):
 2242     """
 2243     Module function to store the various lists of language keywords.
 2244     
 2245     @param key the key of the api to be set
 2246     @param keywordsLists the list of language keywords (list of strings)
 2247     @param prefClass preferences class used as the storage area
 2248     """
 2249     prefClass.settings.setValue("Editor/Keywords/" + key, keywordsLists)
 2250     
 2251 
 2252 def getEditorLexerAssocs(prefClass=Prefs):
 2253     """
 2254     Module function to retrieve all lexer associations.
 2255     
 2256     @param prefClass preferences class used as the storage area
 2257     @return a reference to the list of lexer associations
 2258         (dictionary of strings)
 2259     """
 2260     editorLexerAssoc = {}
 2261     prefClass.settings.beginGroup("Editor/LexerAssociations")
 2262     keyList = prefClass.settings.childKeys()
 2263     prefClass.settings.endGroup()
 2264     
 2265     import QScintilla.Lexers
 2266     editorLexerAssocDefaults = QScintilla.Lexers.getDefaultLexerAssociations()
 2267     
 2268     if len(keyList) == 0:
 2269         # build from scratch
 2270         for key in list(editorLexerAssocDefaults.keys()):
 2271             editorLexerAssoc[key] = editorLexerAssocDefaults[key]
 2272     else:
 2273         for key in keyList:
 2274             if key in editorLexerAssocDefaults:
 2275                 defaultValue = editorLexerAssocDefaults[key]
 2276             else:
 2277                 defaultValue = ""
 2278             editorLexerAssoc[key] = prefClass.settings.value(
 2279                 "Editor/LexerAssociations/" + key, defaultValue)
 2280         
 2281         # check for new default lexer associations
 2282         for key in list(editorLexerAssocDefaults.keys()):
 2283             if key not in editorLexerAssoc:
 2284                 editorLexerAssoc[key] = editorLexerAssocDefaults[key]
 2285     return editorLexerAssoc
 2286     
 2287 
 2288 def setEditorLexerAssocs(assocs, prefClass=Prefs):
 2289     """
 2290     Module function to retrieve all lexer associations.
 2291     
 2292     @param assocs dictionary of lexer associations to be set
 2293     @param prefClass preferences class used as the storage area
 2294     """
 2295     # first remove lexer associations that no longer exist, than save the rest
 2296     prefClass.settings.beginGroup("Editor/LexerAssociations")
 2297     keyList = prefClass.settings.childKeys()
 2298     prefClass.settings.endGroup()
 2299     for key in keyList:
 2300         if key not in assocs:
 2301             prefClass.settings.remove("Editor/LexerAssociations/" + key)
 2302     for key in assocs:
 2303         prefClass.settings.setValue(
 2304             "Editor/LexerAssociations/" + key, assocs[key])
 2305     
 2306 
 2307 def getEditorLexerAssoc(filename, prefClass=Prefs):
 2308     """
 2309     Module function to retrieve a lexer association.
 2310     
 2311     @param filename filename used to determine the associated lexer language
 2312         (string)
 2313     @param prefClass preferences class used as the storage area
 2314     @return the requested lexer language (string)
 2315     """
 2316     for pattern, language in list(getEditorLexerAssocs().items()):
 2317         if fnmatch.fnmatch(filename, pattern):
 2318             return language
 2319     
 2320     return ""
 2321     
 2322 
 2323 def getEditorTyping(key, prefClass=Prefs):
 2324     """
 2325     Module function to retrieve the various editor typing settings.
 2326     
 2327     @param key the key of the value to get
 2328     @param prefClass preferences class used as the storage area
 2329     @return the requested editor setting
 2330     """
 2331     return toBool(prefClass.settings.value(
 2332         "Editor/Typing/" + key, prefClass.editorTypingDefaults[key]))
 2333     
 2334 
 2335 def setEditorTyping(key, value, prefClass=Prefs):
 2336     """
 2337     Module function to store the various editor typing settings.
 2338     
 2339     @param key the key of the setting to be set
 2340     @param value the value to be set
 2341     @param prefClass preferences class used as the storage area
 2342     """
 2343     prefClass.settings.setValue("Editor/Typing/" + key, value)
 2344     
 2345 
 2346 def getEditorExporter(key, prefClass=Prefs):
 2347     """
 2348     Module function to retrieve the various editor exporters settings.
 2349     
 2350     @param key the key of the value to get
 2351     @param prefClass preferences class used as the storage area
 2352     @return the requested editor setting
 2353     """
 2354     if key in ["RTF/Font"]:
 2355         f = QFont()
 2356         f.fromString(prefClass.settings.value(
 2357             "Editor/Exporters/" + key, prefClass.editorExporterDefaults[key]))
 2358         return f
 2359     elif key in ["HTML/WYSIWYG", "HTML/Folding", "HTML/OnlyStylesUsed",
 2360                  "HTML/FullPathAsTitle", "HTML/UseTabs", "RTF/WYSIWYG",
 2361                  "RTF/UseTabs", "TeX/OnlyStylesUsed", "TeX/FullPathAsTitle",
 2362                  "ODT/WYSIWYG", "ODT/OnlyStylesUsed", "ODT/UseTabs"]:
 2363         return toBool(prefClass.settings.value(
 2364             "Editor/Exporters/" + key, prefClass.editorExporterDefaults[key]))
 2365     elif key in ["PDF/Magnification", "PDF/MarginLeft", "PDF/MarginRight",
 2366                  "PDF/MarginTop", "PDF/MarginBottom"]:
 2367         return int(prefClass.settings.value(
 2368             "Editor/Exporters/" + key, prefClass.editorExporterDefaults[key]))
 2369     else:
 2370         return prefClass.settings.value(
 2371             "Editor/Exporters/" + key, prefClass.editorExporterDefaults[key])
 2372 
 2373 
 2374 def setEditorExporter(key, value, prefClass=Prefs):
 2375     """
 2376     Module function to store the various editor exporters settings.
 2377     
 2378     @param key the key of the setting to be set
 2379     @param value the value to be set
 2380     @param prefClass preferences class used as the storage area
 2381     """
 2382     if key in ["RTF/Font"]:
 2383         prefClass.settings.setValue(
 2384             "Editor/Exporters/" + key, value.toString())
 2385     else:
 2386         prefClass.settings.setValue("Editor/Exporters/" + key, value)
 2387     
 2388 
 2389 def getPrinter(key, prefClass=Prefs):
 2390     """
 2391     Module function to retrieve the various printer settings.
 2392     
 2393     @param key the key of the value to get
 2394     @param prefClass preferences class used as the storage area
 2395     @return the requested printer setting
 2396     """
 2397     if key in ["ColorMode", "FirstPageFirst"]:
 2398         return toBool(prefClass.settings.value(
 2399             "Printer/" + key, prefClass.printerDefaults[key]))
 2400     elif key in ["Magnification", "Orientation", "PageSize", "Resolution"]:
 2401         return int(prefClass.settings.value(
 2402             "Printer/" + key, prefClass.printerDefaults[key]))
 2403     elif key in ["LeftMargin", "RightMargin", "TopMargin", "BottomMargin"]:
 2404         return float(prefClass.settings.value(
 2405             "Printer/" + key, prefClass.printerDefaults[key]))
 2406     elif key in ["HeaderFont"]:
 2407         f = QFont()
 2408         f.fromString(prefClass.settings.value(
 2409             "Printer/" + key, prefClass.printerDefaults[key]))
 2410         return f
 2411     else:
 2412         return prefClass.settings.value(
 2413             "Printer/" + key, prefClass.printerDefaults[key])
 2414 
 2415 
 2416 def setPrinter(key, value, prefClass=Prefs):
 2417     """
 2418     Module function to store the various printer settings.
 2419     
 2420     @param key the key of the setting to be set
 2421     @param value the value to be set
 2422     @param prefClass preferences class used as the storage area
 2423     """
 2424     if key in ["HeaderFont"]:
 2425         prefClass.settings.setValue("Printer/" + key, value.toString())
 2426     else:
 2427         prefClass.settings.setValue("Printer/" + key, value)
 2428 
 2429 
 2430 def getShell(key, prefClass=Prefs):
 2431     """
 2432     Module function to retrieve the various shell settings.
 2433     
 2434     @param key the key of the value to get
 2435     @param prefClass preferences class used as the storage area
 2436     @return the requested shell setting
 2437     """
 2438     if key in ["MonospacedFont", "MarginsFont"]:
 2439         f = QFont()
 2440         f.fromString(prefClass.settings.value(
 2441             "Shell/" + key, prefClass.shellDefaults[key]))
 2442         return f
 2443     elif key in ["MaxHistoryEntries"]:
 2444         return int(prefClass.settings.value(
 2445             "Shell/" + key, prefClass.shellDefaults[key]))
 2446     elif key in ["HistoryStyle"]:
 2447         return ShellHistoryStyle(int(prefClass.settings.value(
 2448             "Shell/" + key, prefClass.shellDefaults[key].value)))
 2449     elif key in ["LastVirtualEnvironment"]:
 2450         return prefClass.settings.value(
 2451             "Shell/" + key, prefClass.shellDefaults[key])
 2452     else:
 2453         return toBool(prefClass.settings.value(
 2454             "Shell/" + key, prefClass.shellDefaults[key]))
 2455 
 2456 
 2457 def setShell(key, value, prefClass=Prefs):
 2458     """
 2459     Module function to store the various shell settings.
 2460     
 2461     @param key the key of the setting to be set
 2462     @param value the value to be set
 2463     @param prefClass preferences class used as the storage area
 2464     """
 2465     if key in ["MonospacedFont", "MarginsFont"]:
 2466         prefClass.settings.setValue("Shell/" + key, value.toString())
 2467     elif key in ["HistoryStyle"]:
 2468         prefClass.settings.setValue("Shell/" + key, value.value)
 2469     else:
 2470         prefClass.settings.setValue("Shell/" + key, value)
 2471 
 2472 
 2473 def getProject(key, prefClass=Prefs):
 2474     """
 2475     Module function to retrieve the various project handling settings.
 2476     
 2477     @param key the key of the value to get
 2478     @param prefClass preferences class used as the storage area
 2479     @return the requested project setting
 2480     """
 2481     if key in ["RecentNumber"]:
 2482         return int(prefClass.settings.value(
 2483             "Project/" + key, prefClass.projectDefaults[key]))
 2484     elif key in ["DebugClientsHistory", "DebuggerInterpreterHistory"]:
 2485         return toList(prefClass.settings.value(
 2486             "Project/" + key, prefClass.projectDefaults[key]))
 2487     else:
 2488         return toBool(prefClass.settings.value(
 2489             "Project/" + key, prefClass.projectDefaults[key]))
 2490     
 2491 
 2492 def setProject(key, value, prefClass=Prefs):
 2493     """
 2494     Module function to store the various project handling settings.
 2495     
 2496     @param key the key of the setting to be set
 2497     @param value the value to be set
 2498     @param prefClass preferences class used as the storage area
 2499     """
 2500     if key in ["DebugClientsHistory", "DebuggerInterpreterHistory"]:
 2501         # max. list sizes is hard coded to 20 entries
 2502         newList = [v for v in value if v]
 2503         if len(newList) > 20:
 2504             newList = newList[:20]
 2505         prefClass.settings.setValue("Project/" + key, newList)
 2506     else:
 2507         prefClass.settings.setValue("Project/" + key, value)
 2508     
 2509 
 2510 def getProjectBrowserFlags(key, prefClass=Prefs):
 2511     """
 2512     Module function to retrieve the various project browser flags settings.
 2513     
 2514     @param key the key of the value to get
 2515     @param prefClass preferences class used as the storage area
 2516     @return the requested project setting
 2517     """
 2518     try:
 2519         default = prefClass.projectBrowserFlagsDefaults[key]
 2520     except KeyError:
 2521         default = AllBrowsersFlag
 2522     
 2523     return int(prefClass.settings.value(
 2524         "Project/BrowserFlags/" + key, default))
 2525     
 2526 
 2527 def setProjectBrowserFlags(key, value, prefClass=Prefs):
 2528     """
 2529     Module function to store the various project browser flags settings.
 2530     
 2531     @param key the key of the setting to be set
 2532     @param value the value to be set
 2533     @param prefClass preferences class used as the storage area
 2534     """
 2535     prefClass.settings.setValue("Project/BrowserFlags/" + key, value)
 2536     
 2537 
 2538 def setProjectBrowserFlagsDefault(key, value, prefClass=Prefs):
 2539     """
 2540     Module function to store the various project browser flags settings.
 2541     
 2542     @param key the key of the setting to be set
 2543     @param value the value to be set
 2544     @param prefClass preferences class used as the storage area
 2545     """
 2546     prefClass.projectBrowserFlagsDefaults[key] = value
 2547     
 2548 
 2549 def removeProjectBrowserFlags(key, prefClass=Prefs):
 2550     """
 2551     Module function to remove a project browser flags setting.
 2552     
 2553     @param key the key of the setting to be removed
 2554     @param prefClass preferences class used as the storage area
 2555     """
 2556     prefClass.settings.remove("Project/BrowserFlags/" + key)
 2557     
 2558 
 2559 def getProjectBrowserColour(key, prefClass=Prefs):
 2560     """
 2561     Module function to retrieve the various project browser colours.
 2562     
 2563     @param key the key of the value to get
 2564     @param prefClass preferences class used as the storage area
 2565     @return the requested project browser colour
 2566     """
 2567     col = prefClass.settings.value("Project/Colour/" + key)
 2568     if col is not None:
 2569         return QColor(col)
 2570     else:
 2571         return prefClass.projectBrowserColourDefaults[key]
 2572     
 2573 
 2574 def setProjectBrowserColour(key, value, prefClass=Prefs):
 2575     """
 2576     Module function to store the various project browser colours.
 2577     
 2578     @param key the key of the colour to be set
 2579     @param value the colour to be set
 2580     @param prefClass preferences class used as the storage area
 2581     """
 2582     prefClass.settings.setValue("Project/Colour/" + key, value.name())
 2583     
 2584 
 2585 def getMultiProject(key, prefClass=Prefs):
 2586     """
 2587     Module function to retrieve the various project handling settings.
 2588     
 2589     @param key the key of the value to get
 2590     @param prefClass preferences class used as the storage area
 2591     @return the requested project setting
 2592     """
 2593     if key in ["RecentNumber"]:
 2594         return int(prefClass.settings.value(
 2595             "MultiProject/" + key, prefClass.multiProjectDefaults[key]))
 2596     elif key in ["OpenMasterAutomatically", "XMLTimestamp"]:
 2597         return toBool(prefClass.settings.value(
 2598             "MultiProject/" + key, prefClass.multiProjectDefaults[key]))
 2599     else:
 2600         return prefClass.settings.value(
 2601             "MultiProject/" + key, prefClass.multiProjectDefaults[key])
 2602 
 2603 
 2604 def setMultiProject(key, value, prefClass=Prefs):
 2605     """
 2606     Module function to store the various project handling settings.
 2607     
 2608     @param key the key of the setting to be set
 2609     @param value the value to be set
 2610     @param prefClass preferences class used as the storage area
 2611     """
 2612     prefClass.settings.setValue("MultiProject/" + key, value)
 2613 
 2614 
 2615 def getQt5DocDir(prefClass=Prefs):
 2616     """
 2617     Module function to retrieve the Qt5DocDir setting.
 2618     
 2619     @param prefClass preferences class used as the storage area
 2620     @return the requested Qt5DocDir setting (string)
 2621     """
 2622     s = prefClass.settings.value(
 2623         "Help/Qt5DocDir", prefClass.helpDefaults["Qt5DocDir"])
 2624     if s == "":
 2625         s = os.getenv("QT5DOCDIR", "")
 2626     if s == "":
 2627         s = os.path.join(
 2628             QLibraryInfo.location(QLibraryInfo.DocumentationPath), "qtdoc")
 2629     return s
 2630 
 2631 
 2632 def getHelp(key, prefClass=Prefs):
 2633     """
 2634     Module function to retrieve the various help settings.
 2635     
 2636     @param key the key of the value to get
 2637     @param prefClass preferences class used as the storage area
 2638     @return the requested help setting
 2639     """
 2640     return prefClass.settings.value("Help/" + key,
 2641                                     prefClass.helpDefaults[key])
 2642 
 2643 
 2644 def setHelp(key, value, prefClass=Prefs):
 2645     """
 2646     Module function to store the various help settings.
 2647     
 2648     @param key the key of the setting to be set
 2649     @param value the value to be set
 2650     @param prefClass preferences class used as the storage area
 2651     """
 2652     prefClass.settings.setValue("Help/" + key, value)
 2653 
 2654 
 2655 def getWebBrowser(key, prefClass=Prefs):
 2656     """
 2657     Module function to retrieve the various web browser settings.
 2658     
 2659     @param key the key of the value to get
 2660     @param prefClass preferences class used as the storage area
 2661     @return the requested help setting
 2662     """
 2663     # Web inspector stuff must come before initializing web engine settings
 2664     # because that starts the chromium web process
 2665     if key == "WebInspectorPort":
 2666         return int(prefClass.settings.value(
 2667             "WebBrowser/" + key, prefClass.webBrowserDefaults[key]))
 2668     elif key == "WebInspectorEnabled":
 2669         return toBool(prefClass.settings.value(
 2670             "WebBrowser/" + key, prefClass.webBrowserDefaults[key]))
 2671     
 2672     if not prefClass.webEngineSettingsIntitialized:
 2673         prefClass.initWebEngineSettingsDefaults()
 2674     
 2675     if key in ["StandardFont", "FixedFont"]:
 2676         f = QFont()
 2677         f.fromString(prefClass.settings.value(
 2678             "WebBrowser/" + key, prefClass.webBrowserDefaults[key]))
 2679         return f
 2680     elif key in ["SecureUrlColor", "InsecureUrlColor", "MaliciousUrlColor",
 2681                  "PrivateModeUrlColor"]:
 2682         col = prefClass.settings.value("WebBrowser/" + key)
 2683         if col is not None:
 2684             return QColor(col)
 2685         else:
 2686             return prefClass.webBrowserDefaults[key]
 2687     elif key in ["WebSearchKeywords"]:
 2688         # return a list of tuples of (keyword, engine name)
 2689         keywords = []
 2690         size = prefClass.settings.beginReadArray("WebBrowser/" + key)
 2691         for index in range(size):
 2692             prefClass.settings.setArrayIndex(index)
 2693             keyword = prefClass.settings.value("Keyword")
 2694             engineName = prefClass.settings.value("Engine")
 2695             keywords.append((keyword, engineName))
 2696         prefClass.settings.endArray()
 2697         return keywords
 2698     elif key == "DownloadManagerDownloads":
 2699         # return a list of dicts containing the URL, save location, done flag,
 2700         # page URL, date/time downloaded
 2701         downloads = []
 2702         length = prefClass.settings.beginReadArray("WebBrowser/" + key)
 2703         for index in range(length):
 2704             download = {}
 2705             prefClass.settings.setArrayIndex(index)
 2706             download["URL"] = prefClass.settings.value("URL")
 2707             if download["URL"] is None:
 2708                 download["URL"] = QUrl()
 2709             download["Location"] = prefClass.settings.value("Location")
 2710             download["Done"] = toBool(prefClass.settings.value("Done"))
 2711             download["PageURL"] = prefClass.settings.value("PageURL")
 2712             if download["PageURL"] is None:
 2713                 download["PageURL"] = QUrl()
 2714             download["Downloaded"] = prefClass.settings.value("Downloaded")
 2715             if download["Downloaded"] is None:
 2716                 download["Downloaded"] = QDateTime()
 2717             elif isinstance(download["Downloaded"], str):
 2718                 download["Downloaded"] = QDateTime.fromString(
 2719                     download["Downloaded"], "yyyy-MM-dd hh:mm:ss")
 2720             downloads.append(download)
 2721         prefClass.settings.endArray()
 2722         return downloads
 2723     elif key == "RssFeeds":
 2724         # return a list of tuples of (URL, title, icon)
 2725         feeds = []
 2726         length = prefClass.settings.beginReadArray("WebBrowser/" + key)
 2727         for index in range(length):
 2728             prefClass.settings.setArrayIndex(index)
 2729             url = prefClass.settings.value("URL")
 2730             title = prefClass.settings.value("Title")
 2731             icon = prefClass.settings.value("Icon")
 2732             feeds.append((url, title, icon))
 2733         prefClass.settings.endArray()
 2734         return feeds
 2735     elif key in ["SyncFtpPassword", "SyncEncryptionKey"]:
 2736         from Utilities.crypto import pwConvert
 2737         return pwConvert(prefClass.settings.value(
 2738             "WebBrowser/" + key, prefClass.webBrowserDefaults[key]),
 2739             encode=False)
 2740     elif key == "HelpViewerType":
 2741         # special treatment to adjust for missing QtWebEngine
 2742         value = int(prefClass.settings.value(
 2743             "WebBrowser/" + key, prefClass.webBrowserDefaults[key]))
 2744         if QWebEngineSettings is None:
 2745             value = prefClass.webBrowserDefaults[key]
 2746         return value
 2747     elif key in ["StartupBehavior", "HistoryLimit",
 2748                  "DownloadManagerRemovePolicy", "SyncType", "SyncFtpPort",
 2749                  "SyncFtpIdleTimeout", "SyncEncryptionKeyLength",
 2750                  "SearchLanguage", "WebInspectorPort",
 2751                  "DefaultFontSize", "DefaultFixedFontSize",
 2752                  "MinimumFontSize", "MinimumLogicalFontSize",
 2753                  "DiskCacheSize", "AcceptCookies", "KeepCookiesUntil",
 2754                  "AdBlockUpdatePeriod", "TabManagerGroupByType",
 2755                  "SessionAutoSaveInterval", "NewTabBehavior",
 2756                  "RefererSendReferer", "RefererDefaultPolicy",
 2757                  "RefererTrimmingPolicy", "AcceptQuotaRequest",
 2758                  "AcceptProtocolHandlerRequest",
 2759                  ]:
 2760         return int(prefClass.settings.value(
 2761             "WebBrowser/" + key, prefClass.webBrowserDefaults[key]))
 2762     elif key in ["SingleWebBrowserWindow", "SaveGeometry",
 2763                  "JavaScriptEnabled", "JavaScriptCanOpenWindows",
 2764                  "JavaScriptCanAccessClipboard",
 2765                  "AutoLoadImages", "LocalStorageEnabled",
 2766                  "SpatialNavigationEnabled", "LinksIncludedInFocusChain",
 2767                  "LocalContentCanAccessRemoteUrls",
 2768                  "LocalContentCanAccessFileUrls", "XSSAuditingEnabled",
 2769                  "ScrollAnimatorEnabled", "ErrorPageEnabled",
 2770                  "WarnOnMultipleClose", "WebSearchSuggestions",
 2771                  "SyncEnabled", "SyncBookmarks", "SyncHistory",
 2772                  "SyncPasswords", "SyncUserAgents", "SyncSpeedDial",
 2773                  "SyncEncryptData", "SyncEncryptPasswordsOnly",
 2774                  "ShowPreview", "WebInspectorEnabled", "DiskCacheEnabled",
 2775                  "DoNotTrack", "FilterTrackingCookies",
 2776                  "AdBlockEnabled", "AdBlockUseLimitedEasyList",
 2777                  "PluginsEnabled", "FullScreenSupportEnabled",
 2778                  "AutoScrollEnabled", "ScreenCaptureEnabled",
 2779                  "WebGLEnabled", "FocusOnNavigationEnabled",
 2780                  "PrintElementBackgrounds", "AllowRunningInsecureContent",
 2781                  "SpellCheckEnabled", "ShowToolbars", "MenuBarVisible",
 2782                  "BookmarksToolBarVisible", "StatusBarVisible",
 2783                  "SessionAutoSave", "LoadTabOnActivation",
 2784                  "SafeBrowsingEnabled", "SafeBrowsingFilterPlatform",
 2785                  "SafeBrowsingAutoUpdate", "SafeBrowsingUseLookupApi",
 2786                  "AllowGeolocationOnInsecureOrigins",
 2787                  "AllowWindowActivationFromJavaScript", "ShowScrollBars",
 2788                  "DownloadManagerAutoOpen", "DownloadManagerAutoClose",
 2789                  "PlaybackRequiresUserGesture", "JavaScriptCanPaste",
 2790                  "WebRTCPublicInterfacesOnly", "DnsPrefetchEnabled",
 2791                  "FlashCookiesDeleteOnStartExit", "FlashCookieAutoRefresh",
 2792                  "FlashCookieNotify", "VirusTotalEnabled", "VirusTotalSecure",
 2793                  "PdfViewerEnabled", "AlwaysRejectFaultyCertificates",
 2794                  ]:
 2795         return toBool(prefClass.settings.value(
 2796             "WebBrowser/" + key, prefClass.webBrowserDefaults[key]))
 2797     elif key in ["GreaseMonkeyDisabledScripts", "SendRefererWhitelist",
 2798                  "AdBlockSubscriptions", "AdBlockExceptions",
 2799                  "FlashCookiesWhitelist", "FlashCookiesBlacklist",
 2800                  "SpellCheckLanguages",
 2801                  ]:
 2802         return toList(prefClass.settings.value(
 2803             "WebBrowser/" + key, prefClass.webBrowserDefaults[key]))
 2804     elif key in ["AutoScrollDivider"]:
 2805         return float(prefClass.settings.value(
 2806             "WebBrowser/" + key, prefClass.webBrowserDefaults[key]))
 2807     elif key in ["SafeBrowsingUpdateDateTime"]:
 2808         dateTimeStr = prefClass.settings.value("WebBrowser/" + key)
 2809         if dateTimeStr is not None:
 2810             return QDateTime.fromString(dateTimeStr, Qt.ISODate)
 2811         else:
 2812             return prefClass.webBrowserDefaults[key]
 2813     else:
 2814         return prefClass.settings.value("WebBrowser/" + key,
 2815                                         prefClass.webBrowserDefaults[key])
 2816     
 2817 
 2818 def setWebBrowser(key, value, prefClass=Prefs):
 2819     """
 2820     Module function to store the various web browser settings.
 2821     
 2822     @param key the key of the setting to be set
 2823     @param value the value to be set
 2824     @param prefClass preferences class used as the storage area
 2825     """
 2826     if key in ["StandardFont", "FixedFont"]:
 2827         prefClass.settings.setValue("WebBrowser/" + key, value.toString())
 2828     elif key in ["SecureUrlColor", "InsecureUrlColor", "MaliciousUrlColor",
 2829                  "PrivateModeUrlColor"]:
 2830         prefClass.settings.setValue("WebBrowser/" + key, value.name())
 2831     elif key == "WebSearchKeywords":
 2832         # value is list of tuples of (keyword, engine name)
 2833         prefClass.settings.remove("WebBrowser/" + key)
 2834         prefClass.settings.beginWriteArray("WebBrowser/" + key, len(value))
 2835         index = 0
 2836         for v in value:
 2837             prefClass.settings.setArrayIndex(index)
 2838             prefClass.settings.setValue("Keyword", v[0])
 2839             prefClass.settings.setValue("Engine", v[1])
 2840             index += 1
 2841         prefClass.settings.endArray()
 2842     elif key == "DownloadManagerDownloads":
 2843         # value is list of dicts containing the URL, save location, done flag,
 2844         # page URL, date/time downloaded
 2845         prefClass.settings.remove("Help/" + key)
 2846         prefClass.settings.beginWriteArray("WebBrowser/" + key, len(value))
 2847         index = 0
 2848         for v in value:
 2849             prefClass.settings.setArrayIndex(index)
 2850             prefClass.settings.setValue("URL", v["URL"])
 2851             prefClass.settings.setValue("Location", v["Location"])
 2852             prefClass.settings.setValue("Done", v["Done"])
 2853             prefClass.settings.setValue("PageURL", v["PageURL"])
 2854             prefClass.settings.setValue(
 2855                 "Downloaded", v["Downloaded"].toString("yyyy-MM-dd hh:mm:ss"))
 2856             index += 1
 2857         prefClass.settings.endArray()
 2858     elif key == "RssFeeds":
 2859         # value is list of tuples of (URL, title, icon)
 2860         prefClass.settings.remove("WebBrowser/" + key)
 2861         prefClass.settings.beginWriteArray("WebBrowser/" + key, len(value))
 2862         index = 0
 2863         for v in value:
 2864             prefClass.settings.setArrayIndex(index)
 2865             prefClass.settings.setValue("URL", v[0])
 2866             prefClass.settings.setValue("Title", v[1])
 2867             prefClass.settings.setValue("Icon", v[2])
 2868             index += 1
 2869         prefClass.settings.endArray()
 2870     elif key in ["SyncFtpPassword", "SyncEncryptionKey"]:
 2871         from Utilities.crypto import pwConvert
 2872         prefClass.settings.setValue(
 2873             "WebBrowser/" + key, pwConvert(value, encode=True))
 2874     elif key in ["SafeBrowsingUpdateDateTime"]:
 2875         # value is a QDateTime
 2876         prefClass.settings.setValue("WebBrowser/" + key,
 2877                                     value.toString(Qt.ISODate))
 2878     else:
 2879         prefClass.settings.setValue("WebBrowser/" + key, value)
 2880     
 2881 
 2882 def getSystem(key, prefClass=Prefs):
 2883     """
 2884     Module function to retrieve the various system settings.
 2885     
 2886     @param key the key of the value to get
 2887     @param prefClass preferences class used as the storage area
 2888     @return the requested system setting
 2889     """
 2890     from Utilities import supportedCodecs
 2891     if key in ["StringEncoding", "IOEncoding"]:
 2892         encoding = prefClass.settings.value(
 2893             "System/" + key, prefClass.sysDefaults[key])
 2894         if encoding not in supportedCodecs:
 2895             encoding = prefClass.sysDefaults[key]
 2896         return encoding
 2897     
 2898     return None
 2899     
 2900 
 2901 def setSystem(key, value, prefClass=Prefs):
 2902     """
 2903     Module function to store the various system settings.
 2904     
 2905     @param key the key of the setting to be set
 2906     @param value the value to be set
 2907     @param prefClass preferences class used as the storage area
 2908     """
 2909     prefClass.settings.setValue("System/" + key, value)
 2910     
 2911 
 2912 def getQtTranslationsDir(prefClass=Prefs):
 2913     """
 2914     Module function to retrieve the Qt5TranslationsDir
 2915     setting depending on the current Qt version.
 2916     
 2917     @param prefClass preferences class used as the storage area
 2918     @return the requested setting (string)
 2919     """
 2920     s = prefClass.settings.value(
 2921         "Qt/Qt5TranslationsDir",
 2922         prefClass.qtDefaults["Qt5TranslationsDir"])
 2923     if s == "":
 2924         s = QLibraryInfo.location(QLibraryInfo.TranslationsPath)
 2925     if s == "" and Globals.isWindowsPlatform():
 2926         transPath = os.path.join(Globals.getPyQt5ModulesDirectory(),
 2927                                  "translations")
 2928         if os.path.exists(transPath):
 2929             s = transPath
 2930     return s
 2931     
 2932 
 2933 def getQt(key, prefClass=Prefs):
 2934     """
 2935     Module function to retrieve the various Qt settings.
 2936     
 2937     @param key the key of the value to get
 2938     @param prefClass preferences class used as the storage area
 2939     @return the requested Qt setting
 2940     """
 2941     if key in ["Qt5TranslationsDir"]:
 2942         return getQtTranslationsDir(prefClass)
 2943     elif key in ["PyuicIndent"]:
 2944         return int(prefClass.settings.value(
 2945             "Qt/" + key, prefClass.qtDefaults[key]))
 2946     elif key in ["PyuicFromImports", "PyuicExecute", "PySide2FromImports"]:
 2947         return toBool(prefClass.settings.value(
 2948             "Qt/" + key, prefClass.qtDefaults[key]))
 2949     else:
 2950         return prefClass.settings.value("Qt/" + key, prefClass.qtDefaults[key])
 2951     
 2952 
 2953 def setQt(key, value, prefClass=Prefs):
 2954     """
 2955     Module function to store the various Qt settings.
 2956     
 2957     @param key the key of the setting to be set
 2958     @param value the value to be set
 2959     @param prefClass preferences class used as the storage area
 2960     """
 2961     prefClass.settings.setValue("Qt/" + key, value)
 2962     
 2963 
 2964 def getCorba(key, prefClass=Prefs):
 2965     """
 2966     Module function to retrieve the various Corba settings.
 2967     
 2968     @param key the key of the value to get
 2969     @param prefClass preferences class used as the storage area
 2970     @return the requested corba setting
 2971     """
 2972     return prefClass.settings.value(
 2973         "Corba/" + key, prefClass.corbaDefaults[key])
 2974     
 2975 
 2976 def setCorba(key, value, prefClass=Prefs):
 2977     """
 2978     Module function to store the various Corba settings.
 2979     
 2980     @param key the key of the setting to be set
 2981     @param value the value to be set
 2982     @param prefClass preferences class used as the storage area
 2983     """
 2984     prefClass.settings.setValue("Corba/" + key, value)
 2985     
 2986 
 2987 def getProtobuf(key, prefClass=Prefs):
 2988     """
 2989     Module function to retrieve the various protobuf settings.
 2990     
 2991     @param key the key of the value to get
 2992     @type str
 2993     @param prefClass preferences class used as the storage area
 2994     @type Prefs
 2995     @return the requested protobuf setting
 2996     @rtype any
 2997     """
 2998     return prefClass.settings.value(
 2999         "Protobuf/" + key, prefClass.protobufDefaults[key])
 3000     
 3001 
 3002 def setProtobuf(key, value, prefClass=Prefs):
 3003     """
 3004     Module function to store the various protobuf settings.
 3005     
 3006     @param key the key of the setting to be set
 3007     @type str
 3008     @param value the value to be set
 3009     @type any
 3010     @param prefClass preferences class used as the storage area
 3011     @type Prefs
 3012     """
 3013     prefClass.settings.setValue("Protobuf/" + key, value)
 3014     
 3015 
 3016 def getUser(key, prefClass=Prefs):
 3017     """
 3018     Module function to retrieve the various user settings.
 3019     
 3020     @param key the key of the value to get
 3021     @param prefClass preferences class used as the storage area
 3022     @return the requested user setting
 3023     """
 3024     if key == "MailServerPassword":
 3025         from Utilities.crypto import pwConvert
 3026         return pwConvert(prefClass.settings.value(
 3027             "User/" + key, prefClass.userDefaults[key]), encode=False)
 3028     elif key in ["MailServerPort"]:
 3029         try:
 3030             return int(prefClass.settings.value(
 3031                 "User/" + key, prefClass.userDefaults[key]))
 3032         except ValueError:
 3033             return prefClass.userDefaults[key]
 3034     elif key in ["MailServerAuthentication", "UseSystemEmailClient",
 3035                  "UseMasterPassword", "SavePasswords", "UseGoogleMailOAuth2"]:
 3036         return toBool(prefClass.settings.value(
 3037             "User/" + key, prefClass.userDefaults[key]))
 3038     elif key == "MailServerEncryption":
 3039         # convert from old key 'MailServerUseTLS'
 3040         val = prefClass.settings.value("User/" + key)
 3041         if val is None:
 3042             if toBool(prefClass.settings.value("User/MailServerUseTLS")):
 3043                 val = "TLS"
 3044             else:
 3045                 val = prefClass.userDefaults[key]
 3046         return val
 3047     else:
 3048         return prefClass.settings.value(
 3049             "User/" + key, prefClass.userDefaults[key])
 3050     
 3051 
 3052 def setUser(key, value, prefClass=Prefs):
 3053     """
 3054     Module function to store the various user settings.
 3055     
 3056     @param key the key of the setting to be set
 3057     @param value the value to be set
 3058     @param prefClass preferences class used as the storage area
 3059     """
 3060     if key == "MailServerPassword":
 3061         from Utilities.crypto import pwConvert
 3062         prefClass.settings.setValue(
 3063             "User/" + key, pwConvert(value, encode=True))
 3064     elif key == "MasterPassword":
 3065         from Utilities.crypto.py3PBKDF2 import hashPassword
 3066         prefClass.settings.setValue(
 3067             "User/" + key, hashPassword(value))
 3068     else:
 3069         prefClass.settings.setValue("User/" + key, value)
 3070     
 3071 
 3072 def getVCS(key, prefClass=Prefs):
 3073     """
 3074     Module function to retrieve the VCS related settings.
 3075     
 3076     @param key the key of the value to get
 3077     @param prefClass preferences class used as the storage area
 3078     @return the requested user setting
 3079     """
 3080     if key in ["StatusMonitorInterval"]:
 3081         return int(prefClass.settings.value(
 3082             "VCS/" + key, prefClass.vcsDefaults[key]))
 3083     else:
 3084         return toBool(prefClass.settings.value(
 3085             "VCS/" + key, prefClass.vcsDefaults[key]))
 3086     
 3087 
 3088 def setVCS(key, value, prefClass=Prefs):
 3089     """
 3090     Module function to store the VCS related settings.
 3091     
 3092     @param key the key of the setting to be set
 3093     @param value the value to be set
 3094     @param prefClass preferences class used as the storage area
 3095     """
 3096     prefClass.settings.setValue("VCS/" + key, value)
 3097     
 3098 
 3099 def getTasks(key, prefClass=Prefs):
 3100     """
 3101     Module function to retrieve the Tasks related settings.
 3102     
 3103     @param key the key of the value to get
 3104     @param prefClass preferences class used as the storage area
 3105     @return the requested user setting
 3106     """
 3107     if key in ["TasksFixmeColor", "TasksWarningColor",
 3108                "TasksTodoColor", "TasksNoteColor",
 3109                "TasksTestColor", "TasksDocuColor"]:
 3110         col = prefClass.settings.value("Tasks/" + key)
 3111         if col is not None:
 3112             return QColor(col)
 3113         else:
 3114             return prefClass.tasksDefaults[key]
 3115     elif key in ["ClearOnFileClose", ]:
 3116         return toBool(prefClass.settings.value(
 3117             "Tasks/" + key, prefClass.tasksDefaults[key]))
 3118     else:
 3119         return prefClass.settings.value(
 3120             "Tasks/" + key, prefClass.tasksDefaults[key])
 3121     
 3122 
 3123 def setTasks(key, value, prefClass=Prefs):
 3124     """
 3125     Module function to store the Tasks related settings.
 3126     
 3127     @param key the key of the setting to be set
 3128     @param value the value to be set
 3129     @param prefClass preferences class used as the storage area
 3130     """
 3131     if key in ["TasksFixmeColor", "TasksWarningColor",
 3132                "TasksTodoColor", "TasksNoteColor"]:
 3133         prefClass.settings.setValue("Tasks/" + key, value.name())
 3134     else:
 3135         prefClass.settings.setValue("Tasks/" + key, value)
 3136     
 3137 
 3138 def getTemplates(key, prefClass=Prefs):
 3139     """
 3140     Module function to retrieve the Templates related settings.
 3141     
 3142     @param key the key of the value to get
 3143     @param prefClass preferences class used as the storage area
 3144     @return the requested user setting
 3145     """
 3146     if key in ["SeparatorChar"]:
 3147         return prefClass.settings.value(
 3148             "Templates/" + key, prefClass.templatesDefaults[key])
 3149     elif key in ["EditorFont"]:
 3150         f = QFont()
 3151         f.fromString(prefClass.settings.value(
 3152             "Templates/" + key, prefClass.templatesDefaults[key]))
 3153         return f
 3154     else:
 3155         return toBool(prefClass.settings.value(
 3156             "Templates/" + key, prefClass.templatesDefaults[key]))
 3157     
 3158 
 3159 def setTemplates(key, value, prefClass=Prefs):
 3160     """
 3161     Module function to store the Templates related settings.
 3162     
 3163     @param key the key of the setting to be set
 3164     @param value the value to be set
 3165     @param prefClass preferences class used as the storage area
 3166     """
 3167     if key in ["EditorFont"]:
 3168         prefClass.settings.setValue("Templates/" + key, value.toString())
 3169     else:
 3170         prefClass.settings.setValue("Templates/" + key, value)
 3171     
 3172 
 3173 def getPluginManager(key, prefClass=Prefs):
 3174     """
 3175     Module function to retrieve the plugin manager related settings.
 3176     
 3177     @param key the key of the value to get
 3178     @param prefClass preferences class used as the storage area
 3179     @return the requested user setting
 3180     """
 3181     if key in ["DownloadPath"]:
 3182         return prefClass.settings.value(
 3183             "PluginManager/" + key, prefClass.pluginManagerDefaults[key])
 3184     elif key in ["UpdatesCheckInterval", "KeepGenerations"]:
 3185         return int(prefClass.settings.value(
 3186             "PluginManager/" + key, prefClass.pluginManagerDefaults[key]))
 3187     elif key in ["HiddenPlugins"]:
 3188         return toList(prefClass.settings.value(
 3189             "PluginManager/" + key, prefClass.pluginManagerDefaults[key]))
 3190     else:
 3191         return toBool(prefClass.settings.value(
 3192             "PluginManager/" + key, prefClass.pluginManagerDefaults[key]))
 3193     
 3194 
 3195 def setPluginManager(key, value, prefClass=Prefs):
 3196     """
 3197     Module function to store the plugin manager related settings.
 3198     
 3199     @param key the key of the setting to be set
 3200     @param value the value to be set
 3201     @param prefClass preferences class used as the storage area
 3202     """
 3203     prefClass.settings.setValue("PluginManager/" + key, value)
 3204     
 3205 
 3206 def getGraphics(key, prefClass=Prefs):
 3207     """
 3208     Module function to retrieve the Graphics related settings.
 3209     
 3210     @param key the key of the value to get
 3211     @param prefClass preferences class used as the storage area
 3212     @return the requested user setting
 3213     """
 3214     if key in ["Font"]:
 3215         font = prefClass.settings.value(
 3216             "Graphics/" + key, prefClass.graphicsDefaults[key])
 3217         if isinstance(font, QFont):
 3218             # workaround for an old bug in eric < 4.4
 3219             return font
 3220         else:
 3221             f = QFont()
 3222             f.fromString(font)
 3223             return f
 3224     else:
 3225         return prefClass.settings.value(
 3226             "Graphics/" + key, prefClass.graphicsDefaults[key])
 3227     
 3228 
 3229 def setGraphics(key, value, prefClass=Prefs):
 3230     """
 3231     Module function to store the Graphics related settings.
 3232     
 3233     @param key the key of the setting to be set
 3234     @param value the value to be set
 3235     @param prefClass preferences class used as the storage area
 3236     """
 3237     if key in ["Font"]:
 3238         prefClass.settings.setValue("Graphics/" + key, value.toString())
 3239     else:
 3240         prefClass.settings.setValue("Graphics/" + key, value)
 3241     
 3242 
 3243 def getIconEditor(key, prefClass=Prefs):
 3244     """
 3245     Module function to retrieve the Icon Editor related settings.
 3246     
 3247     @param key the key of the value to get
 3248     @param prefClass preferences class used as the storage area
 3249     @return the requested user setting
 3250     """
 3251     return prefClass.settings.value(
 3252         "IconEditor/" + key, prefClass.iconEditorDefaults[key])
 3253     
 3254 
 3255 def setIconEditor(key, value, prefClass=Prefs):
 3256     """
 3257     Module function to store the Icon Editor related settings.
 3258     
 3259     @param key the key of the setting to be set
 3260     @param value the value to be set
 3261     @param prefClass preferences class used as the storage area
 3262     """
 3263     prefClass.settings.setValue("IconEditor/" + key, value)
 3264 
 3265 
 3266 def getFlakes(key, prefClass=Prefs):
 3267     """
 3268     Module function to retrieve the pyflakes related settings.
 3269     
 3270     @param key the key of the value to get
 3271     @param prefClass preferences class used as the storage area
 3272     @return the requested user setting
 3273     """
 3274     if key in ["IncludeInSyntaxCheck", "IgnoreStarImportWarnings"]:
 3275         return toBool(prefClass.settings.value("Py3Flakes/" + key,
 3276                       prefClass.pyflakesDefaults[key]))
 3277     else:
 3278         return prefClass.settings.value(
 3279             "Py3Flakes/" + key, prefClass.pyflakesDefaults[key])
 3280     
 3281 
 3282 def setFlakes(key, value, prefClass=Prefs):
 3283     """
 3284     Module function to store the pyflakes related settings.
 3285     
 3286     @param key the key of the setting to be set
 3287     @param value the value to be set
 3288     @param prefClass preferences class used as the storage area
 3289     """
 3290     prefClass.settings.setValue("Py3Flakes/" + key, value)
 3291 
 3292 
 3293 def getTrayStarter(key, prefClass=Prefs):
 3294     """
 3295     Module function to retrieve the tray starter related settings.
 3296     
 3297     @param key the key of the value to get
 3298     @param prefClass preferences class used as the storage area
 3299     @return the requested user setting
 3300     """
 3301     return prefClass.settings.value(
 3302         "TrayStarter/" + key, prefClass.trayStarterDefaults[key])
 3303     
 3304 
 3305 def setTrayStarter(key, value, prefClass=Prefs):
 3306     """
 3307     Module function to store the tray starter related settings.
 3308     
 3309     @param key the key of the setting to be set
 3310     @param value the value to be set
 3311     @param prefClass preferences class used as the storage area
 3312     """
 3313     prefClass.settings.setValue("TrayStarter/" + key, value)
 3314     
 3315 
 3316 def getIrc(key, prefClass=Prefs):
 3317     """
 3318     Module function to retrieve the IRC related settings.
 3319     
 3320     @param key the key of the value to get
 3321     @param prefClass preferences class used as the storage area
 3322     @return the requested user setting
 3323     """
 3324     if key in ["TimestampIncludeDate", "ShowTimestamps", "ShowNotifications",
 3325                "NotifyJoinPart", "NotifyMessage", "NotifyNick",
 3326                "EnableIrcColours", "AutoUserInfoLookup",
 3327                "MarkPositionWhenHidden", "AskOnShutdown"]:
 3328         return toBool(prefClass.settings.value(
 3329             "IRC/" + key, prefClass.ircDefaults[key]))
 3330     elif key in ["AutoUserInfoMax", "AutoUserInfoInterval"]:
 3331         return int(prefClass.settings.value(
 3332             "IRC/" + key, prefClass.ircDefaults[key]))
 3333     else:
 3334         return prefClass.settings.value(
 3335             "IRC/" + key, prefClass.ircDefaults[key])
 3336 
 3337 
 3338 def setIrc(key, value, prefClass=Prefs):
 3339     """
 3340     Module function to store the IRC related settings.
 3341     
 3342     @param key the key of the setting to be set
 3343     @param value the value to be set
 3344     @param prefClass preferences class used as the storage area
 3345     """
 3346     prefClass.settings.setValue("IRC/" + key, value)
 3347     
 3348 
 3349 def getHexEditor(key, prefClass=Prefs):
 3350     """
 3351     Module function to retrieve the Hex Editor related settings.
 3352     
 3353     @param key the key of the value to get
 3354     @param prefClass preferences class used as the storage area
 3355     @return the requested user setting
 3356     """
 3357     if key in ["AddressAreaWidth", "RecentNumber"]:
 3358         return int(prefClass.settings.value(
 3359             "HexEditor/" + key, prefClass.hexEditorDefaults[key]))
 3360     elif key in ["ShowAddressArea", "ShowAsciiArea", "OpenInOverwriteMode",
 3361                  "OpenReadOnly", "HighlightChanges"]:
 3362         return toBool(prefClass.settings.value(
 3363             "HexEditor/" + key, prefClass.hexEditorDefaults[key]))
 3364     elif key in ["HighlightingBackGround", "HighlightingForeGround",
 3365                  "SelectionBackGround", "SelectionForeGround",
 3366                  "AddressAreaBackGround", "AddressAreaForeGround"]:
 3367         return QColor(prefClass.settings.value(
 3368             "HexEditor/" + key, prefClass.hexEditorDefaults[key]))
 3369     elif key in ["Font"]:
 3370         f = QFont()
 3371         f.fromString(prefClass.settings.value(
 3372             "HexEditor/" + key, prefClass.hexEditorDefaults[key]))
 3373         return f
 3374     else:
 3375         return prefClass.settings.value(
 3376             "HexEditor/" + key, prefClass.hexEditorDefaults[key])
 3377     
 3378 
 3379 def setHexEditor(key, value, prefClass=Prefs):
 3380     """
 3381     Module function to store the Hex Editor related settings.
 3382     
 3383     @param key the key of the setting to be set
 3384     @param value the value to be set
 3385     @param prefClass preferences class used as the storage area
 3386     """
 3387     if key in ["HighlightingBackGround", "HighlightingForeGround",
 3388                "SelectionBackGround", "SelectionForeGround",
 3389                "AddressAreaBackGround", "AddressAreaForeGround"]:
 3390         if value.alpha() < 255:
 3391             val = "#{0:8x}".format(value.rgba())
 3392         else:
 3393             val = value.name()
 3394         prefClass.settings.setValue("HexEditor/" + key, val)
 3395     elif key in ["Font"]:
 3396         prefClass.settings.setValue("HexEditor/" + key, value.toString())
 3397     else:
 3398         prefClass.settings.setValue("HexEditor/" + key, value)
 3399     
 3400 
 3401 def getDiffColour(key, prefClass=Prefs):
 3402     """
 3403     Module function to retrieve the colours for the diff highlighter.
 3404     
 3405     @param key the key of the value to get
 3406     @param prefClass preferences class used as the storage area
 3407     @return the requested diff colour
 3408     """
 3409     col = prefClass.settings.value("Diff/" + key)
 3410     if col is not None:
 3411         if len(col) == 9:
 3412             # color string with alpha
 3413             return QColor.fromRgba(int(col[1:], 16))
 3414         else:
 3415             return QColor(col)
 3416     else:
 3417         return prefClass.diffColourDefaults[key]
 3418     
 3419 
 3420 def setDiffColour(key, value, prefClass=Prefs):
 3421     """
 3422     Module function to store the diff highlighter colours.
 3423     
 3424     @param key the key of the colour to be set
 3425     @param value the colour to be set
 3426     @param prefClass preferences class used as the storage area
 3427     """
 3428     if value.alpha() < 255:
 3429         val = "#{0:8x}".format(value.rgba())
 3430     else:
 3431         val = value.name()
 3432     prefClass.settings.setValue("Diff/" + key, val)
 3433 
 3434 
 3435 def getDocuViewer(key, prefClass=Prefs):
 3436     """
 3437     Module function to retrieve the Code Documentation Viewer related settings.
 3438     
 3439     @param key the key of the value to get
 3440     @param prefClass preferences class used as the storage area
 3441     @return the requested Code Documentation Viewer value
 3442     """
 3443     if key in ["ShowInfoAsRichText", "ShowInfoOnOpenParenthesis"]:
 3444         return toBool(prefClass.settings.value(
 3445             "CodeDocumentationViewer/" + key,
 3446             prefClass.docuViewerDefaults[key]))
 3447     else:
 3448         return prefClass.settings.value(
 3449             "CodeDocumentationViewer/" + key,
 3450             prefClass.docuViewerDefaults[key])
 3451     
 3452 
 3453 def setDocuViewer(key, value, prefClass=Prefs):
 3454     """
 3455     Module function to store the Code Documentation Viewer related settings.
 3456     
 3457     @param key the key of the setting to be set
 3458     @param value the value to be set
 3459     @param prefClass preferences class used as the storage area
 3460     """
 3461     prefClass.settings.setValue("CodeDocumentationViewer/" + key, value)
 3462 
 3463 
 3464 def getConda(key, prefClass=Prefs):
 3465     """
 3466     Module function to retrieve the conda related settings.
 3467     
 3468     @param key the key of the value to get
 3469     @param prefClass preferences class used as the storage area
 3470     @return the requested conda value
 3471     """
 3472     return prefClass.settings.value(
 3473         "Conda/" + key,
 3474         prefClass.condaDefaults[key])
 3475 
 3476 
 3477 def setConda(key, value, prefClass=Prefs):
 3478     """
 3479     Module function to store the conda related settings.
 3480     
 3481     @param key the key of the setting to be set
 3482     @param value the value to be set
 3483     @param prefClass preferences class used as the storage area
 3484     """
 3485     prefClass.settings.setValue("Conda/" + key, value)
 3486 
 3487 
 3488 def getPip(key, prefClass=Prefs):
 3489     """
 3490     Module function to retrieve the pip related settings.
 3491     
 3492     @param key the key of the value to get
 3493     @param prefClass preferences class used as the storage area
 3494     @return the requested pip value
 3495     """
 3496     return prefClass.settings.value(
 3497         "Pip/" + key,
 3498         prefClass.pipDefaults[key])
 3499 
 3500 
 3501 def setPip(key, value, prefClass=Prefs):
 3502     """
 3503     Module function to store the pip related settings.
 3504     
 3505     @param key the key of the setting to be set
 3506     @param value the value to be set
 3507     @param prefClass preferences class used as the storage area
 3508     """
 3509     prefClass.settings.setValue("Pip/" + key, value)
 3510 
 3511 
 3512 def getMicroPython(key, prefClass=Prefs):
 3513     """
 3514     Module function to retrieve the MicroPython related settings.
 3515     
 3516     @param key the key of the value to get
 3517     @param prefClass preferences class used as the storage area
 3518     @return the requested MicroPython value
 3519     """
 3520     if key in ("SerialTimeout"):
 3521         return int(prefClass.settings.value(
 3522             "MicroPython/" + key,
 3523             prefClass.microPythonDefaults[key]))
 3524     elif key in ["ReplLineWrap", "SyncTimeAfterConnect", "ShowHiddenLocal",
 3525                  "ShowHiddenDevice"]:
 3526         return toBool(prefClass.settings.value(
 3527             "MicroPython/" + key,
 3528             prefClass.microPythonDefaults[key]))
 3529     elif key in ["IgnoredUnknownDevices"]:
 3530         jsonStr = prefClass.settings.value(
 3531             "MicroPython/" + key,
 3532             prefClass.microPythonDefaults[key])
 3533         if jsonStr:
 3534             return json.loads(jsonStr)
 3535         else:
 3536             return None
 3537     else:
 3538         return prefClass.settings.value(
 3539             "MicroPython/" + key,
 3540             prefClass.microPythonDefaults[key])
 3541 
 3542 
 3543 def setMicroPython(key, value, prefClass=Prefs):
 3544     """
 3545     Module function to store the pip MicroPython settings.
 3546     
 3547     @param key the key of the setting to be set
 3548     @param value the value to be set
 3549     @param prefClass preferences class used as the storage area
 3550     """
 3551     if key in ["IgnoredUnknownDevices"]:
 3552         prefClass.settings.setValue(
 3553             "MicroPython/" + key,
 3554             json.dumps(value))
 3555     else:
 3556         prefClass.settings.setValue(
 3557             "MicroPython/" + key,
 3558             value)
 3559 
 3560 
 3561 def getGeometry(key, prefClass=Prefs):
 3562     """
 3563     Module function to retrieve the display geometry.
 3564     
 3565     @param key the key of the value to get
 3566     @param prefClass preferences class used as the storage area
 3567     @return the requested geometry setting
 3568     """
 3569     if key in ["MainMaximized"]:
 3570         return toBool(prefClass.settings.value(
 3571             "Geometry/" + key,
 3572             prefClass.geometryDefaults[key]))
 3573     else:
 3574         v = prefClass.settings.value("Geometry/" + key)
 3575         if v is not None:
 3576             return v
 3577         else:
 3578             return prefClass.geometryDefaults[key]
 3579 
 3580 
 3581 def setGeometry(key, value, prefClass=Prefs):
 3582     """
 3583     Module function to store the display geometry.
 3584     
 3585     @param key the key of the setting to be set
 3586     @param value the geometry to be set
 3587     @param prefClass preferences class used as the storage area
 3588     """
 3589     if key in ["MainMaximized"]:
 3590         prefClass.settings.setValue("Geometry/" + key, value)
 3591     else:
 3592         if prefClass.resetLayout:
 3593             v = prefClass.geometryDefaults[key]
 3594         else:
 3595             v = value
 3596         prefClass.settings.setValue("Geometry/" + key, v)
 3597 
 3598 
 3599 def resetLayout(prefClass=Prefs):
 3600     """
 3601     Module function to set a flag not storing the current layout.
 3602     
 3603     @param prefClass preferences class used as the storage area
 3604     """
 3605     prefClass.resetLayout = True
 3606 
 3607 
 3608 def shouldResetLayout(prefClass=Prefs):
 3609     """
 3610     Module function to indicate a reset of the layout.
 3611     
 3612     @param prefClass preferences class used as the storage area
 3613     @return flag indicating a reset of the layout (boolean)
 3614     """
 3615     return prefClass.resetLayout
 3616     
 3617 
 3618 def saveResetLayout(prefClass=Prefs):
 3619     """
 3620     Module function to save the reset layout.
 3621     
 3622     @param prefClass preferences class used as the storage area
 3623     """
 3624     if prefClass.resetLayout:
 3625         for key in list(prefClass.geometryDefaults.keys()):
 3626             prefClass.settings.setValue(
 3627                 "Geometry/" + key,
 3628                 prefClass.geometryDefaults[key])
 3629 
 3630 
 3631 def toBool(value):
 3632     """
 3633     Module function to convert a value to bool.
 3634     
 3635     @param value value to be converted
 3636     @return converted data
 3637     """
 3638     if value in ["true", "1", "True"]:
 3639         return True
 3640     elif value in ["false", "0", "False"]:
 3641         return False
 3642     else:
 3643         return bool(value)
 3644 
 3645 
 3646 def toList(value):
 3647     """
 3648     Module function to convert a value to a list.
 3649     
 3650     @param value value to be converted
 3651     @return converted data
 3652     """
 3653     if value is None:
 3654         return []
 3655     elif not isinstance(value, list):
 3656         return [value]
 3657     else:
 3658         return value
 3659 
 3660 
 3661 def toByteArray(value):
 3662     """
 3663     Module function to convert a value to a byte array.
 3664     
 3665     @param value value to be converted
 3666     @return converted data
 3667     """
 3668     if value is None:
 3669         return QByteArray()
 3670     else:
 3671         return value
 3672 
 3673 
 3674 def toDict(value):
 3675     """
 3676     Module function to convert a value to a dictionary.
 3677     
 3678     @param value value to be converted
 3679     @return converted data
 3680     """
 3681     if value is None:
 3682         return {}
 3683     else:
 3684         return value
 3685 
 3686 
 3687 def convertPasswords(oldPassword, newPassword, prefClass=Prefs):
 3688     """
 3689     Module function to convert all passwords.
 3690     
 3691     @param oldPassword current master password (string)
 3692     @param newPassword new master password (string)
 3693     @param prefClass preferences class used as the storage area
 3694     """
 3695     from Utilities.crypto import pwRecode
 3696     for key in ["ProxyPassword/Http", "ProxyPassword/Https",
 3697                 "ProxyPassword/Ftp", ]:
 3698         prefClass.settings.setValue(
 3699             "UI/" + key,
 3700             pwRecode(
 3701                 prefClass.settings.value("UI/" + key,
 3702                                          prefClass.uiDefaults[key]),
 3703                 oldPassword,
 3704                 newPassword
 3705             )
 3706         )
 3707     for key in ["MailServerPassword"]:
 3708         prefClass.settings.setValue(
 3709             "User/" + key,
 3710             pwRecode(
 3711                 prefClass.settings.value("User/" + key,
 3712                                          prefClass.userDefaults[key]),
 3713                 oldPassword,
 3714                 newPassword
 3715             )
 3716         )
 3717     for key in ["SyncFtpPassword", "SyncEncryptionKey"]:
 3718         prefClass.settings.setValue(
 3719             "WebBrowser/" + key,
 3720             pwRecode(
 3721                 prefClass.settings.value("WebBrowser/" + key,
 3722                                          prefClass.webBrowserDefaults[key]),
 3723                 oldPassword,
 3724                 newPassword
 3725             )
 3726         )
 3727 
 3728 
 3729 initPreferences()
 3730 initRecentSettings()
 3731 
 3732 #
 3733 # eflag: noqa = M201, M613