Modified HexEditor color usage such, that it is based on the configured/set palette. eric7

Wed, 29 Dec 2021 16:38:32 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 29 Dec 2021 16:38:32 +0100
branch
eric7
changeset 8875
67c3ea933787
parent 8874
ccd99849803e
child 8876
2001accf55b3

Modified HexEditor color usage such, that it is based on the configured/set palette.

eric7/HexEdit/HexEditMainWindow.py file | annotate | diff | comparison | revisions
eric7/HexEdit/HexEditWidget.py file | annotate | diff | comparison | revisions
eric7/Preferences/ConfigurationDialog.py file | annotate | diff | comparison | revisions
eric7/Preferences/ConfigurationPages/HexEditorPage.py file | annotate | diff | comparison | revisions
eric7/Preferences/ConfigurationPages/HexEditorPage.ui file | annotate | diff | comparison | revisions
eric7/Preferences/ConfigurationPages/WebBrowserInterfacePage.py file | annotate | diff | comparison | revisions
eric7/Preferences/ConfigurationPages/WebBrowserInterfacePage.ui file | annotate | diff | comparison | revisions
eric7/Preferences/ThemeManager.py file | annotate | diff | comparison | revisions
eric7/Preferences/__init__.py file | annotate | diff | comparison | revisions
--- a/eric7/HexEdit/HexEditMainWindow.py	Tue Dec 28 19:10:38 2021 +0100
+++ b/eric7/HexEdit/HexEditMainWindow.py	Wed Dec 29 16:38:32 2021 +0100
@@ -1364,15 +1364,6 @@
             Preferences.getHexEditor("ShowAsciiArea"))
         self.__editor.setHighlighting(
             Preferences.getHexEditor("HighlightChanges"))
-        self.__editor.setHighlightColors(
-            Preferences.getHexEditor("HighlightingForeGround"),
-            Preferences.getHexEditor("HighlightingBackGround"))
-        self.__editor.setSelectionColors(
-            Preferences.getHexEditor("SelectionForeGround"),
-            Preferences.getHexEditor("SelectionBackGround"))
-        self.__editor.setAddressAreaColors(
-            Preferences.getHexEditor("AddressAreaForeGround"),
-            Preferences.getHexEditor("AddressAreaBackGround"))
         self.__editor.setFont(
             Preferences.getHexEditor("Font"))
         
--- a/eric7/HexEdit/HexEditWidget.py	Tue Dec 28 19:10:38 2021 +0100
+++ b/eric7/HexEdit/HexEditWidget.py	Wed Dec 29 16:38:32 2021 +0100
@@ -12,11 +12,11 @@
 from PyQt6.QtCore import (
     pyqtSignal, pyqtSlot, Qt, QByteArray, QTimer, QRect, QBuffer, QIODevice
 )
-from PyQt6.QtGui import (
-    QBrush, QPen, QColor, QFont, QPalette, QKeySequence, QPainter
-)
+from PyQt6.QtGui import QFont, QPalette, QKeySequence, QPainter
 from PyQt6.QtWidgets import QAbstractScrollArea, QApplication
 
+from EricWidgets.EricApplication import ericApp
+
 from .HexEditChunks import HexEditChunks
 from .HexEditUndoStack import HexEditUndoStack
 
@@ -65,9 +65,6 @@
         # Properties
         self.__addressArea = True
         # switch the address area on/off
-        self.__addressAreaBrush = QBrush()
-        self.__addressAreaPen = QPen()
-        # background and pen of the address area
         self.__addressOffset = 0
         # offset into the shown address range
         self.__addressWidth = 4
@@ -78,14 +75,8 @@
         # contents of the hex editor
         self.__highlighting = True
         # switch the highlighting feature on/off
-        self.__highlightingBrush = QBrush()
-        self.__highlightingPen = QPen()
-        # background and pen of highlighted text
         self.__overwriteMode = True
         # set overwrite mode on/off
-        self.__selectionBrush = QBrush()
-        self.__selectionPen = QPen()
-        # background and pen of selected text
         self.__readOnly = False
         # set read only mode on/off
         self.__cursorPosition = 0
