Пример #1
0
    def listItemRightClicked(self, QPos):
        self.listMenu = QtGui.QMenu()

        self.listMenu.setStyleSheet("""
            QMenu {
                background-color: #313131;
                border: 1px solid ;
            }
            QMenu::item::selected {
                background-color: #1e1e1e;
            }
        """)

        import_mtl = self.listMenu.addAction("Import Material")
        import_klf = self.listMenu.addAction("Import Lookfile")
        import_Lmtl = self.listMenu.addAction("Create Material")
        delete_mtl = self.listMenu.addAction("Delete Material")

        self.connect(import_mtl, QtCore.SIGNAL("triggered()"), self.importMtl)
        self.connect(import_klf, QtCore.SIGNAL("triggered()"), self.importKlf)
        self.connect(import_Lmtl, QtCore.SIGNAL("triggered()"),
                     self.importLmtl)
        self.connect(delete_mtl, QtCore.SIGNAL("triggered()"), self.deleteMtl)
        parentPosition = self.listWidget.mapToGlobal(QtCore.QPoint(0, 0))
        self.listMenu.move(parentPosition + QPos)
        self.listMenu.show()
Пример #2
0
        def lightListWidgetMousePressEvent(event):
            """
            Handle mouse events
            """
            # Set up context menu (right-click)
            if event.button() == QtCore.Qt.RightButton:
                item = lightListWidget.itemAt(event.pos())
                if not item:
                    return

                scriptItem = item.getItemData()
                item.setHiliteColor(QtGui.QColor(32,32,32))
                lightListWidget.update(lightListWidget.indexFromItem(item))

                menu = QtGui.QMenu(None)

                # Render options
                UI4.Util.RenderMenu.AddRenderItemsToMenu(
                        menu, scriptItem.getRenderNode(), None)
                menu.addSeparator()

                # Add 'Delete' action
                def delete():
                    # Delete selected light pass items
                    for item in lightListWidget.selectedItems():
                        item.getItemData().delete()


                menu.addAction('Delete', delete)
                menu.addSeparator()

                # Add 'View From Render Node' action
                def viewNode():
                    NodegraphAPI.SetNodeViewed(
                            scriptItem.getRenderNode(), True, exclusive=True)
                action = menu.addAction('View From Render Node', viewNode)
                action.setIcon(UI4.Util.IconManager.GetIcon(
                        'Icons/AttributeEditor/blue_snapback.png'))

                # Show menu
                pos = event.pos()
                pos = lightListWidget.mapToGlobal(QtCore.QPoint(
                         pos.x(), pos.y() + lightListWidget.header().height()))
                try:
                    menu.exec_(pos)
                finally:
                    item.setHiliteColor(None)
                    lightListWidget.update(lightListWidget.indexFromItem(item))
                    event.accept()
                    self.updateLightList()
Пример #3
0
    def paintEvent(self, event):
        """
        Overrides the base paint event so we can overlay our circle.
        """
        QtGui.QLabel.paintEvent(self, event)

        if self.__xPoint > 0 and self.__yPoint > 0:
            paint = QtGui.QPainter()
            paint.begin(self)
            paint.setRenderHint(QtGui.QPainter.Antialiasing)

            paint.setPen(QtGui.QColor(0, 255, 0))
            paint.setBrush(QtGui.QColor(0, 255, 0))
            center = QtCore.QPoint(self.__xPoint, self.__yPoint)
            paint.drawEllipse(center, 5, 5)

            paint.end()
Пример #4
0
 def treeWidgetMousePressEvent(event):
     """
     Handle mouse events
     """
     # Set up context menu (right-click)
     if event.button() == QtCore.Qt.RightButton:
         item = treeWidget.itemAt(event.pos())
         if not item:
             return
         
         scriptItem = item.getItemData()                
         item.setHiliteColor(QtGui.QColor(32,32,32))
         treeWidget.update(treeWidget.indexFromItem(item))
         
         menu = QtGui.QMenu(None)
         
         # Add 'Delete' action
         menu.addAction('Delete', scriptItem.delete)
         menu.addSeparator()
         
         # Add 'View From ShadowBranch Node' action
         def viewNode():
             NodegraphAPI.SetNodeViewed(
                 scriptItem.getShadowBranchNode(), True, exclusive=True)
         action = menu.addAction('View From ShadowBranch Node',viewNode)
         action.setIcon(UI4.Util.IconManager.GetIcon(
                 'Icons/AttributeEditor/blue_snapback.png'))                
         
         # Show menu
         pos = event.pos()
         pos = treeWidget.mapToGlobal(QtCore.QPoint(
                         pos.x(), pos.y()))
         
         try:
             menu.exec_(pos)
         finally:
             item.setHiliteColor(None)
             treeWidget.update(treeWidget.indexFromItem(item))
             event.accept()
