11 from PyQt4.QtGui import QTabBar, QWidget, QStackedWidget, QBoxLayout, QToolButton |
11 from PyQt4.QtGui import QTabBar, QWidget, QStackedWidget, QBoxLayout, QToolButton |
12 |
12 |
13 from E5Gui.E5Application import e5App |
13 from E5Gui.E5Application import e5App |
14 |
14 |
15 import UI.PixmapCache |
15 import UI.PixmapCache |
|
16 |
16 |
17 |
17 class E5SideBar(QWidget): |
18 class E5SideBar(QWidget): |
18 """ |
19 """ |
19 Class implementing a sidebar with a widget area, that is hidden or shown, if the |
20 Class implementing a sidebar with a widget area, that is hidden or shown, if the |
20 current tab is clicked again. |
21 current tab is clicked again. |
21 """ |
22 """ |
22 Version = 1 |
23 Version = 1 |
23 |
24 |
24 North = 0 |
25 North = 0 |
25 East = 1 |
26 East = 1 |
26 South = 2 |
27 South = 2 |
27 West = 3 |
28 West = 3 |
28 |
29 |
29 def __init__(self, orientation = None, parent = None): |
30 def __init__(self, orientation=None, parent=None): |
30 """ |
31 """ |
31 Constructor |
32 Constructor |
32 |
33 |
33 @param orientation orientation of the sidebar widget (North, East, South, West) |
34 @param orientation orientation of the sidebar widget (North, East, South, West) |
34 @param parent parent widget (QWidget) |
35 @param parent parent widget (QWidget) |
63 self.__bigSize = QSize() |
64 self.__bigSize = QSize() |
64 |
65 |
65 self.splitter = None |
66 self.splitter = None |
66 self.splitterSizes = [] |
67 self.splitterSizes = [] |
67 |
68 |
68 self.__hasFocus = False # flag storing if this widget or any child has the focus |
69 self.__hasFocus = False # flag storing if this widget or any child has the focus |
69 self.__autoHide = False |
70 self.__autoHide = False |
70 |
71 |
71 self.__tabBar.installEventFilter(self) |
72 self.__tabBar.installEventFilter(self) |
72 |
73 |
73 self.__orientation = E5SideBar.North |
74 self.__orientation = E5SideBar.North |
182 self.nextTab() |
183 self.nextTab() |
183 return True |
184 return True |
184 |
185 |
185 return QWidget.eventFilter(self, obj, evt) |
186 return QWidget.eventFilter(self, obj, evt) |
186 |
187 |
187 def addTab(self, widget, iconOrLabel, label = None): |
188 def addTab(self, widget, iconOrLabel, label=None): |
188 """ |
189 """ |
189 Public method to add a tab to the sidebar. |
190 Public method to add a tab to the sidebar. |
190 |
191 |
191 @param widget reference to the widget to add (QWidget) |
192 @param widget reference to the widget to add (QWidget) |
192 @param iconOrLabel reference to the icon or the labeltext of the tab |
193 @param iconOrLabel reference to the icon or the labeltext of the tab |
198 self.__tabBar.addTab(iconOrLabel, label) |
199 self.__tabBar.addTab(iconOrLabel, label) |
199 else: |
200 else: |
200 self.__tabBar.addTab(iconOrLabel) |
201 self.__tabBar.addTab(iconOrLabel) |
201 self.__stackedWidget.addWidget(widget) |
202 self.__stackedWidget.addWidget(widget) |
202 |
203 |
203 def insertTab(self, index, widget, iconOrLabel, label = None): |
204 def insertTab(self, index, widget, iconOrLabel, label=None): |
204 """ |
205 """ |
205 Public method to insert a tab into the sidebar. |
206 Public method to insert a tab into the sidebar. |
206 |
207 |
207 @param index the index to insert the tab at (integer) |
208 @param index the index to insert the tab at (integer) |
208 @param widget reference to the widget to insert (QWidget) |
209 @param widget reference to the widget to insert (QWidget) |