Beispiel #1
0
 def __updateItemDelegate(self):
     opt = QStyleOptionComboBox()
     opt.initFrom(self)
     if self.style().styleHint(QStyle.SH_ComboBox_Popup, opt, self):
         delegate = CheckComboBox.ComboMenuDelegate(self)
     else:
         delegate = CheckComboBox.ComboItemDelegate(self)
     self.setItemDelegate(delegate)
Beispiel #2
0
 def paint(self, painter, option, index):
     value = index.data(QtCore.Qt.DisplayRole)
     style = QApplication.style()
     opt = QStyleOptionComboBox()
     opt.text = str(value)
     opt.rect = option.rect
     style.drawComplexControl(QStyle.CC_ComboBox, opt, painter)
     QItemDelegate.paint(self, painter, option, index)
    def paint(self, painter, option, index):
        QStyledItemDelegate.paint(self, painter, option, index)

        if index.isValid() and index.internalPointer().data(Outline.status.value) not in ["", None, "0", 0]:
            opt = QStyleOptionComboBox()
            opt.rect = option.rect
            r = qApp.style().subControlRect(QStyle.CC_ComboBox, opt, QStyle.SC_ComboBoxArrow)
            option.rect = r
            qApp.style().drawPrimitive(QStyle.PE_IndicatorArrowDown, option, painter)
Beispiel #4
0
 def paintEvent(self, event):
     style = QApplication.style()
     opt = QStyleOptionComboBox()
     opt.rect = self.rect()
     self.initStyleOption(opt)
     painter = QPainter(self)
     painter.save()
     style.drawComplexControl(QStyle.CC_ComboBox, opt, painter)
     opt.currentText = self._encoder_path()
     style.drawControl(QStyle.CE_ComboBoxLabel, opt, painter)
     painter.restore()
 def paint(self, painter, option, index):
     value = index.data()
     if index.column() == self.column:
         if option.state:
             opt = QStyleOptionComboBox()
             opt.currentText = str(value)
             opt.rect = option.rect
             QApplication.style().drawControl(QStyle.CE_ComboBoxLabel, opt,
                                              painter)
     else:
         QAbstractItemDelegate.paint(self, painter, option, index)
    def paint(self, painter, option, index):
        QStyledItemDelegate.paint(self, painter, option, index)

        if index.isValid() and index.internalPointer().data(
                Outline.status) not in ["", None, "0", 0]:
            opt = QStyleOptionComboBox()
            opt.rect = option.rect
            r = qApp.style().subControlRect(QStyle.CC_ComboBox, opt,
                                            QStyle.SC_ComboBoxArrow)
            option.rect = r
            qApp.style().drawPrimitive(QStyle.PE_IndicatorArrowDown, option,
                                       painter)
Beispiel #7
0
    def setupUi(self):
        super(MainWindow, self).setupUi(self)

        self.search_box.shortcut = QShortcut(self.search_box)
        self.search_box.shortcut.setKey('Ctrl+F')

        self.output_devices_group = QActionGroup(self)
        self.input_devices_group = QActionGroup(self)
        self.alert_devices_group = QActionGroup(self)
        self.video_devices_group = QActionGroup(self)

        self.screen_sharing_button.addAction(QAction('Request screen', self.screen_sharing_button, triggered=self._AH_RequestScreenActionTriggered))
        self.screen_sharing_button.addAction(QAction('Share my screen', self.screen_sharing_button, triggered=self._AH_ShareMyScreenActionTriggered))

        # adjust search box height depending on theme as the value set in designer isn't suited for all themes
        search_box = self.search_box
        option = QStyleOptionFrame()
        search_box.initStyleOption(option)
        frame_width = search_box.style().pixelMetric(QStyle.PM_DefaultFrameWidth, option, search_box)
        if frame_width < 4:
            search_box.setMinimumHeight(20 + 2*frame_width)

        # adjust the combo boxes for themes with too much padding (like the default theme on Ubuntu 10.04)
        option = QStyleOptionComboBox()
        self.identity.initStyleOption(option)
        wide_padding = self.identity.style().subControlRect(QStyle.CC_ComboBox, option, QStyle.SC_ComboBoxEditField, self.identity).height() < 10
        self.identity.setStyleSheet("""QComboBox { padding: 0px 4px 0px 4px; }""" if wide_padding else "")
    def paint(self, painter, option, index):
        if not index.isValid():
            return QStyledItemDelegate.paint(self, painter, option, index)
        else:
            item = index.internalPointer()

        d = item.data(index.column(), Qt.DisplayRole)
        if not d:
            d = 0

        lbl = self.mdlLabels.item(int(d), 0)
        opt = QStyleOptionViewItem(option)
        self.initStyleOption(opt, self.mdlLabels.indexFromItem(lbl))

        qApp.style().drawControl(QStyle.CE_ItemViewItem, opt, painter)

        # Drop down indicator
        if index.isValid() and index.internalPointer().data(
                Outline.label) not in ["", None, "0", 0]:
            opt = QStyleOptionComboBox()
            opt.rect = option.rect
            r = qApp.style().subControlRect(QStyle.CC_ComboBox, opt,
                                            QStyle.SC_ComboBoxArrow)
            option.rect = r
            qApp.style().drawPrimitive(QStyle.PE_IndicatorArrowDown, option,
                                       painter)
    def paint(self, painter, option, index):
        ##option.rect.setWidth(option.rect.width() - 18)
        # QStyledItemDelegate.paint(self, painter, option, index)
        ##option.rect.setWidth(option.rect.width() + 18)

        itemIndex = QModelIndex()
        character = self.mdlCharacter.getCharacterByID(index.data())
        if character:
            itemIndex = character.index(Character.name)

        opt = QStyleOptionViewItem(option)
        self.initStyleOption(opt, itemIndex)

        qApp.style().drawControl(QStyle.CE_ItemViewItem, opt, painter)

        # if index.isValid() and index.internalPointer().data(Outline.POV) not in ["", None]:
        if itemIndex.isValid() and self.mdlCharacter.data(itemIndex) not in [
                "", None
        ]:
            opt = QStyleOptionComboBox()
            opt.rect = option.rect
            r = qApp.style().subControlRect(QStyle.CC_ComboBox, opt,
                                            QStyle.SC_ComboBoxArrow)
            option.rect = r
            qApp.style().drawPrimitive(QStyle.PE_IndicatorArrowDown, option,
                                       painter)