Пример #5
0
    def __listMousePressEvent(self, event):
        item = self.tree.itemAt(event.pos())
        if not item:
            return
        pos = event.pos()
        pos = self.tree.mapToGlobal(
            QtCore.QPoint(pos.x(),
                          pos.y() + self.tree.header().height()))
        self.__lastTreePos = event.pos()
        self.__lastPos = pos
        if event.button() == QtCore.Qt.LeftButton:
            local_pos = event.pos()
            global_pos = pos
            if self.__popupVersions(item, local_pos, global_pos):
                event.accept()
        else:
            if event.button() == QtCore.Qt.RightButton:
                if item.isSelected():
                    items = self.tree.selectedItems()
                else:
                    items = [item]
                for item in items:
                    dark = QtGui.QColor(32, 32, 32)
                    item.setHiliteColor(dark)
                    self.tree.update(self.tree.indexFromItem(item))

                menu = QtWidgets.QMenu(None)
                types = set((i.getItemData()['type'] for i in items))
                if len(types) > 1:
                    menu.addAction(RemoveItemsAction(menu, self.node, items))
                else:
                    itemType = tuple(types)[0]
                    if itemType == 'output':
                        if str(item.text(NAME_COLUMN)) == 'default':
                            a = menu.addAction(
                                '(Default Output Cannot Be Removed)')
                            a.setEnabled(False)
                        else:
                            menu.addAction(
                                RemoveItemsAction(menu, self.node, items))
                    else:
                        if itemType == 'assetTree':
                            assetItem = item.getItemData()['assetItem']
                            if assetItem.isIgnorable():
                                menu.addAction(
                                    ToggleIgnoreItemsAction(
                                        menu, self.node, items,
                                        not assetItem.isIgnored()))
                            if assetItem.isDeletable():
                                try:
                                    menu.addAction(
                                        RemoveItemsAction(
                                            menu, self.node, items))
                                except Exception as exception:
                                    log.exception(
                                        'Error adding action to context menu: %s'
                                        % str(exception))

                            if assetItem.canDuplicate():
                                try:
                                    menu.addAction(
                                        DuplicateItemAction(
                                            menu, self.node, items))
                                except:
                                    import traceback
                                    traceback.print_exc()

                            if len(items) == 1:
                                assetItem.addToContextMenu(menu, self.node)
                menu.exec_(pos)
                for item in items:
                    item.setHiliteColor(None)
                    self.tree.update(self.tree.indexFromItem(item))

                event.accept()
        return
