eric6/E5Gui/E5SideBar.py

changeset 8143
2c730d5fd177
parent 7923
91e843545d9a
child 8218
7c09585bd960
equal deleted inserted replaced
8141:27f636beebad 8143:2c730d5fd177
43 """ 43 """
44 super(E5SideBar, self).__init__(parent) 44 super(E5SideBar, self).__init__(parent)
45 45
46 self.__tabBar = QTabBar() 46 self.__tabBar = QTabBar()
47 self.__tabBar.setDrawBase(True) 47 self.__tabBar.setDrawBase(True)
48 self.__tabBar.setShape(QTabBar.RoundedNorth) 48 self.__tabBar.setShape(QTabBar.Shape.RoundedNorth)
49 self.__tabBar.setUsesScrollButtons(True) 49 self.__tabBar.setUsesScrollButtons(True)
50 self.__tabBar.setDrawBase(False) 50 self.__tabBar.setDrawBase(False)
51 self.__stackedWidget = QStackedWidget(self) 51 self.__stackedWidget = QStackedWidget(self)
52 self.__stackedWidget.setContentsMargins(0, 0, 0, 0) 52 self.__stackedWidget.setContentsMargins(0, 0, 0, 0)
53 self.__autoHideButton = QToolButton() 53 self.__autoHideButton = QToolButton()
55 self.__autoHideButton.setIcon( 55 self.__autoHideButton.setIcon(
56 UI.PixmapCache.getIcon("autoHideOff")) 56 UI.PixmapCache.getIcon("autoHideOff"))
57 self.__autoHideButton.setChecked(True) 57 self.__autoHideButton.setChecked(True)
58 self.__autoHideButton.setToolTip( 58 self.__autoHideButton.setToolTip(
59 self.tr("Deselect to activate automatic collapsing")) 59 self.tr("Deselect to activate automatic collapsing"))
60 self.barLayout = QBoxLayout(QBoxLayout.LeftToRight) 60 self.barLayout = QBoxLayout(QBoxLayout.Direction.LeftToRight)
61 self.barLayout.setContentsMargins(0, 0, 0, 0) 61 self.barLayout.setContentsMargins(0, 0, 0, 0)
62 self.layout = QBoxLayout(QBoxLayout.TopToBottom) 62 self.layout = QBoxLayout(QBoxLayout.Direction.TopToBottom)
63 self.layout.setContentsMargins(0, 0, 0, 0) 63 self.layout.setContentsMargins(0, 0, 0, 0)
64 self.layout.setSpacing(0) 64 self.layout.setSpacing(0)
65 self.barLayout.addWidget(self.__autoHideButton) 65 self.barLayout.addWidget(self.__autoHideButton)
66 self.barLayout.addWidget(self.__tabBar) 66 self.barLayout.addWidget(self.__tabBar)
67 self.layout.addLayout(self.barLayout) 67 self.layout.addLayout(self.barLayout)
237 @param obj reference to the object (QObject) 237 @param obj reference to the object (QObject)
238 @param evt reference to the event object (QEvent) 238 @param evt reference to the event object (QEvent)
239 @return flag indicating, if the event was handled (boolean) 239 @return flag indicating, if the event was handled (boolean)
240 """ 240 """
241 if obj == self.__tabBar: 241 if obj == self.__tabBar:
242 if evt.type() == QEvent.MouseButtonPress: 242 if evt.type() == QEvent.Type.MouseButtonPress:
243 pos = evt.pos() 243 pos = evt.pos()
244 for i in range(self.__tabBar.count()): 244 for i in range(self.__tabBar.count()):
245 if self.__tabBar.tabRect(i).contains(pos): 245 if self.__tabBar.tabRect(i).contains(pos):
246 break 246 break
247 247
251 else: 251 else:
252 self.shrink() 252 self.shrink()
253 return True 253 return True
254 elif self.isMinimized(): 254 elif self.isMinimized():
255 self.expand() 255 self.expand()
256 elif evt.type() == QEvent.Wheel: 256 elif evt.type() == QEvent.Type.Wheel:
257 delta = evt.angleDelta().y() 257 delta = evt.angleDelta().y()
258 if delta > 0: 258 if delta > 0:
259 self.prevTab() 259 self.prevTab()
260 else: 260 else:
261 self.nextTab() 261 self.nextTab()
437 Public method to set the orientation of the sidebar. 437 Public method to set the orientation of the sidebar.
438 438
439 @param orient orientation of the sidebar (North, East, South, West) 439 @param orient orientation of the sidebar (North, East, South, West)
440 """ 440 """
441 if orient == E5SideBar.North: 441 if orient == E5SideBar.North:
442 self.__tabBar.setShape(QTabBar.RoundedNorth) 442 self.__tabBar.setShape(QTabBar.Shape.RoundedNorth)
443 self.__tabBar.setSizePolicy( 443 self.__tabBar.setSizePolicy(
444 QSizePolicy.Expanding, QSizePolicy.Preferred) 444 QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Preferred)
445 self.barLayout.setDirection(QBoxLayout.LeftToRight) 445 self.barLayout.setDirection(QBoxLayout.Direction.LeftToRight)
446 self.layout.setDirection(QBoxLayout.TopToBottom) 446 self.layout.setDirection(QBoxLayout.Direction.TopToBottom)
447 self.layout.setAlignment(self.barLayout, Qt.AlignLeft) 447 self.layout.setAlignment(self.barLayout,
448 Qt.AlignmentFlag.AlignLeft)
448 elif orient == E5SideBar.East: 449 elif orient == E5SideBar.East:
449 self.__tabBar.setShape(QTabBar.RoundedEast) 450 self.__tabBar.setShape(QTabBar.Shape.RoundedEast)
450 self.__tabBar.setSizePolicy( 451 self.__tabBar.setSizePolicy(
451 QSizePolicy.Preferred, QSizePolicy.Expanding) 452 QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Expanding)
452 self.barLayout.setDirection(QBoxLayout.TopToBottom) 453 self.barLayout.setDirection(QBoxLayout.Direction.TopToBottom)
453 self.layout.setDirection(QBoxLayout.RightToLeft) 454 self.layout.setDirection(QBoxLayout.Direction.RightToLeft)
454 self.layout.setAlignment(self.barLayout, Qt.AlignTop) 455 self.layout.setAlignment(self.barLayout, Qt.AlignmentFlag.AlignTop)
455 elif orient == E5SideBar.South: 456 elif orient == E5SideBar.South:
456 self.__tabBar.setShape(QTabBar.RoundedSouth) 457 self.__tabBar.setShape(QTabBar.Shape.RoundedSouth)
457 self.__tabBar.setSizePolicy( 458 self.__tabBar.setSizePolicy(
458 QSizePolicy.Expanding, QSizePolicy.Preferred) 459 QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Preferred)
459 self.barLayout.setDirection(QBoxLayout.LeftToRight) 460 self.barLayout.setDirection(QBoxLayout.Direction.LeftToRight)
460 self.layout.setDirection(QBoxLayout.BottomToTop) 461 self.layout.setDirection(QBoxLayout.Direction.BottomToTop)
461 self.layout.setAlignment(self.barLayout, Qt.AlignLeft) 462 self.layout.setAlignment(self.barLayout,
463 Qt.AlignmentFlag.AlignLeft)
462 elif orient == E5SideBar.West: 464 elif orient == E5SideBar.West:
463 self.__tabBar.setShape(QTabBar.RoundedWest) 465 self.__tabBar.setShape(QTabBar.Shape.RoundedWest)
464 self.__tabBar.setSizePolicy( 466 self.__tabBar.setSizePolicy(
465 QSizePolicy.Preferred, QSizePolicy.Expanding) 467 QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Expanding)
466 self.barLayout.setDirection(QBoxLayout.TopToBottom) 468 self.barLayout.setDirection(QBoxLayout.Direction.TopToBottom)
467 self.layout.setDirection(QBoxLayout.LeftToRight) 469 self.layout.setDirection(QBoxLayout.Direction.LeftToRight)
468 self.layout.setAlignment(self.barLayout, Qt.AlignTop) 470 self.layout.setAlignment(self.barLayout, Qt.AlignmentFlag.AlignTop)
469 self.__orientation = orient 471 self.__orientation = orient
470 472
471 def tabIcon(self, index): 473 def tabIcon(self, index):
472 """ 474 """
473 Public method to get the icon of a tab. 475 Public method to get the icon of a tab.
565 else: 567 else:
566 self.__minSize = self.minimumSizeHint().width() 568 self.__minSize = self.minimumSizeHint().width()
567 self.__maxSize = self.maximumWidth() 569 self.__maxSize = self.maximumWidth()
568 570
569 data = QByteArray() 571 data = QByteArray()
570 stream = QDataStream(data, QIODevice.WriteOnly) 572 stream = QDataStream(data, QIODevice.OpenModeFlag.WriteOnly)
571 stream.setVersion(QDataStream.Qt_4_6) 573 stream.setVersion(QDataStream.Version.Qt_4_6)
572 574
573 stream.writeUInt16(self.Version) 575 stream.writeUInt16(self.Version)
574 stream.writeBool(self.__minimized) 576 stream.writeBool(self.__minimized)
575 stream << self.__bigSize 577 stream << self.__bigSize
576 stream.writeUInt32(self.__minSize) 578 stream.writeUInt32(self.__minSize)
598 else: 600 else:
599 minSize = self.layout.minimumSize().width() 601 minSize = self.layout.minimumSize().width()
600 maxSize = self.maximumWidth() 602 maxSize = self.maximumWidth()
601 603
602 data = QByteArray(state) 604 data = QByteArray(state)
603 stream = QDataStream(data, QIODevice.ReadOnly) 605 stream = QDataStream(data, QIODevice.OpenModeFlag.ReadOnly)
604 stream.setVersion(QDataStream.Qt_4_6) 606 stream.setVersion(QDataStream.Version.Qt_4_6)
605 version = stream.readUInt16() # version 607 version = stream.readUInt16() # version
606 minimized = stream.readBool() 608 minimized = stream.readBool()
607 609
608 if minimized and not self.__minimized: 610 if minimized and not self.__minimized:
609 self.shrink() 611 self.shrink()

eric ide

mercurial