@@ -133,17 +124,6 @@
         else:
             self.setFont(QFont(["Monospace"], 10))
         
-        # TODO: make some colors custimizable
-        self.setAddressAreaColors(
-            self.palette().color(QPalette.ColorRole.WindowText),
-            self.palette().alternateBase().color())
-        self.setHighlightColors(
-            self.palette().color(QPalette.ColorRole.WindowText),
-            QColor(0xff, 0xff, 0x99, 0xff))
-        self.setSelectionColors(
-            self.palette().highlightedText().color(),
-            self.palette().highlight().color())
-        
         self.__cursorTimer = QTimer()
         self.__cursorTimer.timeout.connect(self.__updateCursor)
         
@@ -214,28 +194,6 @@
         self.setCursorPosition(self.__cursorPosition)
         self.viewport().update()
     
-    def addressAreaColors(self):
-        """
-        Public method to get the address area colors.
-        
-        @return address area foreground and background colors
-        @rtype tuple of 2 QColor
-        """
-        return self.__addressAreaPen.color(), self.__addressAreaBrush.color()
-    
-    def setAddressAreaColors(self, foreground, background):
-        """
-        Public method to set the address area colors.
-        
-        @param foreground address area foreground color
-        @type QColor
-        @param background address area background color
-        @type QColor
-        """
-        self.__addressAreaPen = QPen(foreground)
-        self.__addressAreaBrush = QBrush(background)
-        self.viewport().update()
-    
     def addressOffset(self):
         """
         Public method to get the address offset.
@@ -506,28 +464,6 @@
         self.__highlighting = on
         self.viewport().update()
     
-    def highlightColors(self):
-        """
-        Public method to get the highlight colors.
-        
-        @return highlight foreground and background colors
-        @rtype tuple of 2 QColor
-        """
-        return self.__highlightingPen.color(), self.__highlightingBrush.color()
-    
-    def setHighlightColors(self, foreground, background):
-        """
-        Public method to set the highlight colors.
-        
-        @param foreground highlight foreground color
-        @type QColor
-        @param background highlight background color
-        @type QColor
-        """
-        self.__highlightingPen = QPen(foreground)
-        self.__highlightingBrush = QBrush(background)
-        self.viewport().update()
-    
     def overwriteMode(self):
         """
         Public method to get the overwrite mode.
@@ -556,28 +492,6 @@
         self.__blink = True
         self.viewport().update(self.__cursorRect)
     
-    def selectionColors(self):
-        """
-        Public method to get the selection colors.
-        
-        @return selection foreground and background colors
-        @rtype tuple of 2 QColor
-        """
-        return self.__selectionPen.color(), self.__selectionBrush.color()
-    
-    def setSelectionColors(self, foreground, background):
-        """
-        Public method to set the selection colors.
-        
-        @param foreground selection foreground color
-        @type QColor
-        @param background selection background color
-        @type QColor
-        """
-        self.__selectionPen = QPen(foreground)
-        self.__selectionBrush = QBrush(background)
-        self.viewport().update()
-    
     def isReadOnly(self):
         """
         Public method to test the read only state.
@@ -1358,6 +1272,34 @@
         """
         painter = QPainter(self.viewport())
         
