eric7/Preferences/ConfigurationPages/WebBrowserInterfacePage.py

branch
eric7
changeset 8875
67c3ea933787
parent 8761
f05818ae6431
diff -r ccd99849803e -r 67c3ea933787 eric7/Preferences/ConfigurationPages/WebBrowserInterfacePage.py
--- a/eric7/Preferences/ConfigurationPages/WebBrowserInterfacePage.py	Tue Dec 28 19:10:38 2021 +0100
+++ b/eric7/Preferences/ConfigurationPages/WebBrowserInterfacePage.py	Wed Dec 29 16:38:32 2021 +0100
@@ -7,14 +7,22 @@
 Module implementing the Interface configuration page (variant for web browser).
 """
 
+import glob
+import os
+
+from PyQt6.QtCore import QTranslator
 from PyQt6.QtWidgets import QStyleFactory
 
 from EricWidgets.EricPathPicker import EricPathPickerModes
+from EricWidgets.EricApplication import ericApp
 
 from .ConfigurationPageBase import ConfigurationPageBase
 from .Ui_WebBrowserInterfacePage import Ui_WebBrowserInterfacePage
 
 import Preferences
+import Utilities
+
+from eric7config import getConfig
 
 
 class WebBrowserInterfacePage(ConfigurationPageBase,
@@ -35,10 +43,19 @@
         self.styleSheetPicker.setFilters(self.tr(
             "Qt Style Sheets (*.qss);;Cascading Style Sheets (*.css);;"
             "All files (*)"))
+        self.styleSheetPicker.setDefaultDirectory(getConfig("ericStylesDir"))
+        
+        styleIconsPath = ericApp().getStyleIconsPath()
+        self.styleIconsPathPicker.setMode(
+            EricPathPickerModes.DIRECTORY_SHOW_FILES_MODE)
+        self.styleIconsPathPicker.setDefaultDirectory(styleIconsPath)
         
         # set initial values
         self.__populateStyleCombo()
+        self.__populateLanguageCombo()
+        
         self.styleSheetPicker.setText(Preferences.getUI("StyleSheet"))
+        self.styleIconsPathPicker.setText(Preferences.getUI("StyleIconsPath"))
     
     def save(self):
         """
@@ -51,6 +68,18 @@
         Preferences.setUI(
             "StyleSheet",
             self.styleSheetPicker.text())
+        Preferences.setUI(
+            "StyleIconsPath",
+            self.styleIconsPathPicker.text())
+        
+        # save the language settings
+        uiLanguageIndex = self.languageComboBox.currentIndex()
+        uiLanguage = (
+            self.languageComboBox.itemData(uiLanguageIndex)
+            if uiLanguageIndex else
+            None
+        )
+        Preferences.setUILanguage(uiLanguage)
     
     def __populateStyleCombo(self):
         """
@@ -66,6 +95,49 @@
             currentIndex = 0
         self.styleComboBox.setCurrentIndex(currentIndex)
     
+    def __populateLanguageCombo(self):
+        """
+        Private method to initialize the language combo box.
+        """
+        self.languageComboBox.clear()
+        
+        fnlist = (
+            glob.glob("eric7_*.qm") +
+            glob.glob(os.path.join(
+                getConfig('ericTranslationsDir'), "eric7_*.qm")) +
+            glob.glob(os.path.join(Utilities.getConfigDir(), "eric7_*.qm"))
+        )
+        locales = {}
+        for fn in fnlist:
+            locale = os.path.basename(fn)[6:-3]
+            if locale not in locales:
+                translator = QTranslator()
+                translator.load(fn)
+                locales[locale] = (
+                    translator.translate(
+                        "InterfacePage", "English",
+                        "Translate this with your language") +
+                    " ({0})".format(locale)
+                )
+        localeList = sorted(locales.keys())
+        try:
+            uiLanguage = Preferences.getUILanguage()
+            if uiLanguage == "None" or uiLanguage is None:
+                currentIndex = 0
+            elif uiLanguage == "System":
+                currentIndex = 1
+            else:
+                currentIndex = localeList.index(uiLanguage) + 2
+        except ValueError:
+            currentIndex = 0
+        self.languageComboBox.clear()
+        
+        self.languageComboBox.addItem("English (default)", "None")
+        self.languageComboBox.addItem(self.tr('System'), "System")
+        for locale in localeList:
+            self.languageComboBox.addItem(locales[locale], locale)
+        self.languageComboBox.setCurrentIndex(currentIndex)
+
 
 def create(dlg):
     """

eric ide

mercurial