src/eric7/EricWidgets/EricProxyStyle.py

branch
eric7
changeset 10933
95a15b70f7bb
parent 10439
21c28b0f9e41
child 11090
f5f5f5803935
--- a/src/eric7/EricWidgets/EricProxyStyle.py	Fri Sep 27 11:00:27 2024 +0200
+++ b/src/eric7/EricWidgets/EricProxyStyle.py	Fri Sep 27 17:27:11 2024 +0200
@@ -11,8 +11,6 @@
 from PyQt6.QtCore import Qt
 from PyQt6.QtWidgets import QApplication, QProxyStyle, QStyle
 
-from eric7 import Preferences
-
 
 class EricProxyStyle(QProxyStyle):
     """
@@ -20,6 +18,21 @@
     platform default.
     """
 
+    def __init__(self, style=None, itemClickBehavior="default"):
+        """
+        Constructor
+
+        @param style style object or style name or None for the default native style
+            (defaults to None)
+        @type QStyle, str or None (optional)
+        @param itemClickBehavior string describing the item activation behavior (one of
+            "default", "doubleclick" or "singleclick") (defaults to "default")
+        @type str (optional)
+        """
+        super().__init__(style)
+
+        self.__itemClickBehavior = itemClickBehavior
+
     def styleHint(self, hint, option=None, widget=None, returnData=None):
         """
         Public method returning a style hint for the given widget described by the
@@ -36,14 +49,15 @@
         @return integer representing the style hint
         @rtype int
         """
-        if hint == QStyle.StyleHint.SH_ItemView_ActivateItemOnSingleClick:
+        if (
+            hint == QStyle.StyleHint.SH_ItemView_ActivateItemOnSingleClick
+            and QApplication.keyboardModifiers() == Qt.KeyboardModifier.NoModifier
+        ):
             # Activate item with a single click?
-            activate = Preferences.getUI("ActivateItemOnSingleClick")
-            if QApplication.keyboardModifiers() == Qt.KeyboardModifier.NoModifier:
-                if activate == "singleclick":
-                    return 1
-                elif activate == "doubleclick":
-                    return 0
+            if self.__itemClickBehavior == "singleclick":
+                return 1
+            elif self.__itemClickBehavior == "doubleclick":
+                return 0
 
         # return the default style hint
         return super().styleHint(

eric ide

mercurial