eric6/Preferences/__init__.py

branch
maintenance
changeset 7214
f434af227a41
parent 7035
d2036d7f5ef6
parent 7161
728018c32b09
child 7286
7eb04391adf7
--- a/eric6/Preferences/__init__.py	Sat Aug 03 11:34:00 2019 +0200
+++ b/eric6/Preferences/__init__.py	Sat Sep 07 12:59:54 2019 +0200
@@ -47,9 +47,7 @@
 
 from E5Network.E5Ftp import E5FtpProxyType
 
-from Globals import settingsNameOrganization, settingsNameGlobal, \
-    settingsNameRecent, isWindowsPlatform, getPyQt5ModulesDirectory, \
-    qVersionTuple
+import Globals
 
 from Project.ProjectBrowserFlags import SourcesBrowserFlag, FormsBrowserFlag, \
     ResourcesBrowserFlag, TranslationsBrowserFlag, InterfacesBrowserFlag, \
@@ -168,6 +166,7 @@
         "ShowCondaPackageManager": True,        # right side
         "ShowCooperation": True,                # right side
         "ShowIrc": True,                        # right side
+        "ShowMicroPython": True,                # right side
         "ShowNumbersViewer": True,              # bottom side
         "ViewProfiles2": {
             "edit": [
@@ -626,7 +625,7 @@
         "YAMLFoldComment": False,
     }
     
-    if isWindowsPlatform():
+    if Globals.isWindowsPlatform():
         editorDefaults["EOLMode"] = QsciScintilla.EolWindows
     else:
         editorDefaults["EOLMode"] = QsciScintilla.EolUnix
@@ -1558,7 +1557,7 @@
         "AddressAreaForeGround": QColor(Qt.black),
         "RecentNumber": 9,
     }
-    if isWindowsPlatform():
+    if Globals.isWindowsPlatform():
         hexEditorDefaults["Font"] = "Courier,10,-1,5,50,0,0,0,0,0"
     else:
         hexEditorDefaults["Font"] = "Monospace,10,-1,5,50,0,0,0,0,0"
@@ -1590,6 +1589,28 @@
     pipDefaults = {
         "PipSearchIndex": "",           # used by the search command
     }
+    
+    # defaults for MicroPython
+    microPythonDefaults = {
+        "SerialTimeout": 2000,          # timeout in milliseconds
+        "ReplLineWrap": True,           # wrap the REPL lines
+        "SyncTimeAfterConnect": True,
+        "ShowHiddenLocal": True,
+        "ShowHiddenDevice": True,
+        "MpyCrossCompiler": "",         # path of the mpy-cross compiler
+        "MicroPythonDocuUrl":
+            "https://docs.micropython.org/en/latest/",
+        "CircuitPythonDocuUrl":
+            "https://circuitpython.readthedocs.io/en/latest/",
+        "MicrobitDocuUrl":
+            "https://microbit-micropython.readthedocs.io/en/latest/",
+    }
+    if Globals.isWindowsPlatform():
+        microPythonDefaults["ColorScheme"] = "Windows 10"
+    elif Globals.isMacPlatform():
+        microPythonDefaults["ColorScheme"] = "xterm"
+    else:
+        microPythonDefaults["ColorScheme"] = "Ubuntu"
 
 
 def readToolGroups(prefClass=Prefs):
@@ -1693,13 +1714,13 @@
     """
     Prefs.settings = QSettings(
         QSettings.IniFormat, QSettings.UserScope,
-        settingsNameOrganization, settingsNameGlobal)
-    if not isWindowsPlatform():
+        Globals.settingsNameOrganization, Globals.settingsNameGlobal)
+    if not Globals.isWindowsPlatform():
         hp = QDir.homePath()
         dn = QDir(hp)
         dn.mkdir(".eric6")
-    QCoreApplication.setOrganizationName(settingsNameOrganization)
-    QCoreApplication.setApplicationName(settingsNameGlobal)
+    QCoreApplication.setOrganizationName(Globals.settingsNameOrganization)
+    QCoreApplication.setApplicationName(Globals.settingsNameGlobal)
     try:
         Prefs.settings.setAtomicSyncRequired(False)
     except AttributeError:
@@ -1789,7 +1810,7 @@
     """
     Prefs.rsettings = QSettings(
         QSettings.IniFormat, QSettings.UserScope,
-        settingsNameOrganization, settingsNameRecent)
+        Globals.settingsNameOrganization, Globals.settingsNameRecent)
     
 
 def getVarFilters(prefClass=Prefs):
