PluginPipxInterface.py

changeset 52
d9792a2b46fd
parent 49
ec976c5b88ae
child 56
2284c6696655
diff -r 0143a56b2831 -r d9792a2b46fd PluginPipxInterface.py
--- a/PluginPipxInterface.py	Wed Jul 31 13:32:27 2024 +0200
+++ b/PluginPipxInterface.py	Thu Aug 01 11:09:54 2024 +0200
@@ -36,7 +36,7 @@
     "author": "Detlev Offenbach <detlev@die-offenbachs.de>",
     "autoactivate": True,
     "deactivateable": True,
-    "version": "10.3.0",
+    "version": "10.3.1",
     "className": "PluginPipxInterface",
     "packageName": "PipxInterface",
     "shortDescription": "Graphical interface to the 'pipx' command.",
@@ -257,8 +257,10 @@
             self.__ui.rToolboxDock.show()
             self.__ui.rToolbox.setCurrentWidget(self.__widget)
         elif uiLayoutType == "Sidebars":
-            self.__ui.rightSidebar.show()
-            self.__ui.rightSidebar.setCurrentWidget(self.__widget)
+            try:
+                self.__ui.activateLeftRightSidebarWidget(self.__widget)
+            except AttributeError:
+                self.__activateLeftRightSidebarWidget(self.__widget)
         else:
             self.__widget.show()
         self.__widget.setFocus(Qt.FocusReason.ActiveWindowFocusReason)
@@ -283,13 +285,20 @@
             )
         elif uiLayoutType == "Sidebars":
             iconName = "pipxOutdated96" if outdated else "pipx96"
-            index = self.__ui.rightSidebar.indexOf(self.__widget)
-            self.__ui.rightSidebar.setTabIcon(
-                index,
-                EricPixmapCache.getIcon(
-                    os.path.join("PipxInterface", "icons", iconName)
-                ),
-            )
+            try:
+                self.__ui.setLeftRightSidebarWidgetIcon(
+                    self.__widget,
+                    EricPixmapCache.getIcon(
+                        os.path.join("PipxInterface", "icons", iconName)
+                    ),
+                )
+            except AttributeError:
+                self.__setLeftRightSidebarWidgetIcon(
+                    self.__widget,
+                    EricPixmapCache.getIcon(
+                        os.path.join("PipxInterface", "icons", iconName)
+                    ),
+                )
 
     def getPreferences(self, key):
         """
@@ -336,6 +345,45 @@
         """
         Preferences.Prefs.settings.setValue(self.PreferencesKey + "/" + key, value)
 
+    ############################################################################
+    ## Methods for backward compatibility with eric-ide < 24.9
+    ############################################################################
+
+    def __activateLeftRightSidebarWidget(self, widget):
+        """
+        Private method to activate the given widget in the left or right
+        sidebar.
+
+        @param widget reference to the widget to be activated
+        @type QWidget
+        """
+        # This is for backward compatibility with eric-ide < 24.9.
+        sidebar = (
+            self.__ui.leftSidebar
+            if Preferences.getUI("CombinedLeftRightSidebar")
+            else self.__ui.rightSidebar
+        )
+        sidebar.show()
+        sidebar.setCurrentWidget(widget)
+
+    def __setLeftRightSidebarWidgetIcon(self, widget, icon):
+        """
+        Private method to set the icon of the given widget in the left or right
+        sidebar.
+
+        @param widget reference to the widget to set the icon for
+        @type QWidget
+        @param icon icon to be set
+        @type QIcon
+        """
+        sidebar = (
+            self.__ui.leftSidebar
+            if Preferences.getUI("CombinedLeftRightSidebar")
+            else self.__ui.rightSidebar
+        )
+        index = sidebar.indexOf(widget)
+        sidebar.setTabIcon(index, icon)
+
 
 def installDependencies(pipInstall):
     """

eric ide

mercurial