コード例 #1
0
    def __init__(self, showColumnVisBox=True, showHeaderBox=True, parent=None):
        super(ViewSearchWidget, self).__init__(parent=parent)
        # TODO: these button colors need stylesheeting once Stylesheeting is moved to zoocore
        searchIcon = iconlib.iconColorized("magnifier", size=14, color=(255, 255, 255))
        closeIcon = iconlib.iconColorized("close", size=14, color=(255, 255, 255))

        self.searchFrame = QtWidgets.QFrame(parent=self)
        self.searchFrame.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.searchFrame.setFrameShadow(QtWidgets.QFrame.Plain)
        self.searchLayout = QtWidgets.QHBoxLayout(self)
        self.searchLayout.setContentsMargins(0, 0, 0, 0)

        self.searchWidget = searchwidget.SearchLineEdit(searchIcon, closeIcon, parent=self)
        self.searchWidget.textCleared.connect(self.searchTextedCleared.emit)
        self.searchWidget.textChanged.connect(self.searchTextedChanged.emit)

        self.searchFrame.setLayout(self.searchLayout)

        self.columnVisibilityBox = combobox.ExtendedComboBox(parent=self)
        self.columnVisibilityBox.setMinimumWidth(100)
        self.columnVisibilityBox.checkStateChanged.connect(self.onVisibilityChanged)
        self.searchLayout.addWidget(self.columnVisibilityBox)

        self.searchHeaderBox = combobox.ExtendedComboBox(parent=self)
        self.searchHeaderBox.setMinimumWidth(100)
        self.searchHeaderBox.currentIndexChanged.connect(self.onFilterChanged)
        self.searchLayout.addWidget(self.searchHeaderBox)
        self.searchLayout.addWidget(self.searchWidget)
        if not showColumnVisBox:
            self.columnVisibilityBox.hide()
        if not showHeaderBox:
            self.searchHeaderBox.hide()
コード例 #2
0
ファイル: searchwidget.py プロジェクト: andrewsilke/zoocore
    def __init__(self, searchPixmap=None, clearPixmap=None, parent=None):
        QtWidgets.QLineEdit.__init__(self, parent)

        if searchPixmap is None:
            searchPixmap = iconlib.iconColorized("magnifier", utils.dpiScale(16), (128,128,128))  # these should be in layouts

        if clearPixmap is None:
            clearPixmap = iconlib.iconColorized("close", utils.dpiScale(16), (128,128,128))

        self.clearButton = QtWidgets.QToolButton(self)
        self.clearButton.setIcon(QtGui.QIcon(clearPixmap))
        self.clearButton.setCursor(QtCore.Qt.ArrowCursor)
        self.clearButton.setStyleSheet("QToolButton { border: none; padding: 1px; }")
        self.clearButton.hide()
        self.clearButton.clicked.connect(self.clear)
        self.textChanged.connect(self.updateCloseButton)

        self.searchButton = QtWidgets.QToolButton(self)
        self.searchButton.setStyleSheet("QToolButton { border: none; padding: 0px; }")
        self.searchButton.setIcon(QtGui.QIcon(searchPixmap))

        frameWidth = self.style().pixelMetric(QtWidgets.QStyle.PM_DefaultFrameWidth)
        self.setStyleSheet("QLineEdit { padding-left: %dpx; padding-right: %dpx; } "%(
            self.searchButton.sizeHint().width() + frameWidth + 1,
            self.clearButton.sizeHint().width() + frameWidth + 1))

        msz = self.minimumSizeHint()
        self.setMinimumSize(max(msz.width(),
                                self.searchButton.sizeHint().width() +
                                self.clearButton.sizeHint().width() + frameWidth * 2 + 2),
                            max(msz.height(),
                                self.clearButton.sizeHint().height() + frameWidth * 2 + 2))
