Esempio n. 1
0
    def __init__(self, data_dict, options):
        '''Instanstiate settings from *options*.'''
        super(ActionSettingsWidget, self).__init__()

        self.setLayout(QtWidgets.QFormLayout())
        self.layout().setContentsMargins(0, 0, 0, 0)

        for option in options:
            type_ = option['type']
            label = option.get('label', '')
            name = option['name']
            value = option.get('value')
            empty_text = option.get('empty_text')
            if name in data_dict.get('options', {}):
                value = data_dict['options'][name]

            if value is not None and name not in data_dict:
                # Set default value from options.
                data_dict[name] = value

            field = None

            if type_ == 'group':
                nested_dict = data_dict[name] = dict()
                settings_widget = QtWidgets.QGroupBox(label)
                settings_widget.setLayout(QtWidgets.QVBoxLayout())
                settings_widget.layout().addWidget(
                    ActionSettingsWidget(nested_dict,
                                         option.get('options', [])))
                self.layout().addRow(settings_widget)

            if type_ == 'boolean':
                field = QtWidgets.QCheckBox()
                if value is True:
                    field.setCheckState(QtCore.Qt.Checked)

                field.stateChanged.connect(
                    functools.partial(
                        self.update_on_change, data_dict, field, name,
                        lambda check_box: (check_box.checkState() == QtCore.Qt.
                                           CheckState.Checked)))

            if type_ == 'textarea':
                field = textarea.TextAreaField(empty_text or '')
                if value is not None:
                    field.setPlainText(unicode(value))

                field.value_changed.connect(
                    functools.partial(
                        self.update_on_change, data_dict, field, name,
                        lambda textarea_widget: textarea_widget.value()))

            if type_ == 'text':
                field = QtWidgets.QLineEdit()
                if value is not None:
                    field.insert(unicode(value))

                field.textChanged.connect(
                    functools.partial(self.update_on_change, data_dict, field,
                                      name,
                                      lambda line_edit: line_edit.text()))

            if type_ == 'number':
                field = QtWidgets.QDoubleSpinBox()
                if value is not None:
                    field.setValue(float(value))

                field.setMaximum(sys.maxint)
                field.setMinimum(-sys.maxint)

                field.valueChanged.connect(
                    functools.partial(self.update_on_change, data_dict, field,
                                      name, lambda spin_box: spin_box.value()))

            if type_ == 'enumerator':
                field = QtWidgets.QComboBox()
                for item in option['data']:
                    field.addItem(item['label'])

                field.currentIndexChanged.connect(
                    functools.partial(
                        self.update_on_change, data_dict, field, name,
                        lambda box:
                        (option['data'][box.currentIndex()]['value'])))

            if type_ == 'qt_widget':
                field = option['widget']
                field.value_changed.connect(
                    functools.partial(
                        self.update_on_change, data_dict, field, name,
                        lambda custom_field: (custom_field.value())))

            if field is not None:
                if label:
                    label_widget = QtWidgets.QLabel(label)
                    self.layout().addRow(label_widget, field)
                else:
                    self.layout().addRow(field)
