E5Gui/E5SideBar.py

changeset 945
8cd4d08fa9f6
parent 818
476d99fd8981
child 1131
7781e396c903
equal deleted inserted replaced
944:1b59c4ba121e 945:8cd4d08fa9f6
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)
486 if state.isEmpty(): 487 if state.isEmpty():
487 return False 488 return False
488 489
489 data = QByteArray(state) 490 data = QByteArray(state)
490 stream = QDataStream(data, QIODevice.ReadOnly) 491 stream = QDataStream(data, QIODevice.ReadOnly)
491 stream.readUInt16() # version 492 stream.readUInt16() # version
492 minimized = stream.readBool() 493 minimized = stream.readBool()
493 494
494 if minimized: 495 if minimized:
495 self.shrink() 496 self.shrink()
496 497

eric ide

mercurial