def __init__(self, parent): QtWidgets.QWidget.__init__(self, parent) layout = QtWidgets.QHBoxLayout(self) layout.setContentsMargins(4, 4, 4, 4) layout.setSpacing(2) self.__iconLabel = QtWidgets.QLabel('', self) self.__iconLabel.setFixedSize(QtCore.QSize(16, 16)) self.__textLabel = QtWidgets.QLabel('', self) self.__inputEdit = QT4FormWidgets.InputWidgets.InputLineEdit(self) self.__inputEdit.hide() layout.addWidget(self.__iconLabel) layout.addWidget(self.__textLabel) layout.addWidget(self.__inputEdit, 2) layout.addStretch() self.__enableCustomName = QtWidgets.QCheckBox('use custom asset name', self) self.__enableCustomName.hide() self.setFixedHeight(self.__inputEdit.height()) layout.addWidget(self.__enableCustomName) self.__enableCustomName.clicked.connect(self.__enableClicked) if hasattr(self.__inputEdit, 'EMITS_CUSTOM_FOCUS_EVENTS' ) and self.__inputEdit.EMITS_CUSTOM_FOCUS_EVENTS: self.__inputEdit.lostFocus.connect(self.__customFieldChanged) else: self.__inputEdit.lostFocus.connect(self.__customFieldChanged)
def __init__(self, parent, group): super(UsdMaterialBakeEditor, self).__init__(parent=parent) self.setLayout(QtWidgets.QVBoxLayout()) self.__groupNode = group self.__interruptWidget = None self.__timer = None #For auto upgrade in the future # pylint: disable=undefined-variable versionValue = 1 versionParam = group.getParameter('__networkVersion') if versionParam: versionValue = int(versionParam.getValue(0)) self.__widgetFactory = UI4.FormMaster.ParameterWidgetFactory widgets = [] self.__rootPolicy = UI4.FormMaster.CreateParameterPolicy( None, group.getParameters()) widgets.append(self.__widgetFactory.buildWidget( self, self.__rootPolicy.getChildByName('rootLocations'))) variantsWidget = VariantsWidget(self.__groupNode, parent=self) widgets.append(variantsWidget) widgets.append(UI4.Widgets.VBoxLayoutResizer(variantsWidget)) widgets.append(self.__widgetFactory.buildWidget( self, self.__rootPolicy.getChildByName('saveTo'))) widgets.append(self.__widgetFactory.buildWidget( self, self.__rootPolicy.getChildByName('looksFilename'))) widgets.append(self.__widgetFactory.buildWidget( self, self.__rootPolicy.getChildByName('looksFileFormat'))) widgets.append(self.__widgetFactory.buildWidget( self, self.__rootPolicy.getChildByName('alwaysCreateVariantSet'))) widgets.append(self.__widgetFactory.buildWidget( self, self.__rootPolicy.getChildByName( 'createCompleteUsdAssemblyFile'))) widgets.append(self.__widgetFactory.buildWidget( self, self.__rootPolicy.getChildByName('assemblyFilename'))) widgets.append(self.__widgetFactory.buildWidget( self, self.__rootPolicy.getChildByName('payloadFilename'))) widgets.append(self.__widgetFactory.buildWidget( self, self.__rootPolicy.getChildByName('rootPrimName'))) widgets.append(self.__widgetFactory.buildWidget( self, self.__rootPolicy.getChildByName('variantSetName'))) labelWidthList = [] for w in widgets: if hasattr(w, "getLabelWidth"): labelWidthList.append(w.getLabelWidth()) maxLabelWidth = reduce(max, labelWidthList) for w in widgets: if hasattr(w, "setLabelWidth"): w.setLabelWidth(maxLabelWidth) self.layout().addWidget(w) self.__writeButton = QtWidgets.QPushButton("Write", parent=self) self.__writeButton.clicked.connect( lambda checked : self.__groupNode.bake(parentWidget=self)) self.layout().addWidget(self.__writeButton)
def __init__(self): QtWidgets.QDialog.__init__(self, None) self.setWindowTitle('Duplicate Asset Found') layout = QtWidgets.QVBoxLayout(self) self.__productLabel = QtWidgets.QLabel('', self) layout.addWidget(self.__productLabel) layout.addSpacing(32) layout.addStretch() checkboxLayout = QtWidgets.QHBoxLayout(self) layout.addItem(checkboxLayout) self.__doForAllCheckbox = QtWidgets.QCheckBox( 'Apply Action To All Remaining Duplicates', self) checkboxLayout.addWidget(self.__doForAllCheckbox) checkboxLayout.addStretch() self.__skipButton = QtWidgets.QPushButton('Skip', self) self.__addAnywayButton = QtWidgets.QPushButton('Add Anyway', self) self.__cancelButton = QtWidgets.QPushButton('Cancel', self) buttonLayout = QtWidgets.QHBoxLayout() layout.addItem(buttonLayout) buttonLayout.addStretch() buttonLayout.addWidget(self.__skipButton) buttonLayout.addWidget(self.__addAnywayButton) buttonLayout.addWidget(self.__cancelButton) self.__cancelButton.clicked.connect(self.reject) self.__skipButton.clicked.connect(self.__skipButtonClicked) self.__addAnywayButton.clicked.connect(self.__addAnywayButtonClicked) self.__result = None return
def customContextMenu(self, pos): """ Open up a custom context menu. """ # pylint: disable=unused-argument self.deleteSelectedAction.setEnabled(self.listWidget.currentRow() > -1) menu = QtWidgets.QMenu() menu.addAction(self.deleteSelectedAction) menu.exec_(QtGui.QCursor.pos())
def __init__(self, parent, node, portName): QtWidgets.QWidget.__init__(self, parent) self.__node = node self.__portName = portName QtWidgets.QHBoxLayout(self) self.layout().setContentsMargins(2, 2, 2, 2) self.layout().setSpacing(2) self.__label = QtWidgets.QLabel('output', self) self.__field = QT4FormWidgets.InputWidgets.InputLineEdit(self) self.__field.setText(portName) self.layout().addWidget(self.__label) self.layout().addWidget(self.__field) self.setMinimumHeight(self.__field.height()) if portName == 'default': self.__field.setReadOnly(True) return if hasattr(self.__field, 'EMITS_CUSTOM_FOCUS_EVENTS' ) and self.__field.EMITS_CUSTOM_FOCUS_EVENTS: self.__field.lostFocus.connect(self.__returnPressedCallback) else: self.__field.lostFocus.connect(self.__returnPressedCallback)
def updateWidgets(self): """ Perform a clean reset of the widget and its items. """ self.listWidget.clear() # Ensure self.minPorts default ports always available. for port in self.node.getInputPorts()[self.minPorts:]: item = QtWidgets.QListWidgetItem(port.getName()) item.setFlags(QtCore.Qt.ItemIsDragEnabled | QtCore.Qt.ItemIsDropEnabled | QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemNeverHasChildren | QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEditable) self.listWidget.addItem(item)
def setup_root_menu(self): """ Attempts to find an existing menu of the specified title. If it can't be found, it creates one. """ # Get the "main menu" (the bar of menus) try: main_menu = self.get_katana_main_bar() except Exception as error: message = 'Failed to get main Katana menu bar: {}'.format(error) self.engine.log_debug(message) return # Attempt to find existing menu for menu in main_menu.children(): is_menu = isinstance(menu, QtWidgets.QMenu) if is_menu and menu.title() == self.menu_name: return menu # Otherwise, create a new menu menu = QtWidgets.QMenu(self.menu_name, main_menu) main_menu.addMenu(menu) return menu
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
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
def __init__(self, node, newVariantName=None, parent=None): """ @param node: The UsdMaterialBake node which should have the following methods. addVariantInput, deleteVariantInput, reorderInput, renameVariantInput, require3DInput, and the MIN_PORTS attribute. @param newVariantName: The name to use when adding new variants with the plus button. If not set, it will default to "variant" @param parent: The Qt parent widget for this QFrame. @type node: C{GroupNode} (Supertool) @type newVariantName: C{str} @type parent: C{QtWidgets.Widget} """ super(VariantsWidget, self).__init__(parent=parent) self.node = node self.newVariantName = newVariantName or "variant" self.minPorts = self.node.MIN_PORTS self.setAutoFillBackground(True) self.setBackgroundRole(QtGui.QPalette.Base) Utils.EventModule.RegisterEventHandler(self.__onAddOrRemoveInputPort, 'node_addInputPort', None) Utils.EventModule.RegisterEventHandler(self.__onAddOrRemoveInputPort, 'node_removeInputPort', None) # Toolbar to work as heading for Variants widget. self.toolbar = QtWidgets.QToolBar(self) self.toolbar.setMovable(False) variantsLabel = QtWidgets.QLabel("Variants") variantsLabel.setIndent(6) self.toolbar.addWidget(variantsLabel) # Spacer widget to allow us to align some widgets to the right of the # toolbar. spacerWidget = QtWidgets.QWidget(self) spacerWidget.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) spacerWidget.setVisible(True) self.toolbar.addWidget(spacerWidget) # Toolbar Actions addIcon = UI4.Util.IconManager.GetIcon('Icons/plus16.png') self.addAction = self.toolbar.addAction(addIcon, "Add") self.addAction.triggered.connect(self.addNewVariant) # List Widget self.listWidget = VariantsListWidget(self) self.listWidget.itemChanged.connect(self.__onCurrentTextChanged) self.listWidget.customContextMenuRequested.connect( self.customContextMenu) self.listWidget.model().rowsMoved.connect(self.__onRowMoved) self.deleteSelectedAction = QtWidgets.QAction('Delete', self.listWidget) self.listWidget.addAction(self.deleteSelectedAction) self.deleteSelectedAction.triggered.connect(self.deleteSelectedVariant) self.deleteSelectedAction.setShortcut(QtCore.Qt.Key_Delete) # Layout layout = QtWidgets.QVBoxLayout() layout.setSpacing(0) self.setLayout(layout) layout.addWidget(self.toolbar) layout.addWidget(self.listWidget) self.updateWidgets()