Esempio n. 2
0
    def __init__(self, selection, parent=None):
        ''' Initialise class with *selection* and *parent* widget. '''
        self._result_data = {}

        if not parent:
            parent = hiero.ui.mainWindow()

        super(FtrackReBuildServerTrackDialog, self).__init__(parent)
        self.logger = logging.getLogger(__name__ + '.' +
                                        self.__class__.__name__)

        num_tasks = registry.numTasks()
        self._ftrack_tasks = [
            registry.taskName(index) for index in range(num_tasks)
        ]

        self._selection = selection

        if self._selection:
            self.project = self.item_project(self._selection[0])

        self._window_title = 'Build track from ftrack'
        self.setWindowTitle(self._window_title)
        # self.setWindowIcon(QtGui.QPixmap(':ftrack/image/default/ftrackLogoColor'))

        self.setSizeGripEnabled(True)

        layout = QtWidgets.QVBoxLayout()
        formLayout = QtWidgets.QFormLayout()
        self._tracknameField = QtWidgets.QLineEdit()
        self._tracknameField.setToolTip('Name of new track')
        formLayout.addRow('Track name:', self._tracknameField)

        self.tasks_combobox = QtWidgets.QComboBox()
        formLayout.addRow('Task type:', self.tasks_combobox)

        self.asset_type_combobox = QtWidgets.QComboBox()

        formLayout.addRow('Asset type:', self.asset_type_combobox)

        self.asset_status_combobox = QtWidgets.QComboBox()
        formLayout.addRow('Asset Status:', self.asset_status_combobox)

        self.component_combobox = QtWidgets.QComboBox()
        formLayout.addRow('Component name:', self.component_combobox)

        layout.addLayout(formLayout)

        # Add the standard ok/cancel buttons, default to ok.
        self._buttonbox = QtWidgets.QDialogButtonBox(
            QtWidgets.QDialogButtonBox.StandardButton.Ok
            | QtWidgets.QDialogButtonBox.StandardButton.Cancel)
        self._buttonbox.button(
            QtWidgets.QDialogButtonBox.StandardButton.Ok).setText('Build')
        self._buttonbox.button(
            QtWidgets.QDialogButtonBox.StandardButton.Ok).setDisabled(True)
        self._buttonbox.button(
            QtWidgets.QDialogButtonBox.StandardButton.Ok).setAutoDefault(True)
        self._buttonbox.accepted.connect(self.accept_test)
        self._buttonbox.rejected.connect(self.reject)
        layout.addWidget(self._buttonbox)

        self.setLayout(layout)

        # populate data
        self.populate_tasks()
        self.populate_asset_types()
        self.populate_components()
        self.populate_asset_statuses()

        # connect signals
        self.tasks_combobox.currentIndexChanged.connect(self.get_components)
        self.asset_type_combobox.currentIndexChanged.connect(
            self.get_components)
        self.component_combobox.currentIndexChanged.connect(
            self.get_components)
        self.asset_status_combobox.currentIndexChanged.connect(
            self.get_components)

        # set suggested track name
        self._tracknameField.setText(self.suggested_track_name)

        # force ui to refresh
        self.get_components()
    def populateUI(self, widget, exportTemplate):
        if exportTemplate:

            self._exportTemplate = exportTemplate

            properties = self._preset.properties()

            layout = QtWidgets.QFormLayout()

            self._readList = QtWidgets.QListView()
            self._writeList = QtWidgets.QListView()

            self._readList.setMinimumHeight(50)
            self._writeList.setMinimumHeight(50)
            self._readList.resize(200, 50)
            self._writeList.resize(200, 50)

            self._readModel = QtWidgets.QStandardItemModel()
            self._writeModel = QtWidgets.QStandardItemModel()

            # Default to the empty item unless the preset has a value set.
            for model, presetValue in ((self._readModel,
                                        properties["readPaths"]),
                                       (self._writeModel,
                                        properties["writePaths"])):
                for path, preset in exportTemplate.flatten():

                    if model is self._writeModel:
                        if not hasattr(preset._parentType, 'nukeWriteNode'):
                            continue

                    item = QtWidgets.QStandardItem(path)
                    item.setFlags(QtCore.Qt.ItemIsUserCheckable
                                  | QtCore.Qt.ItemIsEnabled)

                    item.setData(QtCore.Qt.Unchecked, QtCore.Qt.CheckStateRole)
                    if path in presetValue:
                        item.setData(QtCore.Qt.Checked,
                                     QtCore.Qt.CheckStateRole)

                    model.appendRow(item)

            self._readList.setModel(self._readModel)
            self._writeList.setModel(self._writeModel)

            readNodeListToolTip = """Select multiple entries within the shot template to be used as inputs for the read nodes (i.e. symlink, transcode.. etc).\n No selection will mean that read nodes are created in the nuke script pointing directly at the source media.\n"""
            writeNodeListToolTip = """Add one or more "Nuke Write Node" tasks to your export structure to define the path and codec settings for the nuke script.\nIf no write paths are selected, no write node will be added to the nuke script."""

            self._readList.setToolTip(readNodeListToolTip)
            self._writeList.setToolTip(writeNodeListToolTip)
            self._readModel.dataChanged.connect(self.readPresetChanged)

            publishScriptTip = """When enabled, if there is a known shot in the asset that matches the shot in Hiero, the Nuke script will be published there."""
            key, value, label = "publishScript", True, FnAssetAPI.l(
                "{publish} Script")
            uiProperty = UIPropertyFactory.create(
                type(value),
                key=key,
                value=value,
                dictionary=self._preset._properties,
                label=label,
                tooltip=publishScriptTip)
            self._uiProperties.append(uiProperty)
            layout.addRow(uiProperty._label + ":", uiProperty)

            ## @todo Think of a better name
            useAssetsTip = """If enabled, any Clips that point to managed Assets will reference the Asset, rather than their files."""
            key, value, label = "useAssets", True, "Use Assets"
            uiProperty = UIPropertyFactory.create(
                type(value),
                key=key,
                value=value,
                dictionary=self._preset._properties,
                label=label,
                tooltip=useAssetsTip)
            self._uiProperties.append(uiProperty)
            layout.addRow(uiProperty._label + ":", uiProperty)

            layout.addRow("Read Nodes:", self._readList)
            self._writeModel.dataChanged.connect(self.writePresetChanged)
            layout.addRow("Write Nodes:", self._writeList)

            retimeToolTip = """Sets the retime method used if retimes are enabled.\n-Motion - Motion Estimation.\n-Blend - Frame Blending.\n-Frame - Nearest Frame"""
            key, value = "method", ("None", "Motion", "Frame", "Blend")
            uiProperty = UIPropertyFactory.create(
                type(value),
                key=key,
                value=value,
                dictionary=self._preset._properties,
                label="Retime Method",
                tooltip=retimeToolTip)
            self._uiProperties.append(uiProperty)
            layout.addRow(uiProperty._label + ":", uiProperty)

            collateTracksToolTip = """Enable this to include other shots which overlap the sequence time of each shot within the script. Cannot be enabled when Read Node overrides are set."""

            key, value, label = "collateTracks", False, "Collate Shot Timings"
            uiProperty = UIPropertyFactory.create(
                type(value),
                key=key,
                value=value,
                dictionary=self._preset.properties(),
                label=label + ":",
                tooltip=collateTracksToolTip)
            layout.addRow(label + ":", uiProperty)
            self._uiProperties.append(uiProperty)
            self._collateTimeProperty = uiProperty

            collateShotNameToolTip = """Enable this to include other shots which have the same name in the Nuke script. Cannot be enabled when Read Node overrides are set."""
            key, value, label = "collateShotNames", False, "Collate Shot Name"
            uiProperty = UIPropertyFactory.create(
                type(value),
                key=key,
                value=value,
                dictionary=self._preset.properties(),
                label=label + ":",
                tooltip=collateShotNameToolTip)
            layout.addRow(label + ":", uiProperty)
            self._collateNameProperty = uiProperty
            self._uiProperties.append(uiProperty)
            self.readPresetChanged(None, None)

            additionalNodesToolTip = """When enabled, allows custom Nuke nodes to be added into Nuke Scripts.\n Click Edit to add nodes on a per Shot, Track or Sequence basis.\n Additional Nodes can also optionally be filtered by Tag."""

            additionalNodesLayout = QtWidgets.QHBoxLayout()
            additionalNodesCheckbox = QtWidgets.QCheckBox()
            additionalNodesCheckbox.setToolTip(additionalNodesToolTip)
            additionalNodesCheckbox.stateChanged.connect(
                self._additionalNodesEnableClicked)
            if self._preset.properties()["additionalNodesEnabled"]:
                additionalNodesCheckbox.setCheckState(QtCore.Qt.Checked)
            additionalNodesButton = QtWidgets.QPushButton("Edit")
            additionalNodesButton.setToolTip(additionalNodesToolTip)
            additionalNodesButton.clicked.connect(
                self._additionalNodesEditClicked)
            additionalNodesLayout.addWidget(additionalNodesCheckbox)
            additionalNodesLayout.addWidget(additionalNodesButton)
            layout.addRow("Additional Nodes:", additionalNodesLayout)

            widget.setLayout(layout)