+        # initialize colors
+        if ericApp().usesDarkPalette():
+            addressAreaForeground = self.palette().color(
+                QPalette.ColorRole.Text)
+            addressAreaBackground = self.palette().color(
+                QPalette.ColorRole.Base).lighter(200)
+            highlightingForeground = self.palette().color(
+                QPalette.ColorRole.HighlightedText).darker(200)
+            highlightingBackground = self.palette().color(
+                QPalette.ColorRole.Highlight).lighter()
+        else:
+            addressAreaForeground = self.palette().color(
+                QPalette.ColorRole.Text)
+            addressAreaBackground = self.palette().color(
+                QPalette.ColorRole.Base).darker()
+            highlightingForeground = self.palette().color(
+                QPalette.ColorRole.HighlightedText).lighter()
+            highlightingBackground = self.palette().color(
+                QPalette.ColorRole.Highlight).darker()
+        selectionForeground = self.palette().color(
+            QPalette.ColorRole.HighlightedText)
+        selectionBackground = self.palette().color(
+            QPalette.ColorRole.Highlight)
+        standardBackground = self.viewport().palette().color(
+            QPalette.ColorRole.Base)
+        standardForeground = self.viewport().palette().color(
+            QPalette.ColorRole.Text)
+        
         if (
             evt.rect() != self.__cursorRect and
             evt.rect() != self.__cursorRectAscii
@@ -1366,27 +1308,22 @@
             pxPosStartY = self.__pxCharHeight
             
             # draw some patterns if needed
-            painter.fillRect(
-                evt.rect(),
-                self.viewport().palette().color(QPalette.ColorRole.Base))
+            painter.fillRect(evt.rect(), standardBackground)
             if self.__addressArea:
                 painter.fillRect(
                     QRect(-pxOfsX, evt.rect().top(),
                           self.__pxPosHexX - self.__pxGapAdrHex // 2 - pxOfsX,
                           self.height()),
-                    self.__addressAreaBrush)
+                    addressAreaBackground)
             if self.__asciiArea:
                 linePos = self.__pxPosAsciiX - (self.__pxGapHexAscii // 2)
                 painter.setPen(Qt.GlobalColor.gray)
                 painter.drawLine(linePos - pxOfsX, evt.rect().top(),
                                  linePos - pxOfsX, self.height())
             
-            painter.setPen(
-                self.viewport().palette().color(QPalette.ColorRole.WindowText))
-            
             # paint the address area
             if self.__addressArea:
-                painter.setPen(self.__addressAreaPen)
+                painter.setPen(addressAreaForeground)
                 address = ""
                 row = 0
                 pxPosY = self.__pxCharHeight
@@ -1402,9 +1339,6 @@
                     pxPosY += self.__pxCharHeight
             
             # paint hex and ascii area
-            colStandard = QPen(
-                self.viewport().palette().color(QPalette.ColorRole.WindowText))
-            
             painter.setBackgroundMode(Qt.BGMode.TransparentMode)
             
             row = 0
@@ -1419,42 +1353,41 @@
                     bPosLine + colIdx < len(self.__dataShown) and
                     colIdx < self.BYTES_PER_LINE
                 ):
-                    c = self.viewport().palette().color(
-                        QPalette.ColorRole.Base)
-                    painter.setPen(colStandard)
+                    background = standardBackground
+                    painter.setPen(standardForeground)
                     
                     posBa = self.__bPosFirst + bPosLine + colIdx
                     if (
                         self.getSelectionBegin() <= posBa and
                         self.getSelectionEnd() > posBa
                     ):
-                        c = self.__selectionBrush.color()
-                        painter.setPen(self.__selectionPen)
+                        background = selectionBackground
+                        painter.setPen(selectionForeground)
                     elif (
                         self.__highlighting and
                         self.__markedShown and
                         self.__markedShown[posBa - self.__bPosFirst]
                     ):
-                        c = self.__highlightingBrush.color()
-                        painter.setPen(self.__highlightingPen)
+                        background = highlightingBackground
+                        painter.setPen(highlightingForeground)
                     
                     # render hex value
-                    r = QRect()
+                    rect = QRect()
                     if colIdx == 0:
