Beispiel #1
0
 def resizeEvent(self, event):
     q = self.parentWidget()
     if hasFeature(q, QDockWidget.DockWidgetVerticalTitleBar):
         fh = q.isFloating() and q.style().pixelMetric(
             QStyle.PM_DockWidgetFrameWidth, None, q) or 0
         opt = QStyleOptionDockWidget()
         opt.initFrom(q)
         opt.verticalTitleBar = True
         opt.rect = QRect(
             QPoint(fh, 40),  #self.geometry().height() - (fh * 3)),
             QSize(self.geometry().width() - (fh * 2), fh * 2))
         opt.title = q.windowTitle()
         opt.closable = hasFeature(q, QDockWidget.DockWidgetClosable)
         opt.floatable = hasFeature(q, QDockWidget.DockWidgetFloatable)
         floatRect = q.style().subElementRect(
             QStyle.SE_DockWidgetFloatButton, opt, q)
         if not floatRect.isNull():
             self.floatButton.setGeometry(floatRect)
         closeRect = q.style().subElementRect(
             QStyle.SE_DockWidgetCloseButton, opt, q)
         if not closeRect.isNull():
             self.closeButton.setGeometry(closeRect)
         top = fh
         if not floatRect.isNull():
             top = floatRect.x()
         elif not closeRect.isNull():
             top = closeRect.x()
         size = self.collapseButton.size()
         if not closeRect.isNull():
             size = self.closeButton.size()
         elif not floatRect.isNull():
             size = self.floatButton.size()
         collapseRect = QRect(QPoint(top, fh), size)
         self.collapseButton.setGeometry(collapseRect)
         pinRect = QRect(QPoint(top, fh + collapseRect.height() + 1), size)
         self.pinButton.setGeometry(pinRect)
     else:
         fw = q.isFloating() and q.style().pixelMetric(
             QStyle.PM_DockWidgetFrameWidth, None, q) or 0
         opt = QStyleOptionDockWidget()
         opt.initFrom(q)
         opt.rect = QRect(
             QPoint(fw, fw),
             QSize(self.geometry().width() - (fw * 2),
                   self.geometry().height() - (fw * 2)))
         opt.title = q.windowTitle()
         opt.closable = hasFeature(q, QDockWidget.DockWidgetClosable)
         opt.floatable = hasFeature(q, QDockWidget.DockWidgetFloatable)
         floatRect = q.style().subElementRect(
             QStyle.SE_DockWidgetFloatButton, opt, q)
         if not floatRect.isNull():
             self.floatButton.setGeometry(floatRect)
         closeRect = q.style().subElementRect(
             QStyle.SE_DockWidgetCloseButton, opt, q)
         if not closeRect.isNull():
             self.closeButton.setGeometry(closeRect)
         top = fw
         if not floatRect.isNull():
             top = floatRect.y()
         elif not closeRect.isNull():
             top = closeRect.y()
         size = self.collapseButton.size()
         if not closeRect.isNull():
             size = self.closeButton.size()
         elif not floatRect.isNull():
             size = self.floatButton.size()
         collapseRect = QRect(QPoint(fw, top), size)
         self.collapseButton.setGeometry(collapseRect)
         pinRect = QRect(QPoint(fw + collapseRect.width() + 1, top), size)
         self.pinButton.setGeometry(pinRect)
Beispiel #2
0
 def paintEvent(self, event):
     p = QStylePainter(self)
     q = self.parentWidget()
     if hasFeature(q, QDockWidget.DockWidgetVerticalTitleBar):
         fw = 1 or q.isFloating() and q.style().pixelMetric(
             QStyle.PM_DockWidgetFrameWidth, None, q) or 0
         mw = q.style().pixelMetric(QStyle.PM_DockWidgetTitleMargin, None,
                                    q)
         titleOpt = QStyleOptionDockWidget()
         titleOpt.initFrom(q)
         titleOpt.verticalTitleBar = True
         titleOpt.rect = QRect(
             QPoint(fw, fw + mw + \
                    self.collapseButton.size().height() + self.pinButton.size().height()),
             QSize(
                self.geometry().width() - (fw * 2),
                self.geometry().height() - (fw * 2) - \
                mw - self.collapseButton.size().height() - self.pinButton.size().height()))
         titleOpt.title = q.windowTitle()
         titleOpt.closable = hasFeature(q, QDockWidget.DockWidgetClosable)
         titleOpt.floatable = hasFeature(q, QDockWidget.DockWidgetFloatable)
         p.drawControl(QStyle.CE_DockWidgetTitle, titleOpt)
     else:
         fw = q.isFloating() and q.style().pixelMetric(
             QStyle.PM_DockWidgetFrameWidth, None, q) or 0
         mw = q.style().pixelMetric(QStyle.PM_DockWidgetTitleMargin, None,
                                    q)
         titleOpt = QStyleOptionDockWidget()
         titleOpt.initFrom(q)
         titleOpt.rect = QRect(
             QPoint(fw + mw + \
                    self.collapseButton.size().width() + self.pinButton.size().width(), fw),
             QSize(
                self.geometry().width() - (fw * 2) - \
                mw - self.collapseButton.size().width() - self.pinButton.size().width(),
                self.geometry().height() - (fw * 2)))
         titleOpt.title = q.windowTitle()
         titleOpt.closable = hasFeature(q, QDockWidget.DockWidgetClosable)
         titleOpt.floatable = hasFeature(q, QDockWidget.DockWidgetFloatable)
         p.drawControl(QStyle.CE_DockWidgetTitle, titleOpt)