eric7/EricWidgets/EricSideBar.py

branch
eric7
changeset 8584
90391fda03d5
parent 8583
aac629a05f8b
child 8587
78971b458d25
--- a/eric7/EricWidgets/EricSideBar.py	Mon Sep 06 19:52:37 2021 +0200
+++ b/eric7/EricWidgets/EricSideBar.py	Wed Sep 08 19:47:32 2021 +0200
@@ -11,7 +11,6 @@
 import json
 
 from PyQt6.QtCore import pyqtSlot, Qt, QSize
-from PyQt6.QtGui import QIcon
 from PyQt6.QtWidgets import QWidget, QStackedWidget, QBoxLayout
 
 from .EricIconBar import EricIconBar
@@ -34,6 +33,7 @@
     """
     Version = 3
     
+    # TODO: make icon bar size configurable with default
     def __init__(self, orientation=None, parent=None):
         """
         Constructor
@@ -46,7 +46,7 @@
         super().__init__(parent)
         
         # initial layout is done for NORTH
-        self.__iconBar = EricIconBar(Qt.Orientation.Horizontal)
+        self.__iconBar = EricIconBar(orientation=Qt.Orientation.Horizontal)
         
         self.__stackedWidget = QStackedWidget(self)
         self.__stackedWidget.setContentsMargins(0, 0, 0, 0)
@@ -189,12 +189,10 @@
         @param widget reference to the widget to add
         @type QWidget
         @param icon reference to the icon of the widget
-        @type QIcon or QPixmap
+        @type QIcon
         @param label the label text of the widget
         @type str
         """
-        if isinstance(icon, QIcon):
-            icon = icon.pixmap(48, 48)
         self.__iconBar.addIcon(icon, label)
         self.__stackedWidget.addWidget(widget)
         if self.__orientation in (
@@ -213,12 +211,10 @@
         @param widget reference to the widget to insert
         @type QWidget
         @param icon reference to the icon of the widget
-        @type QIcon or QPixmap
+        @type QIcon
         @param label the label text of the widget
         @type str
         """
-        if isinstance(icon, QIcon):
-            icon = icon.pixmap(48, 48)
         self.__iconBar.insertIcon(index, icon, label)
         
         self.__stackedWidget.insertWidget(index, widget)
@@ -387,6 +383,26 @@
         """
         return self.__iconBar.color()
     
+    def setIconBarSize(self, barSize):
+        """
+        Public method to set the icon bar size.
+        
+        @param barSize size category for the bar (one of 'xs', 'sm', 'md',
+            'lg', 'xl', 'xxl')
+        @type str
+        """
+        self.__iconBar.setBarSize(barSize)
+    
+    def barSize(self):
+        """
+        Public method to get the icon bar size.
+        
+        @return barSize size category for the bar (one of 'xs', 'sm', 'md',
+            'lg', 'xl', 'xxl')
+        @rtype str
+        """
+        return self.__iconBar.barSize()
+    
     def saveState(self):
         """
         Public method to save the state of the sidebar.

eric ide

mercurial