src/eric7/EricWidgets/EricSideBar.py

branch
eric7
changeset 10500
40fc136e7002
parent 10439
21c28b0f9e41
child 10689
3ede487187f2
equal deleted inserted replaced
10499:71208bcc7d99 10500:40fc136e7002
8 """ 8 """
9 9
10 import enum 10 import enum
11 import json 11 import json
12 12
13 from PyQt6.QtCore import QSize, Qt, pyqtSlot 13 from PyQt6.QtCore import QSize, Qt, pyqtSignal, pyqtSlot
14 from PyQt6.QtWidgets import QBoxLayout, QStackedWidget, QWidget 14 from PyQt6.QtWidgets import QBoxLayout, QStackedWidget, QWidget
15 15
16 from .EricIconBar import EricIconBar 16 from .EricIconBar import EricIconBar
17 17
18 18
29 29
30 class EricSideBar(QWidget): 30 class EricSideBar(QWidget):
31 """ 31 """
32 Class implementing a sidebar with a widget area, that is hidden or shown, 32 Class implementing a sidebar with a widget area, that is hidden or shown,
33 if the current tab is clicked again. 33 if the current tab is clicked again.
34
35 @signal currentChanged(index) emitted to indicate a change of the current
36 index
34 """ 37 """
35 38
36 Version = 4 39 Version = 4
40
41 currentChanged = pyqtSignal(int)
37 42
38 def __init__( 43 def __init__(
39 self, orientation=None, iconBarSize=EricIconBar.DefaultBarSize, parent=None 44 self, orientation=None, iconBarSize=EricIconBar.DefaultBarSize, parent=None
40 ): 45 ):
41 """ 46 """
146 @type int 151 @type int
147 """ 152 """
148 if self.isMinimized(): 153 if self.isMinimized():
149 self.__expandIt() 154 self.__expandIt()
150 155
156 self.currentChanged.emit(index)
157
151 def addTab(self, widget, icon, label=None): 158 def addTab(self, widget, icon, label=None):
152 """ 159 """
153 Public method to add a tab to the sidebar. 160 Public method to add a tab to the sidebar.
154 161
155 @param widget reference to the widget to add 162 @param widget reference to the widget to add
198 self.__iconBar.removeIcon(index) 205 self.__iconBar.removeIcon(index)
199 if self.__orientation in (EricSideBarSide.NORTH, EricSideBarSide.SOUTH): 206 if self.__orientation in (EricSideBarSide.NORTH, EricSideBarSide.SOUTH):
200 self.__minSize = self.minimumSizeHint().height() 207 self.__minSize = self.minimumSizeHint().height()
201 else: 208 else:
202 self.__minSize = self.minimumSizeHint().width() 209 self.__minSize = self.minimumSizeHint().width()
210
211 def setTabIcon(self, index, icon):
212 """
213 Public method to set the icon at the given index.
214
215 @param index icon index
216 @type int
217 @param icon reference to the icon
218 @type QIcon
219 """
220 self.__iconBar.setIcon(index, icon)
203 221
204 def clear(self): 222 def clear(self):
205 """ 223 """
206 Public method to remove all tabs. 224 Public method to remove all tabs.
207 """ 225 """

eric ide

mercurial