コード例 #3
0
ファイル: flowtoolbar.py プロジェクト: keenfoong/zoocore
    def updateWidgetsOverflow(self, width=None):
        """Hide or show widgets based on the size of the flow toolbar.

        If the flow toolbar is too small it will move widgets it to the overflow menu.

        If there are widgets in the overflow menu, place it back into the flow toolbar if there is space.

        :param width:
        :return:
        """
        if not self.overflowMenuBtn or self.overflowMenu is False:
            return

        width = width or self.width()

        # Stop the flickering by disabling updates and processing first
        self.setUpdatesEnabled(False)

        spacing = self.flowLayout.spacingX
        menu = self.overflowMenuBtn.getMenu(mouseMenu=QtCore.Qt.LeftButton)

        # Add all items in the flow layout and place them into the menu
        for item in self.flowLayout.itemList:
            wgt = item.widget()
            toolsetType = wgt.property('toolsetType')

            if toolsetType is not None:
                icon = iconlib.iconColorized(wgt.property('iconName'),
                                             color=wgt.property('color'))
                self.overflowMenuBtn.addAction(
                    wgt.property('toolsetType'),
                    icon=icon,
                    connect=lambda x=wgt: x.leftClicked.emit())

        # Hide all the menu items so we can unhide what we need later
        for a in menu.actions():
            a.setVisible(False)

        hidden = []

        nextX = self.overflowMenuBtn.sizeHint().width()
        for item in self.flowLayout.itemList[:-1]:
            wgt = item.widget()
            nextX += wgt.sizeHint().width() + spacing
            if nextX > width:
                wgt.hide()
                hidden.append(wgt)
            else:
                wgt.show()

        # Show or hide menu items
        for wgt in hidden:
            for a in menu.actions():
                if a.text() == wgt.property('toolsetType'):
                    a.setVisible(True)
                    break

        self.overflowMenuBtn.setVisible(len(hidden) > 0)
        self.setUpdatesEnabled(True)
コード例 #4
0
ファイル: expandedtooltip.py プロジェクト: keenfoong/zoocore
    def setIcon(self, icon):
        """Sets the large icon of this tooltip dialogue window

        :param icon:
        """
        icon = icon or self.defaultIcon
        qicon = iconlib.iconColorized(icon, self.iconSize, self.iconColour)
        iconWgt = QtWidgets.QToolButton()
        iconWgt.setIconSize(QtCore.QSize(self.iconSize, self.iconSize))

        iconWgt.setIcon(qicon)
        self.tooltipIcon = iconWgt
コード例 #5
0
    def _setupFilter(self):
        self.reloadBtn = QtWidgets.QToolButton(parent=self)
        # TODO: this button color needs stylesheeting once Stylesheeting is moved to zoocore
        self.reloadBtn.setIcon(iconlib.iconColorized("reload", color=(255, 255, 255)))

        self.searchLayout = QtWidgets.QHBoxLayout(self)
        self.searchLayout.setContentsMargins(0, 0, 0, 0)
        self.searchLayout.addWidget(self.reloadBtn)
        self.searchWidget = viewfilterwidget.ViewSearchWidget(showColumnVisBox=False, showHeaderBox=False, parent=self)
        self.searchWidget.setFixedHeight(utils.dpiScale(23))

        self.searchLayout.addWidget(self.searchWidget)
        self.mainLayout.addLayout(self.searchLayout)
コード例 #6
0
ファイル: iconmenu.py プロジェクト: keenfoong/zoocore
def IconMenuButtonCombo(modes,
                        defaultMode,
                        color=(255, 255, 255),
                        parent=None,
                        size=24,
                        toolTip=""):
    """Creates an IconMenuButton in a combo box style, like a combo box with an icon instead,
    works with left click and a regular menu

    modes = [("arnoldIcon", "Arnold"),
             ("redshiftIcon", "Redshift"),
             ("rendermanIcon", "Renderman")]
    defaultMode = "redshiftIcon"

    :param modes: A list of tuples, tuples are (iconName, menuName)
    :type modes: list(tuples)
    :param defaultMode: the name of the icon to set as the default state
    :type defaultMode: str
    :param color: the color of the icon in 255 rgb color
    :type color: tuple
    :param parent: the parent widget
    :type parent: QWidget
    :param size: the size of the icon
    :type size: int
    :param toolTip: the toolTip on mouse hover
    :type toolTip: str
    :return iconCBtn: the iconCBtn widget
    :rtype iconCBtn: iconmenu.IconMenuButton()
    """
    iconCBtn = IconMenuButton(parent=parent)
    for m in modes:
        iconCBtn.addAction(m[1],
                           mouseMenu=QtCore.Qt.LeftButton,
                           connect=lambda x=m[0]: iconCBtn.setIconByName(
                               [x, None], colors=color),
                           icon=iconlib.iconColorized(m[0]))
    iconCBtn.setMenuAlign(QtCore.Qt.AlignRight)
    iconCBtn.setIconByName([defaultMode, None], colors=color)
    iconCBtn.setFixedSize(QtCore.QSize(size, size))
    iconCBtn.setToolTip(toolTip)
    utils.setStylesheetObjectName(iconCBtn, "DefaultButton")
    return iconCBtn