Ejemplo n.º 1
0
 def drawComplexControl(self,
                        element,
                        style_option: QStyleOptionComplex,
                        painter: QPainter,
                        widget=None):
     """TODO"""
     QProxyStyle.drawComplexControl(self, element, style_option, painter,
                                    widget)
Ejemplo n.º 2
0
    def drawComplexControl(self, element, opt, painter, widget):
        if not self.__panel_widget(widget):
            QProxyStyle.drawComplexControl(self, element, opt, painter, widget)
            return
        if element == QStyle.CC_ComboBox:
            empty = False
            if not opt.currentText and opt.currentIcon.isNull():
                empty = True

            tool_btn = opt
            if empty:
                tool_btn.state &= ~(STATE_ENABLED | STATE_SUNKEN)
            self.drawPrimitive(QStyle.PE_PanelButtonTool, tool_btn, painter,
                               widget)
            # Draw border
            if widget.property("border"):
                # painter.setPen(opt.palette.light().color().lighter(150))
                painter.setPen(_COLORS["MenuBarBorderColor"])
                painter.drawLine(opt.rect.topRight() + QPoint(0, 6),
                                 opt.rect.bottomRight() - QPoint(0, 6))

            if widget.property("border_bottom"):
                painter.setPen(_COLORS['Border'])
                painter.drawLine(opt.rect.bottomLeft(), opt.rect.bottomRight())
            arrow_rect = QRect((opt.rect.left() + opt.rect.right()) / 2 + 6,
                               opt.rect.center().y(), 9, 9)

            arrow_rect.moveRight(opt.rect.width() - 10)
            # FIXME:
            arrow_opt = QStyleOptionComboBox()
            arrow_opt.state = opt.state
            arrow_opt.rect = arrow_rect
            if empty:
                arrow_opt.state &= ~(STATE_ENABLED | STATE_SUNKEN)
            if self.styleHint(QStyle.SH_ComboBox_Popup, opt, widget):
                arrow_opt.rect.translate(0, -3)
                arrow_opt.palette.setColor(QPalette.ButtonText,
                                           _COLORS['IconBaseColor'])
                QCommonStyle.drawPrimitive(self, QStyle.PE_IndicatorArrowDown,
                                           arrow_opt, painter, widget)
        # elif element == QStyle.CC_ScrollBar:
        #    pass
        elif element == QStyle.CC_ToolButton:
            # reverse = opt.direction == Qt.RightToLeft
            button = self.subControlRect(element, opt, QStyle.SC_ToolButton,
                                         widget)
            flags = opt.state
            if flags & QStyle.State_AutoRaise:
                if not flags & STATE_MOUSEOVER:
                    flags &= ~QStyle.State_Raised

            tool = opt
            tool.palette = self.panel_palette(opt.palette)
            if opt.subControls & QStyle.SC_ToolButton:
                tool.rect = button
                tool.state = flags
                self.drawPrimitive(QStyle.PE_PanelButtonTool, tool, painter,
                                   widget)

            # Draw border
            if widget.property("border"):
                # painter.setPen(_COLORS["MenuBarBorderColor"])
                # painter.drawLine(opt.rect.bottomLeft(), opt.rect.bottomRight())
                pass
            label = opt
            label.palette.setColor(QPalette.ButtonText,
                                   label.palette.buttonText().color())
            fw = self.pixelMetric(QStyle.PM_DefaultFrameWidth, opt, widget)
            label.rect = opt.rect.adjusted(fw, fw, -fw, -fw)
            self.drawControl(QStyle.CE_ToolButtonLabel, label, painter, widget)
        else:
            QProxyStyle.drawComplexControl(self, element, opt, painter, widget)