コード例 #1
0
    def __init__(self, *args, **kwargs):
        '''Instantiate the asset options.'''
        super(AssetOptions, self).__init__(*args, **kwargs)

        self.logger = logging.getLogger(
            __name__ + '.' + self.__class__.__name__
        )

        self._entity = None
        self._hasEditedName = False

        self.radioButtonFrame = QtWidgets.QFrame()
        self.radioButtonFrame.setLayout(QtWidgets.QHBoxLayout())
        self.radioButtonFrame.layout().setContentsMargins(5, 5, 5, 5)

        self.newAssetButton = QtWidgets.QRadioButton('Create new')
        self.newAssetButton.toggled.connect(self._onNewAssetToggled)
        self.radioButtonFrame.layout().addWidget(self.newAssetButton)

        self.existingAssetButton = QtWidgets.QRadioButton('Version up existing')
        self.existingAssetButton.toggled.connect(self._onExistingAssetToggled)
        self.radioButtonFrame.layout().addWidget(self.existingAssetButton)

        self.existingAssetSelector = _asset_selector.AssetSelector()
        self.assetTypeSelector = _asset_type_selector.AssetTypeSelector()
        self.assetNameLineEdit = _asset_name_edit.AssetNameEdit(
            self.existingAssetSelector, self.assetTypeSelector
        )

        self.assetTypeSelector.currentIndexChanged.connect(self._onAssetTypeChanged)
        self.assetNameLineEdit.textEdited.connect(self._onAssetNameEdited)
コード例 #2
0
  def __init__(self, parent=None, session=None, context=None):
    super(BuildAssetTrackDialog, self).__init__(parent)

    self.setWindowTitle("Build Track")

    if not session:
      session = FnAssetAPI.SessionManager.currentSession()
    self.__session = session

    if not context:
      context = session.createContext()
    self.__context = context

    self.__selection = []
    self.__entities = []
    self.__ignoreClips = False

    self.__lastIgnoreClips = None
    self.__lastParentRef = None

    layout = QtWidgets.QVBoxLayout()
    self.setLayout(layout)

     # Asset Manager Widget

    self.__relationshipWidget = session.getManagerWidget(
        kWorkflowRelationshipWidgetId, args=[context,])
    layout.addWidget(self.__relationshipWidget)

    # Stretch
    layout.addStretch()

    # Options

    optionsBox = QtWidgets.QGroupBox("Options")
    optionsLayout = QtWidgets.QVBoxLayout()
    optionsBox.setLayout(optionsLayout)
    layout.addWidget(optionsBox)

    self.__trackName = QtWidgets.QLineEdit()
    trackNameLayout = QtWidgets.QHBoxLayout()
    trackNameLayout.addWidget(QtWidgets.QLabel("Track Name"))
    trackNameLayout.addWidget(self.__trackName)
    optionsLayout.addLayout(trackNameLayout)

    self.__useClipsRadio = QtWidgets.QRadioButton("Match by Clip")
    self.__useShotsRadio = QtWidgets.QRadioButton("Match by Shot")
    optionsLayout.addWidget(self.__useClipsRadio)
    optionsLayout.addWidget(self.__useShotsRadio)

   ## @todo Use the project entityReferences Parent if we have one?

    context.access = context.kReadMultiple
    context.retention = context.kTransient
    specification = specifications.ShotSpecification()

    self.__shotParentPicker = self.__session.getManagerWidget(
        FnAssetAPI.ui.constants.kInlinePickerWidgetId, args=[specification, context])
    optionsLayout.addWidget(self.__shotParentPicker)

    # Buttons

    ## @todo disable the ok button if using shots and no valid entity ref

    self.__buttons = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok
        | QtWidgets.QDialogButtonBox.Cancel)
    self.__buttons.button(QtWidgets.QDialogButtonBox.Ok).setText('Build')
    layout.addWidget(self.__buttons)

    # Connections

    self.__buttons.accepted.connect(self.accept)
    self.__buttons.rejected.connect(self.reject)

    self.__useShotsRadio.toggled.connect(self.__modeChanged)
    self.__useClipsRadio.toggled.connect(self.__modeChanged)

    self.__relationshipWidget.criteriaChanged.connect(self.__syncUI)
    # This might be better on editingFinished, but there is only one text field
    # some of the time so loosing focus might not happen as required
    self.__trackName.textChanged.connect(self.__syncUI)

    self.__shotParentPicker.selectionChanged.connect(self.__parentChanged)

    self.__syncUI()

    # Make sure the name field is ready for editing as we can't create without
    self.__trackName.setFocus()
コード例 #3
0
    def parseOptions(self, rowLayout, optionElements, assetTypeName, enabled):
        '''Parse options.'''
        optionsCount = 0
        for k in range(optionElements.length()):
            optionElement = optionElements.item(k).toElement()
            optionType = optionElement.attribute('type')
            optionValue = optionElement.attribute('value')
            if optionValue == 'True':
                optionValue = True
            elif optionValue == 'False':
                optionValue = False
            optionName = optionElement.attribute('name')
            self.stackedOptions[assetTypeName].append(optionName)

            if optionType == 'float':
                floatBox = QtWidgets.QDoubleSpinBox()
                floatBox.setEnabled(enabled)
                floatBox.setObjectName(optionName)
                floatBox.setSingleStep(0.1)
                floatBox.setMaximum(sys.maxint)
                floatBox.setMinimum(-sys.maxint)
                floatBox.setValue(float(optionValue))
                rowLayout.addWidget(floatBox)
                optionsCount = 1

            if optionType == 'checkbox':
                checkBox = QtWidgets.QCheckBox()
                checkBox.setEnabled(enabled)
                checkBox.setChecked(bool(optionValue))
                checkBox.setObjectName(optionName)
                rowLayout.addWidget(checkBox)
                optionsCount = 1

            if optionType == 'string':
                textBox = QtWidgets.QLineEdit()
                textBox.setEnabled(enabled)
                textBox.setText(optionValue)
                textBox.setObjectName(optionName)
                rowLayout.addWidget(textBox)
                optionsCount = 1

            if optionType == 'combo':
                comboBox = QtWidgets.QComboBox()
                comboBox.setEnabled(enabled)
                optionitemElements = optionElement.elementsByTagName(
                    'optionitem')
                for t in range(optionitemElements.length()):
                    optionitemElement = optionitemElements.item(t).toElement()
                    optionitemValue = optionitemElement.attribute('name')
                    comboBox.addItem(optionitemValue)

                comboBox.setObjectName(optionName)
                rowLayout.addWidget(comboBox)
                optionsCount = optionitemElements.length()

            if optionType == 'radio':
                radioWidget = QtWidgets.QWidget()
                radioLayout = QtWidgets.QVBoxLayout()
                radioLayout.setSpacing(1)
                radioWidget.setLayout(radioLayout)
                optionitemElements = optionElement.elementsByTagName(
                    'optionitem')
                for t in range(optionitemElements.length()):
                    optionitemElement = optionitemElements.item(t).toElement()
                    optionitemValue = optionitemElement.attribute('value')
                    optionitemName = optionitemElement.attribute('name')
                    radioButton = QtWidgets.QRadioButton(optionitemName)
                    if bool(optionitemValue):
                        radioButton.setChecked(True)
                    radioLayout.addWidget(radioButton)
                    radioButton.setEnabled(enabled)

                    radioButton.setObjectName(optionName)
                rowLayout.addWidget(radioWidget)
                optionsCount = optionitemElements.length()
        return optionsCount