def setupContentUi(self, parent): """ Build the content ui for this BatchBuildAction. Creates ui to manage the array of variant attributes. """ # constants main layout self.constantsLayout = QtWidgets.QVBoxLayout(parent) self.constantsLayout.setContentsMargins(0, 0, 0, 0) self.mainLayout.addLayout(self.constantsLayout) spacer = QtWidgets.QSpacerItem(20, 4, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.mainLayout.addItem(spacer) # variant header variantHeader = QtWidgets.QFrame(parent) variantHeader.setStyleSheet( ".QFrame{ background-color: rgb(255, 255, 255, 15); border-radius: 2px }" ) self.mainLayout.addWidget(variantHeader) variantHeaderLayout = QtWidgets.QHBoxLayout(variantHeader) variantHeaderLayout.setContentsMargins(10, 4, 4, 4) variantHeaderLayout.setSpacing(4) self.variantsLabel = QtWidgets.QLabel(variantHeader) self.variantsLabel.setText("Variants: {0}".format( len(self.buildItem.variantValues))) variantHeaderLayout.addWidget(self.variantsLabel) spacer = QtWidgets.QSpacerItem(20, 4, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.mainLayout.addItem(spacer) # add variant button addVariantBtn = QtWidgets.QPushButton(variantHeader) addVariantBtn.setText('+') addVariantBtn.setFixedSize(QtCore.QSize(20, 20)) addVariantBtn.clicked.connect(self.addVariant) variantHeaderLayout.addWidget(addVariantBtn) # variant list main layout self.variantLayout = QtWidgets.QVBoxLayout(parent) self.variantLayout.setContentsMargins(0, 0, 0, 0) self.variantLayout.setSpacing(4) self.mainLayout.addLayout(self.variantLayout) self.setupConstantsUi(parent) self.setupVariantsUi(parent)
def setupUi(self, parent): layout = QtWidgets.QVBoxLayout(self) propertiesHeader = createHeaderLabel(parent, "Rig Properties") layout.addWidget(propertiesHeader) rigNameLabel = QtWidgets.QLabel(parent) rigNameLabel.setText("Rig Name") self.rigNameText = QtWidgets.QLineEdit(parent) self.rigNameText.setText(self.blueprintModel.getRigName()) self.rigNameText.textChanged.connect(self.rigNameTextChanged) formLayout1 = QtWidgets.QFormLayout(parent) formLayout1.setWidget(0, QtWidgets.QFormLayout.LabelRole, rigNameLabel) formLayout1.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.rigNameText) layout.addLayout(formLayout1) fileNameLabel = QtWidgets.QLabel(parent) fileNameLabel.setText("File Name") self.fileNameText = QtWidgets.QLineEdit(parent) self.fileNameText.setText(self.getSceneRelativeFilePath(self.blueprintModel.getBlueprintFilepath())) self.fileNameText.setReadOnly(True) formLayout2 = QtWidgets.QFormLayout(parent) formLayout2.setWidget(0, QtWidgets.QFormLayout.LabelRole, fileNameLabel) formLayout2.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.fileNameText) layout.addLayout(formLayout2) spacer = QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) layout.addItem(spacer) self.refreshState()
def setupUi(self, parent): layout = QtWidgets.QVBoxLayout(self) formLayout1 = QtWidgets.QFormLayout(self) rigNameLabel = QtWidgets.QLabel(self) rigNameLabel.setText("Rig Name") self.rigNameText = QtWidgets.QLineEdit(self) self.rigNameText.setText(self.blueprintModel.getRigName()) self.rigNameText.textChanged.connect(self.rigNameTextChanged) formLayout1.setWidget(0, QtWidgets.QFormLayout.LabelRole, rigNameLabel) formLayout1.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.rigNameText) layout.addLayout(formLayout1) initBtn = QtWidgets.QPushButton(self) initBtn.setText("Initialize Blueprint") initBtn.clicked.connect(self.initBlueprint) layout.addWidget(initBtn) debugPrintBtn = QtWidgets.QPushButton(self) debugPrintBtn.setText("Debug Print YAML") debugPrintBtn.clicked.connect(self.debugPrintSerialized) layout.addWidget(debugPrintBtn) spacer = QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) layout.addItem(spacer) self.refreshState()
def __init__(self, parent=None): super(BlueprintEditorWidget, self).__init__(parent=parent) self.model = ActionTreeItemModel.getSharedModel() self.model.modelReset.connect(self.onBlueprintLoaded) layout = QtWidgets.QVBoxLayout(self) self.rigNameText = QtWidgets.QLineEdit(self) self.rigNameText.setText(self.blueprint.rigName) self.rigNameText.textChanged.connect(self.rigNameTextChanged) layout.addWidget(self.rigNameText) createBtn = QtWidgets.QPushButton(self) createBtn.setText("Create Default Blueprint") createBtn.clicked.connect(self.createDefaultBlueprint) layout.addWidget(createBtn) saveBtn = QtWidgets.QPushButton(self) saveBtn.setText("Debug Save Blueprint") saveBtn.clicked.connect(self.debugSaveBlueprint) layout.addWidget(saveBtn) debugPrintBtn = QtWidgets.QPushButton(self) debugPrintBtn.setText("Debug Print Serialized") debugPrintBtn.clicked.connect(self.debugPrintSerialized) layout.addWidget(debugPrintBtn) debugOpenBpBtn = QtWidgets.QPushButton(self) debugOpenBpBtn.setText("Debug Open Blueprint Scene") debugOpenBpBtn.clicked.connect(self.debugOpenBlueprintScene) layout.addWidget(debugOpenBpBtn) spacer = QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) layout.addItem(spacer)
def setupUi(self, parent): outerLayout = QtWidgets.QVBoxLayout(parent) self.scrollArea = QtWidgets.QScrollArea(parent) self.scrollArea.setFrameShape(QtWidgets.QScrollArea.NoFrame) self.scrollArea.setWidgetResizable(True) outerLayout.addWidget(self.scrollArea) self.scrollWidget = QtWidgets.QWidget() self.scrollArea.setWidget(self.scrollWidget) # scroll layout contains the main layout and a spacer item self.scrollLayout = QtWidgets.QVBoxLayout(self.scrollWidget) self.scrollLayout.setMargin(0) self.mainLayout = QtWidgets.QVBoxLayout(self.scrollWidget) self.mainLayout.setSpacing(12) self.mainLayout.setMargin(4) self.scrollLayout.addLayout(self.mainLayout) spacer = QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.scrollLayout.addItem(spacer) self.scrollWidget.setLayout(self.scrollLayout)
def setupVariantsUi(self, parent, layout): # variant header variantHeader = QtWidgets.QFrame(parent) variantHeader.setStyleSheet( ".QFrame{ background-color: rgb(255, 255, 255, 15); border-radius: 2px }" ) layout.addWidget(variantHeader) variantHeaderLayout = QtWidgets.QHBoxLayout(variantHeader) variantHeaderLayout.setContentsMargins(10, 4, 4, 4) variantHeaderLayout.setSpacing(4) self.variantsLabel = QtWidgets.QLabel(variantHeader) self.variantsLabel.setText("Variants: ") variantHeaderLayout.addWidget(self.variantsLabel) spacer = QtWidgets.QSpacerItem(20, 4, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) layout.addItem(spacer) # add variant button addVariantBtn = QtWidgets.QPushButton(variantHeader) addVariantBtn.setText('+') addVariantBtn.setFixedSize(QtCore.QSize(20, 20)) addVariantBtn.clicked.connect(self.addVariant) variantHeaderLayout.addWidget(addVariantBtn) # variant list layout self.variantListLayout = QtWidgets.QVBoxLayout(parent) self.variantListLayout.setContentsMargins(0, 0, 0, 0) self.variantListLayout.setSpacing(4) layout.addLayout(self.variantListLayout)
def setupPanelsUi(self, layout, parent): general = GeneralPanel(parent) layout.addWidget(general) controls = ControlsPanel(parent) layout.addWidget(controls) joints = JointsPanel(parent) layout.addWidget(joints) spacer = QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) layout.addItem(spacer)
def setupUi(self, parent): hlayout = QtWidgets.QHBoxLayout(parent) hlayout.setContentsMargins(2, 2, 2, 2) pickButton = QtWidgets.QPushButton(parent) pickButton.setIcon(viewutils.getIcon("select.png")) pickButton.setFixedSize(QtCore.QSize(20, 20)) pickButton.clicked.connect(self.setFromSelection) hlayout.addWidget(pickButton) hlayout.setAlignment(pickButton, QtCore.Qt.AlignTop) # body spacer spacer = QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) hlayout.addItem(spacer)
def setupSuffixesUi(self, parent): """ Build the suffixes layout and button grid. Returns the layout. """ suffixLayout = QtWidgets.QVBoxLayout(parent) suffixesLabel = self.createLabel(parent, "Suffixes", bold=True) suffixLayout.addWidget(suffixesLabel) self.suffixBtnGrid = QtWidgets.QGridLayout() self.suffixBtnGrid.setObjectName("suffixBtnGrid") # create button for all suffixes self.suffixBtns = {} suffixes = self.namesConfig.get('suffixes', {}) x = 0 y = 0 for suffix in suffixes: name = suffix['name'] btn = QtWidgets.QPushButton() btn.setText(name) btn.setCheckable(True) btn.clicked.connect(self.onPrefixOrSuffixClicked) self.suffixBtnGrid.addWidget(btn, y, x, 1, 1) self.suffixBtns[name] = btn x += 1 if x > 1: x = 0 y += 1 suffixLayout.addLayout(self.suffixBtnGrid) spacerItem = QtWidgets.QSpacerItem(0, 2, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) suffixLayout.addItem(spacerItem) return suffixLayout
def setupUi(self, parent): """ Build the content ui for this BatchBuildAction. Creates ui to manage the array of variant attributes. """ layout = QtWidgets.QVBoxLayout(parent) layout.setSpacing(4) layout.setMargin(0) # form for all main / invariant attributes mainAttrForm = MainBuildActionDataForm(self.index, parent=parent) layout.addWidget(mainAttrForm) spacer = QtWidgets.QSpacerItem(20, 4, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) layout.addItem(spacer) # variant form list if self.shouldSetupVariantsUi(): self.setupVariantsUi(parent, layout) self.hasVariantsUi = True
def setupContentUi(self, parent): """ Build the action buttons UI """ layout = QtWidgets.QVBoxLayout(parent) allActionConfigs = pulse.getRegisteredActionConfigs() # make button for each action categories = [c.get('category', 'Default') for c in allActionConfigs] categories = list(set(categories)) categoryLayouts = {} # create category layouts for cat in sorted(categories): # add category layout catLay = QtWidgets.QVBoxLayout(parent) catLay.setSpacing(4) layout.addLayout(catLay) categoryLayouts[cat] = catLay # add label label = createHeaderLabel(parent, cat) catLay.addWidget(label) for actionConfig in allActionConfigs: actionId = actionConfig['id'] actionCategory = actionConfig.get('category', 'Default') color = self.getActionColor(actionConfig) btn = QtWidgets.QPushButton(parent) btn.setText(actionConfig['displayName']) btn.setStyleSheet( 'background-color:rgba({0}, {1}, {2}, 30)'.format(*color)) btn.setMinimumHeight(22) cmd = lambda x=actionId: self.createBuildAction(x) btn.clicked.connect(cmd) categoryLayouts[actionCategory].addWidget(btn) spacer = QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) layout.addItem(spacer)
def setupContentUi(self, parent): layout = QtWidgets.QVBoxLayout(parent) # make button for each action registeredActions = pulse.getRegisteredActions().values() categories = list( set([ ac.config.get('category', 'Default') for ac in registeredActions ])) categoryLayouts = {} # create category layouts for i, cat in enumerate(sorted(categories)): # add category layout catLay = QtWidgets.QVBoxLayout(parent) catLay.setSpacing(4) layout.addLayout(catLay) categoryLayouts[cat] = catLay # add label label = self.createLabel(parent, cat) catLay.addWidget(label) for actionClass in registeredActions: cat = actionClass.config.get('category', 'Default') color = self.getActionColor(actionClass) btn = QtWidgets.QPushButton(parent) btn.setText(actionClass.config['displayName']) btn.setStyleSheet( 'background-color:rgba({0}, {1}, {2}, 30)'.format(*color)) btn.setMinimumHeight(22) cmd = lambda x=actionClass.getTypeName(): self.createBuildAction(x) btn.clicked.connect(cmd) categoryLayouts[cat].addWidget(btn) spacer = QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) layout.addItem(spacer)
def setupPanelsUi(self, layout, parent): controls = ControlsPanel(parent) layout.addWidget(controls) general = GeneralPanel(parent) layout.addWidget(general) layoutPanel = LayoutPanel(parent) layout.addWidget(layoutPanel) joints = JointsPanel(parent) layout.addWidget(joints) jointOrients = JointOrientsPanel(parent) layout.addWidget(jointOrients) sym = SymmetryPanel(parent) layout.addWidget(sym) spacer = QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) layout.addItem(spacer)
def setupKeywordsUi(self, parent): """ Build the keywords layout and all categories and button grids. Returns the layout. """ keywordsLayout = QtWidgets.QVBoxLayout(parent) keywordsLabel = self.createLabel(parent, "Names", bold=True) keywordsLayout.addWidget(keywordsLabel) scrollArea = QtWidgets.QScrollArea(parent) scrollArea.setFrameShape(QtWidgets.QScrollArea.NoFrame) scrollArea.setWidgetResizable(True) scrollWidget = QtWidgets.QWidget() scrollLayout = QtWidgets.QVBoxLayout(scrollWidget) # create category and btn grid for all keywords self.keywordBtns = {} keywords = self.namesConfig.get('keywords', {}) categoryNames = sorted(keywords.keys()) for catName in categoryNames: catKeywords = keywords[catName] catLayout = self.setupKeywordCategoryUi(scrollWidget, catName, catKeywords) scrollLayout.addLayout(catLayout) keywordsSpacer = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) scrollLayout.addItem(keywordsSpacer) scrollArea.setWidget(scrollWidget) keywordsLayout.addWidget(scrollArea) return keywordsLayout
def createVSpacer(width=20, height=20): return QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
def setupConstantsUi(self, parent): viewutils.clearLayout(self.constantsLayout) # create attr form all constant attributes for attr in self.buildItem.actionClass.config['attrs']: isConstant = (attr['name'] in self.buildItem.constantValues) # make an HBox with a button to toggle variant state attrHLayout = QtWidgets.QHBoxLayout(parent) attrHLayout.setSpacing(10) attrHLayout.setMargin(0) self.constantsLayout.addLayout(attrHLayout) if isConstant: # constant value, make an attr form attrValue = self.buildItem.constantValues[attr['name']] context = self.buildItem.constantValues attrForm = ActionAttrForm.createForm(attr, attrValue, parent=parent) attrForm.valueChanged.connect( partial(self.attrValueChanged, context, attrForm)) attrHLayout.addWidget(attrForm) else: # variant value, check for batch editor, or just display a label attrLabel = QtWidgets.QLabel(parent) # extra 2 to account for the left-side frame padding that occurs in the ActionAttrForm attrLabel.setFixedSize( QtCore.QSize(ActionAttrForm.LABEL_WIDTH + 2, ActionAttrForm.LABEL_HEIGHT)) attrLabel.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignTop) attrLabel.setMargin(2) attrLabel.setText(pulse.names.toTitle(attr['name'])) attrLabel.setEnabled(False) attrHLayout.addWidget(attrLabel) if BatchAttrForm.doesFormExist(attr): batchEditor = BatchAttrForm.createForm(self.buildItem, attr, parent=parent) batchEditor.valuesChanged.connect( self.batchEditorValuesChanged) attrHLayout.addWidget(batchEditor) else: spacer = QtWidgets.QSpacerItem( 24, 24, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) attrHLayout.addItem(spacer) # not a constant value, add a line with button to make it constant # button to toggle variant toggleVariantBtn = QtWidgets.QPushButton(parent) toggleVariantBtn.setText("v") toggleVariantBtn.setFixedSize(QtCore.QSize(20, 20)) toggleVariantBtn.setCheckable(True) toggleVariantBtn.setChecked(not isConstant) attrHLayout.addWidget(toggleVariantBtn) attrHLayout.setAlignment(toggleVariantBtn, QtCore.Qt.AlignTop) toggleVariantBtn.clicked.connect( partial(self.setIsVariantAttr, attr['name'], isConstant))