Esempio n. 4
0
    def __init__(self, parent=None):
        '''Initiate a publish view.'''
        super(Publisher, self).__init__(parent)

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

        self._entity = None

        layout = QtWidgets.QVBoxLayout()

        self.setLayout(layout)

        self.browser = _data_drop_zone.DataDropZone()
        layout.addWidget(self.browser)
        self.browser.dataSelected.connect(self._onDataSelected)

        # Create a components list widget.
        self.componentsList = _components_list.ComponentsList()
        self.componentsList.setObjectName('publisher-componentlist')
        self.componentsList.itemsChanged.connect(
            self._onComponentListItemsChanged)
        layout.addWidget(self.componentsList, stretch=1)
        self.componentsList.hide()

        # Create form layout to keep track of publish form items.
        formLayout = QtWidgets.QFormLayout()
        layout.addLayout(formLayout, stretch=0)

        # Add entity selector.
        self.entitySelector = EntitySelector()
        formLayout.addRow('Linked to', self.entitySelector)

        # Add asset options.
        self.assetOptions = _asset_options.AssetOptions()
        self.entitySelector.entityChanged.connect(self.assetOptions.setEntity)
        self.assetCreated.connect(self.assetOptions.setAsset)
        formLayout.addRow('Asset', self.assetOptions.radioButtonFrame)
        formLayout.addRow('Existing asset',
                          self.assetOptions.existingAssetSelector)
        formLayout.addRow('Type', self.assetOptions.assetTypeSelector)
        formLayout.addRow('Name', self.assetOptions.assetNameLineEdit)
        self.assetOptions.initializeFieldLabels(formLayout)

        # Add preview selector.
        self.previewSelector = _item_selector.ItemSelector(
            labelField='componentName',
            defaultLabel='Unnamed component',
            emptyLabel='Select component to use')
        formLayout.addRow('Web playable', self.previewSelector)

        self.thumbnailDropZone = _thumbnail_drop_zone.ThumbnailDropZone()
        formLayout.addRow('Thumbnail', self.thumbnailDropZone)

        # Add version description component.
        self.versionDescription = QtWidgets.QTextEdit()
        formLayout.addRow('Description', self.versionDescription)

        publishButton = QtWidgets.QPushButton(text='Publish')
        publishButton.setObjectName('primary')
        publishButton.clicked.connect(self.publish)

        layout.addWidget(publishButton,
                         alignment=QtCore.Qt.AlignCenter,
                         stretch=0)