@@ -1995,7 +2016,7 @@
                "ShowCodeDocumentationViewer", "ShowPyPIPackageManager",
                "ShowCondaPackageManager", "ShowCooperation", "ShowIrc",
                "ShowTemplateViewer", "ShowFileBrowser", "ShowSymbolsViewer",
-               "ShowNumbersViewer", "UseNativeMenuBar"]:
+               "ShowNumbersViewer", "ShowMicroPython", "UseNativeMenuBar"]:
         return toBool(prefClass.settings.value(
             "UI/" + key, prefClass.uiDefaults[key]))
     elif key in ["TabViewManagerFilenameLength", "CaptionFilenameLength",
@@ -3201,7 +3222,7 @@
     @param prefClass preferences class used as the storage area
     @return the requested setting (string)
     """
-    if qVersionTuple() < (5, 0, 0):
+    if Globals.qVersionTuple() < (5, 0, 0):
         s = prefClass.settings.value(
             "Qt/Qt4TranslationsDir",
             prefClass.qtDefaults["Qt4TranslationsDir"])
@@ -3212,14 +3233,15 @@
     if s == "":
         s = os.getenv("QTTRANSLATIONSDIR", "")
     if s == "":
-        if qVersionTuple() < (5, 0, 0):
+        if Globals.qVersionTuple() < (5, 0, 0):
             s = os.getenv("QT4TRANSLATIONSDIR", "")
         else:
             s = os.getenv("QT5TRANSLATIONSDIR", "")
     if s == "":
         s = QLibraryInfo.location(QLibraryInfo.TranslationsPath)
-    if s == "" and isWindowsPlatform():
-        transPath = os.path.join(getPyQt5ModulesDirectory(), "translations")
+    if s == "" and Globals.isWindowsPlatform():
+        transPath = os.path.join(Globals.getPyQt5ModulesDirectory(),
+                                 "translations")
         if os.path.exists(transPath):
             s = transPath
     return s
@@ -3803,6 +3825,40 @@
     prefClass.settings.setValue("Pip/" + key, value)
 
 
+def getMicroPython(key, prefClass=Prefs):
+    """
+    Module function to retrieve the MicroPython related settings.
+    
+    @param key the key of the value to get
+    @param prefClass preferences class used as the storage area
+    @return the requested MicroPython value
+    """
+    if key in ("SerialTimeout"):
+        return int(prefClass.settings.value(
+            "MicroPython/" + key,
+            prefClass.microPythonDefaults[key]))
+    elif key in ["ReplLineWrap", "SyncTimeAfterConnect", "ShowHiddenLocal",
+                 "ShowHiddenDevice"]:
+        return toBool(prefClass.settings.value(
+            "MicroPython/" + key,
+            prefClass.microPythonDefaults[key]))
+    else:
+        return prefClass.settings.value(
+            "MicroPython/" + key,
+            prefClass.microPythonDefaults[key])
+
+
+def setMicroPython(key, value, prefClass=Prefs):
+    """
+    Module function to store the pip MicroPython settings.
+    
+    @param key the key of the setting to be set
+    @param value the value to be set
+    @param prefClass preferences class used as the storage area
+    """
+    prefClass.settings.setValue("MicroPython/" + key, value)
+
+
 def getGeometry(key, prefClass=Prefs):
     """
     Module function to retrieve the display geometry.

eric ide

mercurial