예제 #1
0
파일: overlay.py 프로젝트: rbax/orange3
class SimpleButton(QAbstractButton):
    """
    A simple icon button widget.
    """
    def __init__(self, parent=None, **kwargs):
        super().__init__(parent, **kwargs)
        self.__focusframe = None

    def focusInEvent(self, event):
        # reimplemented
        event.accept()
        self.__focusframe = QFocusFrame(self)
        self.__focusframe.setWidget(self)

    def focusOutEvent(self, event):
        # reimplemented
        event.accept()
        self.__focusframe.deleteLater()
        self.__focusframe = None

    def sizeHint(self):
        # reimplemented
        self.ensurePolished()
        iconsize = self.iconSize()
        icon = self.icon()
        if not icon.isNull():
            iconsize = icon.actualSize(iconsize)
        return iconsize

    def minimumSizeHint(self):
        # reimplemented
        return self.sizeHint()

    def paintEvent(self, event):
        # reimplemented
        painter = QStylePainter(self)
        option = QStyleOptionButton()
        option.initFrom(self)
        option.icon = self.icon()
        option.iconSize = self.iconSize()

        icon = self.icon()

        if not icon.isNull():
            if option.state & QStyle.State_Active:
                mode = (QIcon.Normal if option.state
                        & QStyle.State_MouseOver else QIcon.Active)
            else:
                mode = QIcon.Disabled
            pixmap = icon.pixmap(
                option.iconSize,
                mode,
            )

            painter.drawItemPixmap(option.rect, Qt.AlignCenter, pixmap)
예제 #2
0
class SimpleButton(QAbstractButton):
    """
    A simple icon button widget.
    """
    def __init__(self, parent=None, **kwargs):
        super().__init__(parent, **kwargs)
        self.__focusframe = None

    def focusInEvent(self, event):
        # reimplemented
        event.accept()
        self.__focusframe = QFocusFrame(self)
        self.__focusframe.setWidget(self)

    def focusOutEvent(self, event):
        # reimplemented
        event.accept()
        self.__focusframe.deleteLater()
        self.__focusframe = None

    def sizeHint(self):
        # reimplemented
        self.ensurePolished()
        iconsize = self.iconSize()
        icon = self.icon()
        if not icon.isNull():
            iconsize = icon.actualSize(iconsize)
        return iconsize

    def minimumSizeHint(self):
        # reimplemented
        return self.sizeHint()

    def paintEvent(self, event):
        # reimplemented
        painter = QStylePainter(self)
        option = QStyleOptionButton()
        option.initFrom(self)
        option.icon = self.icon()
        option.iconSize = self.iconSize()

        icon = self.icon()

        if not icon.isNull():
            if option.state & QStyle.State_Active:
                mode = (QIcon.Normal if option.state & QStyle.State_MouseOver
                        else QIcon.Active)
            else:
                mode = QIcon.Disabled
            pixmap = icon.pixmap(option.iconSize, mode, )

            painter.drawItemPixmap(option.rect, Qt.AlignCenter, pixmap)
예제 #3
0
파일: overlay.py 프로젝트: waqarini/orange3
 def focusInEvent(self, event):
     # reimplemented
     event.accept()
     self.__focusframe = QFocusFrame(self)
     self.__focusframe.setWidget(self)