def setupUi(self, WorkflowRelationship): '''Set up ui for *WorkflowRelationship* widget.''' WorkflowRelationship.setObjectName('WorkflowRelationship') WorkflowRelationship.resize(275, 106) self.verticalLayout = QtWidgets.QVBoxLayout(WorkflowRelationship) self.verticalLayout.setObjectName('verticalLayout') self.gridLayout = QtWidgets.QGridLayout() self.gridLayout.setObjectName('gridLayout') spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.gridLayout.addItem(spacerItem, 2, 0, 1, 1) self.label = QtWidgets.QLabel(WorkflowRelationship) self.label.setObjectName('label') self.gridLayout.addWidget(self.label, 1, 0, 1, 1) self.taskCombo = QtWidgets.QComboBox(WorkflowRelationship) self.taskCombo.setObjectName('taskCombo') self.gridLayout.addWidget(self.taskCombo, 1, 1, 1, 1) self.versionCombo = QtWidgets.QComboBox(WorkflowRelationship) self.versionCombo.setObjectName('versionCombo') self.gridLayout.addWidget(self.versionCombo, 0, 1, 1, 1) self.label_2 = QtWidgets.QLabel(WorkflowRelationship) self.label_2.setObjectName('label_2') self.gridLayout.addWidget(self.label_2, 0, 0, 1, 1) self.preferNukeScript = QtWidgets.QCheckBox('Prefer nuke script', WorkflowRelationship) self.gridLayout.addWidget(self.preferNukeScript, 2, 0, 1, 2) spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.gridLayout.addItem(spacerItem1, 0, 3, 1, 1) self.verticalLayout.addLayout(self.gridLayout) self.retranslateUi(WorkflowRelationship) QtCore.QMetaObject.connectSlotsByName(WorkflowRelationship)
def ftrackPublishKnobChanged(forceRefresh=False, g=None): g = g or nuke.thisNode() if 'ftable' in g.knobs(): header = getHeaderKnob(g) nodeAssetType = '' if nuke.thisKnob().name() in ['inputChange', 'fscript' ] or forceRefresh == True: thisNodeName = g['name'].value() g = nuke.toNode(HelpFunctions.safeString(thisNodeName)) # Add new labels cmdString = '' assetType = None availableAssetTypes = [''] inputMissmatch = None tableWidget = g['ftable'].getObject().tableWidget tableWidget.setRowCount(0) components = [] for inputNode in range(g.inputs()): inNode = g.input(inputNode) if inNode: if inNode.Class() in ['Read', 'Write']: nodeAssetType = 'img' elif inNode.Class() in ['WriteGeo']: nodeAssetType = 'geo' else: nodeAssetType = '' if not assetType: assetType = nodeAssetType if assetType != nodeAssetType: inputMissmatch = True if nodeAssetType == 'img': fileComp = str(inNode['file'].value()) proxyComp = str(inNode['proxy'].value()) nameComp = str(inNode['name'].value()).strip() if inNode.Class() == 'Read': first = str(inNode['first'].value()) last = str(inNode['last'].value()) if first == '0.0' and last == '0.0': first = str( int(nuke.root().knob( "first_frame").value())) last = str( int(nuke.root().knob( "last_frame").value())) availableAssetTypes = ['img', 'render'] elif inNode.Class() == 'Write': # use the timeline to define the amount of frames first = str( int(nuke.root().knob("first_frame").value())) last = str( int(nuke.root().knob("last_frame").value())) # then in case check if the limit are set if inNode['use_limit'].value(): first = str(inNode['first'].value()) last = str(inNode['last'].value()) # always check how many frames are actually available frames = inNode['file'].value() try: # Try to collect the sequence prefix, padding # and extension. If this fails with a ValueError # we are probably handling a non-sequence file. # If so rely on the first_frame and last_frame # of the root node. prefix, padding, extension = frames.split('.') except ValueError: FnAssetAPI.logging.debug( 'Could not determine prefix, padding ' 'and extension from "".'.format(frames)) availableAssetTypes = ['render'] else: root = os.path.dirname(prefix) files = glob.glob('{0}/*.{1}'.format( root, extension)) collections = clique.assemble(files) for collection in collections[0]: if prefix in collection.head: indexes = list(collection.indexes) first = str(indexes[0]) last = str(indexes[-1]) break availableAssetTypes = ['img'] try: compNameComp = inNode['fcompname'].value() except: compNameComp = '' if compNameComp == '': compNameComp = nameComp components.append( (fileComp, compNameComp, first, last, nameComp)) if proxyComp != '': components.append( (proxyComp, compNameComp + '_proxy', first, last, nameComp)) elif nodeAssetType == 'geo': fileComp = str(inNode['file'].value()) nameComp = str(inNode['name'].value()).strip() first = str(inNode['first'].value()) last = str(inNode['last'].value()) if first == '0.0' and last == '0.0': first = str( int(nuke.root().knob("first_frame").value())) last = str( int(nuke.root().knob("last_frame").value())) try: compNameComp = inNode['fcompname'].value() except: compNameComp = '' if compNameComp == '': compNameComp = nameComp components.append( (fileComp, compNameComp, first, last, nameComp)) availableAssetTypes = ['geo', 'cam'] rowCount = len(components) tableWidget.setRowCount(rowCount) if len(components) == 0: g.knob('pknob').setEnabled(False) else: g.knob('pknob').setEnabled(True) l = [x[1] for x in components] wodup = list(set(l)) if len(l) != len(wodup): g.knob('pknob').setEnabled(False) header.setMessage('Components can not have the same name', 'warning') rowCntr = 0 for comp in components: cb = QtWidgets.QCheckBox('') cb.setChecked(True) tableWidget.setCellWidget(rowCntr, 0, cb) componentItem = QtWidgets.QTableWidgetItem() componentItem.setText(comp[0]) componentItem.setToolTip(comp[0]) tableWidget.setItem(rowCntr, 1, componentItem) componentItem = QtWidgets.QTableWidgetItem() componentItem.setText(comp[1]) componentItem.setToolTip(comp[1]) tableWidget.setItem(rowCntr, 2, componentItem) try: fileCurrentFrame = nukescripts.replaceHashes( comp[0]) % int(float(comp[2])) except: print 'File is not sequence' fileCurrentFrame = comp[0] if os.path.isfile(fileCurrentFrame): fileExist = 'T' else: fileExist = 'F' componentItem = QtWidgets.QTableWidgetItem() if fileExist == 'T': componentItem.setBackground(QtGui.QColor(20, 161, 74)) else: componentItem.setBackground(QtGui.QColor(227, 99, 22)) componentItem.setToolTip(fileExist) tableWidget.setItem(rowCntr, 4, componentItem) componentItem = QtWidgets.QTableWidgetItem() componentItem.setText(comp[2]) componentItem.setToolTip(comp[2]) tableWidget.setItem(rowCntr, 5, componentItem) componentItem = QtWidgets.QTableWidgetItem() componentItem.setText(comp[3]) componentItem.setToolTip(comp[3]) tableWidget.setItem(rowCntr, 6, componentItem) componentItem = QtWidgets.QTableWidgetItem() componentItem.setText(comp[4]) componentItem.setToolTip(comp[4]) tableWidget.setItem(rowCntr, 3, componentItem) rowCntr += 1 g['ftrackassettype'].setValues(availableAssetTypes) if inputMissmatch: tableWidget.setRowCount(0) g['ftrackassettype'].setValues(['Missmatch inputs']) if cmdString == '': cmdString = 'No inputs connected' assetEnums = ['New'] if nodeAssetType != '': # assets = connector.Connector.objectById(os.environ['FTRACK_SHOTID']).getAssets(assetTypes=[g['ftrackassettype'].value()]) pubto = g.knob('fpubto').getObject().targetTask assets = connector.Connector.objectById(pubto).getAssets( assetTypes=[g['ftrackassettype'].value()]) assets = sorted(assets, key=lambda entry: entry.getName().lower()) assetEnums = assetEnums + [ HelpFunctions.safeString(x.getName()) for x in assets ] FnAssetAPI.logging.info(assetEnums) g['fassetnameexisting'].setValues(assetEnums) g = nuke.toNode(HelpFunctions.safeString(thisNodeName)) g.begin() # Add more inputs if full realInputCount = 0 for inputNode in range(g.inputs()): if g.input(inputNode): realInputCount += 1 if realInputCount == g.maxInputs(): inputNode = nuke.createNode("Input", inpanel=False) g.end() elif nuke.thisKnob().name() == 'ftrackassettype': nodeAssetType = g['ftrackassettype'].value() #print nodeAssetType assetEnums = ['New'] if nodeAssetType != '' and nodeAssetType != 'Missmatch inputs': # assets = connector.Connector.objectById(os.environ['FTRACK_SHOTID']).getAssets(assetTypes=[nodeAssetType]) pubto = g.knob('fpubto').getObject().targetTask assets = connector.Connector.objectById(pubto).getAssets( assetTypes=[nodeAssetType]) assetEnums = assetEnums + [ HelpFunctions.safeString(x.getName()) for x in assets ] g['fassetnameexisting'].setValues(assetEnums)
def _build(self): '''Build and layout widget.''' layout = QtWidgets.QVBoxLayout() self.setLayout(layout) # Header header = ftrack_connect.ui.widget.header.Header( getpass.getuser(), self) header.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Fixed) layout.addWidget(header) secondaryHeader = QtWidgets.QFrame() headerLayout = QtWidgets.QHBoxLayout() headerLayout.setContentsMargins(0, 0, 0, 0) secondaryHeader.setLayout(headerLayout) layout.addWidget(secondaryHeader) self._createButton = QtWidgets.QToolButton() self._createButton.setIcon( QtGui.QIcon.fromTheme('plus', QtGui.QIcon(':icon-plus'))) headerLayout.addWidget(self._createButton) self._navigateUpButton = QtWidgets.QToolButton() self._navigateUpButton.setIcon( QtGui.QIcon.fromTheme('go-up', QtGui.QIcon(':icon-arrow-up'))) headerLayout.addWidget(self._navigateUpButton) headerLayout.addStretch(1) # Bookmarks contentSplitter = QtWidgets.QSplitter() layout.addWidget(contentSplitter) self._bookmarksView = QtWidgets.QTableWidget() self._bookmarksView.setEditTriggers( QtWidgets.QAbstractItemView.NoEditTriggers) self._bookmarksView.setGridStyle(QtCore.Qt.NoPen) self._bookmarksView.setColumnCount(1) self._bookmarksView.setColumnCount(1) self._bookmarksView.setRowCount(0) self._bookmarksView.horizontalHeader().setVisible(False) self._bookmarksView.horizontalHeader().setStretchLastSection(True) self._bookmarksView.verticalHeader().setVisible(False) self._bookmarksView.verticalHeader().setDefaultSectionSize(25) contentSplitter.addWidget(self._bookmarksView) # Navigation self._navigator = QtWidgets.QTableWidget() self._navigator.setEditTriggers( QtWidgets.QAbstractItemView.NoEditTriggers) self._navigator.setGridStyle(QtCore.Qt.NoPen) self._navigator.setColumnCount(1) self._navigator.horizontalHeader().setStretchLastSection(True) self._navigator.verticalHeader().hide() self._navigator.setHorizontalHeaderLabels(['Name']) contentSplitter.addWidget(self._navigator) self._versionsNavigator = QtWidgets.QTableWidget() self._versionsNavigator.setEditTriggers( QtWidgets.QAbstractItemView.NoEditTriggers) self._versionsNavigator.setGridStyle(QtCore.Qt.NoPen) self._versionsNavigator.setColumnCount(1) self._versionsNavigator.verticalHeader().hide() self._versionsNavigator.setSortingEnabled(False) self._versionsNavigator.setHorizontalHeaderLabels(['Version']) contentSplitter.addWidget(self._versionsNavigator) self._componentsNavigator = QtWidgets.QTableWidget() self._componentsNavigator.setEditTriggers( QtWidgets.QAbstractItemView.NoEditTriggers) self._componentsNavigator.setColumnCount(1) self._componentsNavigator.horizontalHeader().setStretchLastSection( True) self._componentsNavigator.verticalHeader().hide() self._componentsNavigator.verticalHeader().setStretchLastSection(False) self._componentsNavigator.setHorizontalHeaderLabels(['Component']) contentSplitter.addWidget(self._componentsNavigator) # Details self._detailView = ftrack_connect_foundry.ui.detail_view.DetailView( self._bridge) contentSplitter.addWidget(self._detailView) # Location self._locationField = QtWidgets.QLineEdit() layout.addWidget(self._locationField) self._locationOptions = QtWidgets.QFrame() layout.addWidget(self._locationOptions) locationOptionsLayout = QtWidgets.QHBoxLayout() locationOptionsLayout.setContentsMargins(0, 0, 0, 0) self._locationOptions.setLayout(locationOptionsLayout) self._assetNameField = QtWidgets.QLineEdit() self._assetNameField.setEnabled(False) locationOptionsLayout.addWidget(self._assetNameField) self._overrideNameHintOption = QtWidgets.QCheckBox( 'Specify Asset Name') locationOptionsLayout.addWidget(self._overrideNameHintOption)