-                        r.setRect(
+                        rect.setRect(
                             pxPosX,
                             pxPosY - self.__pxCharHeight +
                             self.__pxSelectionSub,
                             2 * self.__pxCharWidth,
                             self.__pxCharHeight)
                     else:
-                        r.setRect(
+                        rect.setRect(
                             pxPosX - self.__pxCharWidth,
                             pxPosY - self.__pxCharHeight +
                             self.__pxSelectionSub,
                             3 * self.__pxCharWidth,
                             self.__pxCharHeight)
-                    painter.fillRect(r, c)
+                    painter.fillRect(rect, background)
                     hexStr = (
                         chr(self.__hexDataShown[(bPosLine + colIdx) * 2]) +
                         chr(self.__hexDataShown[(bPosLine + colIdx) * 2 + 1])
@@ -1469,13 +1402,13 @@
                             ch = "."
                         else:
                             ch = chr(by)
-                        r.setRect(
+                        rect.setRect(
                             pxPosAsciiX2,
                             pxPosY - self.__pxCharHeight +
                             self.__pxSelectionSub,
                             self.__pxCharWidth,
                             self.__pxCharHeight)
-                        painter.fillRect(r, c)
+                        painter.fillRect(rect, background)
                         painter.drawText(pxPosAsciiX2, pxPosY, ch)
                         pxPosAsciiX2 += self.__pxCharWidth
                     
@@ -1487,14 +1420,11 @@
                 pxPosY += self.__pxCharHeight
         
         painter.setBackgroundMode(Qt.BGMode.TransparentMode)
-        painter.setPen(
-            self.viewport().palette().color(QPalette.ColorRole.WindowText))
-            
+        painter.setPen(standardForeground)
+        
         # paint cursor
         if self.__blink and not self.__readOnly and self.isActiveWindow():
-            painter.fillRect(
-                self.__cursorRect,
-                self.palette().color(QPalette.ColorRole.WindowText))
+            painter.fillRect(self.__cursorRect, standardForeground)
         else:
             if self.__hexDataShown:
                 try:
--- a/eric7/Preferences/ConfigurationDialog.py	Tue Dec 28 19:10:38 2021 +0100
+++ b/eric7/Preferences/ConfigurationDialog.py	Wed Dec 29 16:38:32 2021 +0100
@@ -444,11 +444,30 @@
                 # The dialog module must have the module function 'create' to
                 # create the configuration page. This must have the method
                 # 'save' to save the settings.
+                "interfacePage":
+                [self.tr("Interface"), "preferences-interface",
+                 "WebBrowserInterfacePage", None, None],
                 "hexEditorPage":
                 [self.tr("Hex Editor"), "hexEditor",
                  "HexEditorPage", None, None],
             }
         
+        # TODO: add mode for Mini Editor
+        
+        else:
+            # display mode for generic use
+            self.configItems = {
+                # key : [display string, pixmap name, dialog module name or
+                #        page creation function, parent key,
+                #        reference to configuration page (must always be last)]
+                # The dialog module must have the module function 'create' to
+                # create the configuration page. This must have the method
+                # 'save' to save the settings.
+                "interfacePage":
+                [self.tr("Interface"), "preferences-interface",
+                 "WebBrowserInterfacePage", None, None],
+            }
+        
         # generate the list entries
         self.__expandedEntries = []
         for key in sorted(self.configItems.keys()):
--- a/eric7/Preferences/ConfigurationPages/HexEditorPage.py	Tue Dec 28 19:10:38 2021 +0100
+++ b/eric7/Preferences/ConfigurationPages/HexEditorPage.py	Wed Dec 29 16:38:32 2021 +0100
@@ -48,26 +48,6 @@
         # font
         self.monospacedFont = Preferences.getHexEditor("Font")
         self.monospacedFontSample.setFont(self.monospacedFont)
-
-        # colours
-        self.initColour("HighlightingBackGround",
-                        self.highlightingBackGroundButton,
-                        Preferences.getHexEditor)
-        self.initColour("HighlightingForeGround",
-                        self.highlightingForeGroundButton,
-                        Preferences.getHexEditor)
-        self.initColour("SelectionBackGround",
-                        self.selectionBackGroundButton,
-                        Preferences.getHexEditor)
-        self.initColour("SelectionForeGround",
-                        self.selectionForeGroundButton,
-                        Preferences.getHexEditor)
-        self.initColour("AddressAreaBackGround",
-                        self.addressAreaBackGroundButton,
-                        Preferences.getHexEditor)
-        self.initColour("AddressAreaForeGround",
-                        self.addressAreaForeGroundButton,
-                        Preferences.getHexEditor)
     
     def save(self):
         """
@@ -89,9 +69,6 @@
             "Font", self.monospacedFont)
         Preferences.setHexEditor(
             "RecentNumber", self.recentFilesSpinBox.value())
-        
-        # colours
-        self.saveColours(Preferences.setHexEditor)
     
     @pyqtSlot()
     def on_monospacedFontButton_clicked(self):
--- a/eric7/Preferences/ConfigurationPages/HexEditorPage.ui	Tue Dec 28 19:10:38 2021 +0100
+++ b/eric7/Preferences/ConfigurationPages/HexEditorPage.ui	Wed Dec 29 16:38:32 2021 +0100
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>519</width>
-    <height>664</height>
+    <width>520</width>
+    <height>550</height>
    </rect>
   </property>
   <layout class="QVBoxLayout" name="verticalLayout">
@@ -61,7 +61,7 @@
       <string>Address Area</string>
      </property>
      <layout class="QGridLayout" name="gridLayout_2">
-      <item row="0" column="0" colspan="4">
+      <item row="0" column="0" colspan="2">
        <widget class="QCheckBox" name="addressAreaCheckBox">
         <property name="toolTip">
          <string>Select whether the address area shall be shown</string>
@@ -71,7 +71,7 @@
         </property>
        </widget>
       </item>
-      <item row="1" column="0" colspan="4">
+      <item row="1" column="0" colspan="2">
        <layout class="QHBoxLayout">
         <item>
          <widget class="QLabel" name="textLabel1_20">
@@ -123,52 +123,6 @@
         </item>
        </layout>
       </item>
-      <item row="2" column="0">
-       <widget class="QLabel" name="TextLabel1_3_4">
-        <property name="text">
-         <string>Foreground:</string>
-        </property>
-       </widget>
-      </item>
-      <item row="2" column="1">
-       <widget class="QPushButton" name="addressAreaForeGroundButton">
-        <property name="minimumSize">
-         <size>
-          <width>100</width>
-          <height>0</height>
-         </size>
-        </property>
-        <property name="toolTip">
-         <string>Select the foreground color of the address area</string>
-        </property>
-        <property name="text">
-         <string/>
-        </property>
-       </widget>
-      </item>
-      <item row="2" column="2">
-       <widget class="QLabel" name="TextLabel1_3_2_4">
-        <property name="text">
-         <string>Background:</string>
-        </property>
-       </widget>
-      </item>
-      <item row="2" column="3">
-       <widget class="QPushButton" name="addressAreaBackGroundButton">
-        <property name="minimumSize">
-         <size>
-          <width>100</width>
-          <height>0</height>
-         </size>
-        </property>
-        <property name="toolTip">
-         <string>Select the background color of the address area</string>
-        </property>
-        <property name="text">
-         <string/>
-        </property>
-       </widget>
-      </item>
      </layout>
     </widget>
    </item>
@@ -197,7 +151,7 @@
       <string>Highlighting</string>
      </property>
      <layout class="QGridLayout" name="gridLayout">
-      <item row="0" column="0" colspan="4">
+      <item row="0" column="0" colspan="2">
        <widget class="QCheckBox" name="highlightingCheckBox">
         <property name="toolTip">
          <string>Select whether changed data shall be highlighted</string>
@@ -207,107 +161,6 @@
         </property>
        </widget>
       </item>
-      <item row="1" column="0">
-       <widget class="QLabel" name="TextLabel1_3_2">
-        <property name="text">
-         <string>Foreground:</string>
-        </property>
-       </widget>
-      </item>
-      <item row="1" column="1">
-       <widget class="QPushButton" name="highlightingForeGroundButton">
-        <property name="minimumSize">
-         <size>
-          <width>100</width>
-          <height>0</height>
-         </size>
-        </property>
-        <property name="toolTip">
-         <string>Select the foreground color for highlighted data</string>
-        </property>
-        <property name="text">
-         <string/>
-        </property>
-       </widget>
-      </item>
-      <item row="1" column="2">
-       <widget class="QLabel" name="TextLabel1_3_2_2">
-        <property name="text">
-         <string>Background:</string>
-        </property>
-       </widget>
-      </item>
-      <item row="1" column="3">
-       <widget class="QPushButton" name="highlightingBackGroundButton">
-        <property name="minimumSize">
-         <size>
-          <width>100</width>
-          <height>0</height>
-         </size>
-        </property>
-        <property name="toolTip">
-         <string>Select the background color for highlighted data</string>
-        </property>
-        <property name="text">
-         <string/>
-        </property>
-       </widget>
-      </item>
-     </layout>
-    </widget>
-   </item>
-   <item>
-    <widget class="QGroupBox" name="groupBox_2">
-     <property name="title">
-      <string>Selection</string>
-     </property>
-     <layout class="QHBoxLayout" name="horizontalLayout_2">
-      <item>
-       <widget class="QLabel" name="TextLabel1_3_3">
-        <property name="text">
-         <string>Foreground:</string>
-        </property>
-       </widget>
-      </item>
-      <item>
-       <widget class="QPushButton" name="selectionForeGroundButton">
-        <property name="minimumSize">
-         <size>
-          <width>100</width>
-          <height>0</height>
-         </size>
-        </property>
-        <property name="toolTip">
-         <string>Select the foreground color of the selection</string>
-        </property>
-        <property name="text">
-         <string/>
-        </property>
-       </widget>
-      </item>
-      <item>
-       <widget class="QLabel" name="TextLabel1_3_2_3">
-        <property name="text">
-         <string>Background:</string>
-        </property>
-       </widget>
-      </item>
-      <item>
-       <widget class="QPushButton" name="selectionBackGroundButton">
-        <property name="minimumSize">
-         <size>
-          <width>100</width>
-          <height>0</height>
-         </size>
-        </property>
-        <property name="toolTip">
-         <string>Select the background color of the selection</string>
-        </property>
-        <property name="text">
-         <string/>
-        </property>
-       </widget>
-      </item>
      </layout>
     </widget>
    </item>
@@ -411,14 +264,8 @@
   <tabstop>overwriteCheckBox</tabstop>
   <tabstop>addressAreaCheckBox</tabstop>
   <tabstop>addressAreaWidthSpinBox</tabstop>
-  <tabstop>addressAreaForeGroundButton</tabstop>
-  <tabstop>addressAreaBackGroundButton</tabstop>
   <tabstop>asciiAreaCheckBox</tabstop>
   <tabstop>highlightingCheckBox</tabstop>
-  <tabstop>highlightingForeGroundButton</tabstop>
-  <tabstop>highlightingBackGroundButton</tabstop>
-  <tabstop>selectionForeGroundButton</tabstop>
-  <tabstop>selectionBackGroundButton</tabstop>
   <tabstop>monospacedFontButton</tabstop>
  </tabstops>
  <resources/>
--- 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):
     """
--- a/eric7/Preferences/ConfigurationPages/WebBrowserInterfacePage.ui	Tue Dec 28 19:10:38 2021 +0100
+++ b/eric7/Preferences/ConfigurationPages/WebBrowserInterfacePage.ui	Wed Dec 29 16:38:32 2021 +0100
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>555</width>
-    <height>133</height>
+    <height>365</height>
    </rect>
   </property>
   <layout class="QVBoxLayout" name="verticalLayout">
@@ -70,6 +70,85 @@
        </property>
       </widget>
      </item>
+     <item row="2" column="0">
+      <widget class="QLabel" name="label_6">
+       <property name="text">
+        <string>Style Icons Path:</string>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="1">
+      <widget class="EricPathPicker" name="styleIconsPathPicker" native="true">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="focusPolicy">
+        <enum>Qt::StrongFocus</enum>
+       </property>
+       <property name="toolTip">
+        <string>Enter the path to the icons used within the style sheet (empty for default)</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <widget class="Line" name="line9_2">
+     <property name="frameShape">
+      <enum>QFrame::HLine</enum>
+     </property>
+     <property name="frameShadow">
+      <enum>QFrame::Sunken</enum>
+     </property>
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QLabel" name="TextLabel1_2_2_2">
+     <property name="text">
+      <string>&lt;font color=&quot;#FF0000&quot;&gt;&lt;b&gt;Note:&lt;/b&gt; All settings below are activated at the next startup of the application.&lt;/font&gt;</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <widget class="QLabel" name="languageLabel">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="text">
+        <string>Language:</string>
+       </property>
+       <property name="buddy">
+        <cstring>languageComboBox</cstring>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QComboBox" name="languageComboBox">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="toolTip">
+        <string>Select the interface language.</string>
+       </property>
+       <property name="whatsThis">
+        <string>The interface language can be selected from this list. If &quot;system&quot; is selected, the interface language is determined by the system. The selection of &quot;none&quot; means, that the default language will be used.</string>
+       </property>
+      </widget>
+     </item>
     </layout>
    </item>
    <item>
@@ -97,6 +176,8 @@
  </customwidgets>
  <tabstops>
   <tabstop>styleComboBox</tabstop>
+  <tabstop>styleSheetPicker</tabstop>
+  <tabstop>styleIconsPathPicker</tabstop>
  </tabstops>
  <resources/>
  <connections/>
--- a/eric7/Preferences/ThemeManager.py	Tue Dec 28 19:10:38 2021 +0100
+++ b/eric7/Preferences/ThemeManager.py	Wed Dec 29 16:38:32 2021 +0100
@@ -28,8 +28,6 @@
     ColorKeyPatternList = [
         "Diff/.*Color",
         "Editor/Colour/",
-        "HexEditor/.*BackGround",
-        "HexEditor/.*ForeGround",
         "IRC/.*Colou?r",
         "Project/Colour",
         "Python/.*Color",
--- a/eric7/Preferences/__init__.py	Tue Dec 28 19:10:38 2021 +0100
+++ b/eric7/Preferences/__init__.py	Wed Dec 29 16:38:32 2021 +0100
@@ -1402,12 +1402,6 @@
         "OpenInOverwriteMode": True,
         "OpenReadOnly": False,
         "HighlightChanges": True,
-        "HighlightingBackGround": QColor("#ffff99"),
-        "HighlightingForeGround": QColor(Qt.GlobalColor.black),
-        "SelectionBackGround": QColor("#308cc6"),
-        "SelectionForeGround": QColor(Qt.GlobalColor.white),
-        "AddressAreaBackGround": QColor("#efedec"),
-        "AddressAreaForeGround": QColor(Qt.GlobalColor.black),
         "RecentNumber": 9,
     }
     if Globals.isWindowsPlatform():
@@ -3345,11 +3339,6 @@
                  "OpenReadOnly", "HighlightChanges"]:
         return toBool(Prefs.settings.value(
             "HexEditor/" + key, Prefs.hexEditorDefaults[key]))
-    elif key in ["HighlightingBackGround", "HighlightingForeGround",
-                 "SelectionBackGround", "SelectionForeGround",
-                 "AddressAreaBackGround", "AddressAreaForeGround"]:
-        return QColor(Prefs.settings.value(
-            "HexEditor/" + key, Prefs.hexEditorDefaults[key]))
     elif key in ["Font"]:
         f = QFont()
         f.fromString(Prefs.settings.value(
@@ -3367,15 +3356,7 @@
     @param key the key of the setting to be set
     @param value the value to be set
     """
-    if key in ["HighlightingBackGround", "HighlightingForeGround",
-               "SelectionBackGround", "SelectionForeGround",
-               "AddressAreaBackGround", "AddressAreaForeGround"]:
-        if value.alpha() < 255:
-            val = "#{0:8x}".format(value.rgba())
-        else:
-            val = value.name()
-        Prefs.settings.setValue("HexEditor/" + key, val)
-    elif key in ["Font"]:
+    if key in ["Font"]:
         Prefs.settings.setValue("HexEditor/" + key, value.toString())
     else:
         Prefs.settings.setValue("HexEditor/" + key, value)

eric ide

mercurial