Beispiel #10
0
 def paint(self, painter, option, index):
     self.initStyleOption(option, index)
     # No idea why, but this cast is required if we want to have access to the V4 valuess
     option = QStyleOptionViewItem(option)
     if (index.column() == 1) and (option.state & QStyle.State_Selected):
         cboption = QStyleOptionComboBox()
         cboption.rect = option.rect
         # On OS X (with Qt4.6.0), adding State_Enabled to the flags causes the whole drawing to
         # fail (draw nothing), but it's an OS X only glitch. On Windows, it works alright.
         cboption.state |= QStyle.State_Enabled
         QApplication.style().drawComplexControl(QStyle.CC_ComboBox, cboption, painter)
         painter.setBrush(option.palette.text())
         rect = QRect(option.rect)
         rect.setLeft(rect.left()+4)
         painter.drawText(rect, Qt.AlignLeft, option.text)
     else:
         super().paint(painter, option, index)
Beispiel #11
0
    def paintEvent(self, event):
        """Reimplemented."""
        painter = QStylePainter(self)
        option = QStyleOptionComboBox()
        self.initStyleOption(option)
        painter.drawComplexControl(QStyle.CC_ComboBox, option)
        # draw the icon and text
        checked = self.checkedIndices()
        if checked:
            items = [self.itemText(i) for i in checked]
            option.currentText = self.__separator.join(items)
        else:
            option.currentText = self.__placeholderText
            option.palette.setCurrentColorGroup(QPalette.Disabled)

        option.currentIcon = QIcon()
        painter.drawControl(QStyle.CE_ComboBoxLabel, option)
Beispiel #12
0
 def paintEvent(self, event):
     painter = QStylePainter(self)
     
     opt = QStyleOptionComboBox()
     self.initStyleOption(opt)
     
     selected = []
     
     for index in range(self.__model.rowCount()):
         item = self.__model.item(index)
         if item.checkState() == Qt.Checked:
             selected.append(item.text())
     
     opt.currentText = " | ".join(selected)
     
     painter.drawComplexControl(QStyle.CC_ComboBox, opt)
     painter.drawControl(QStyle.CE_ComboBoxLabel, opt)
Beispiel #13
0
    def paintEvent(self, e):
        painter = QStylePainter(self)
        painter.setPen(self.palette().color(QPalette.Text))

        opt = QStyleOptionComboBox()
        self.initStyleOption(opt)

        count = self.model().checkedCount()
        if count == 0:
            opt.currentText = self.emptyCheckText
        elif count == 3:
            opt.currentText = self.model().singleCheckText
        else:
            opt.currentText = self.fullCheckText

        painter.drawComplexControl(QStyle.CC_ComboBox, opt)

        painter.drawControl(QStyle.CE_ComboBoxLabel, opt)
Beispiel #14
0
    def getMinimumWidth(self, items=None):
        fm = QFontMetrics(self.font())
        opt = QStyleOptionComboBox()
        style = self.style()
        mw = self.maxWidth

        if items is not None:

            for str in items:
                opt.currentText = str
                sz = QSize(fm.width(opt.currentText), fm.height())
                mw = max(
                    mw,
                    style.sizeFromContents(QStyle.CT_ComboBox, opt, sz,
                                           self).width())

        elif mw == 0 and self.count() > 0:

            for i in range(0, self.count()):
                opt.currentText = self.itemText(i)
                sz = QSize(fm.width(opt.currentText), fm.height())
                mw = max(
                    mw,
                    style.sizeFromContents(QStyle.CT_ComboBox, opt, sz,
                                           self).width())

        elif mw == 0:
            opt.currentText = ' '
            sz = QSize(fm.width(opt.currentText), fm.height())
            mw = max(
                mw,
                style.sizeFromContents(QStyle.CT_ComboBox, opt, sz,
                                       self).width())

        self.maxWidth = mw
        return mw
Beispiel #15
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)