Пример #6
0
    def __init__(self, parent, node):
        self.node = node
        self.nodeVersion = node.getNodeVersion()

        # Initialize widget
        QtWidgets.QWidget.__init__(self, parent)

        # Hide Original SuperTool Search Button
        search_button = self.__findSearchButton()
        if search_button is not None:
            search_button.setParent(None)

        # Main Layout
        mainLayout = QtWidgets.QVBoxLayout(self)
        mainLayout.setSpacing(0)

        # Menu Bar
        self.__menuBar = QtWidgets.QMenuBar(self)
        self.__addMenu = self.__menuBar.addMenu(
            UI4.Util.IconManager.GetIcon('Icons/plus16.png'), 'Add')
        self.__addMenu.aboutToShow.connect(self.__addMenuAboutToShow)
        self.__addMenu.triggered.connect(self.__addMenuTriggered)
        self.__cacheMenu = self.__menuBar.addMenu("Caching System")
        self.__cacheMenu.aboutToShow.connect(self.__addMenuAboutToShow)
        self.__cacheMenu.triggered.connect(self.__addMenuTriggered)

        # Top-Right Search Button
        self.search_button = UI4.Widgets.FilterablePopupButton(self.__menuBar)
        self.search_button.setIcon(
            UI4.Util.IconManager.GetIcon('Icons/find20.png'))
        self.search_button.setIconSize(
            UI4.Util.IconManager.GetSize('Icons/find20.png'))
        self.search_button.setFlat(True)
        self.search_button.setFocusPolicy(QtCore.Qt.NoFocus)
        self.search_button.setButtonType('smallToolbar')
        self.search_button.aboutToShow.connect(self.__searchPopupShow)
        self.search_button.itemChosen.connect(self.__searchPopupChosen)
        self.__menuBar.setCornerWidget(self.search_button,
                                       QtCore.Qt.TopRightCorner)

        mainLayout.setMenuBar(self.__menuBar)

        # Main Frame where the tree widget will reside
        self.__listContainer = QtWidgets.QFrame(self)
        mainLayout.addWidget(self.__listContainer)
        self.__listStretchBox = UI4.Widgets.StretchBox(self.__listContainer,
                                                       allowHorizontal=False,
                                                       allowVertical=True)

        # Main Tree Widget
        self.tree = UI4.Widgets.SortableTreeWidget(None)
        self.tree.setAutoScroll(False)
        self.tree.setExpandsOnDoubleClick(False)
        self.suppressor = self.tree.getUpdateSuppressor()

        self.__versionPopup = Widgets.FilterablePopup()
        self.__lastTreePos = QtCore.QPoint(0, 0)
        self.__listStretchBox.layout().addWidget(self.tree)
        self.__listStretchBox.setMinHeight(160)
        self.__listStretchBox.setFixedHeight(160)
        mainLayout.addWidget(self.__listStretchBox)

        # Headers
        self.__headerLabels = [
            ' Name', ' Task', ' Version', ' Finalable', ' Prman Version',
            ' Shot'
        ]

        self.tree.setColumnCount(len(self.__headerLabels))
        self.tree.setHeaderLabels(self.__headerLabels)
        # self.tree.header().setSectionsClickable(False)
        self.tree.setSelectionMode(self.tree.ExtendedSelection)
        self.tree.setRootIsDecorated(True)
        self.tree.setDraggable(True)
        self.tree.setAllColumnsShowFocus(True)
        self.tree.setMinimumHeight(128)
        self.tree.setUniformRowHeights(True)
        self.tree.setSortingEnabled(False)  # TODO: Context menu for sorting
        self.tree.setMultiDragEnabled(True)

        # ResizeToContents makes the UI slow, we'll make it manual, not a big deal
        # self.tree.header().setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents)
        self.tree.header().setSectionResizeMode(
            QtWidgets.QHeaderView.Interactive)
        self.tree.header().resizeSection(0, 200)
        # self.tree.header().setSortIndicator(NAME_COLUMN, QtCore.Qt.AscendingOrder)

        self.tree.dragMoveEventSignal.connect(self.__dragMoveEventCallback)
        self.tree.dropEventSignal.connect(self.__dropEventCallback)
        self.tree.aboutToDrag.connect(self.__aboutToDragCallback)
        self.tree.itemSelectionChanged.connect(self.__selectionChanged)
        self.tree.mousePressEventSignal.connect(self.__listMousePressEvent)
        self.tree.doubleClicked.connect(self.__doubleClick)
        self.tree.keyPressEventSignal.connect(self.__listKeyPressCallback)
        self.__versionPopup.itemChosen.connect(self.__popupVersionsItemChosen)

        # Editor Status Widget
        self.__selectionStateDisplay = EditorStatusWidget(self)
        mainLayout.addWidget(self.__selectionStateDisplay)
        self.__selectionStateDisplay.customNameStateChange.connect(
            self.__customNameStateChanged)
        self.__selectionStateDisplay.customNameFieldChange.connect(
            self.__customNameChanged)
        self.__parameterDisplayArea = QtWidgets.QWidget(self)
        QtWidgets.QVBoxLayout(self.__parameterDisplayArea)
        mainLayout.addWidget(self.__parameterDisplayArea)
        mainLayout.addStretch()
        self.__additionalObservedNodes = {}
        self.__addObserverNode(NodegraphAPI.GetRootNode())
        self.__frozen = True
        self.__preselect = None
        self.__primaryProductDict = {}
        self.__rebuilding = False
        self.__addDupsDialog = None
        self.__currentDisplayWidgetSource = None
        self.__currentDisplayWidget = None
        return