示例#1
0
    def paint(self, painter, option, index):
        ''' Override the tree widget draw widget function.
        '''
        rect = option.rect

        tree_widget = self.parent()
        model = tree_widget.model()
        item = index.model().itemFromIndex(index)

        line = item.script_line.clean_line
        line_number = item.line_number
        is_title = item.script_line.has_children()
        is_comment = item.script_line.is_comment()

        color_value = self._color_default_value

        if item.script_line.is_comment():
            font = self._font_comment
            color_default = self._color_comment
            highlight_value = False

        elif item.script_line.is_layer_addition():
            font = self._font_default
            color_default = self._color_layer_addition
            highlight_value = False

        elif (item.script_line.stack_pushed() != None
              or item.script_line.stack_set() != None):
            font = self._font_default
            color_default = self._color_stacked_pushed
            color_value = self._color_stacked_pushed_value
            highlight_value = True

        elif item.script_line.has_children():
            font = self._font_has_children
            color_default = self._color_has_children
            highlight_value = True

        else:
            font = self._font_default
            color_default = self._color_default
            highlight_value = True

        font.setPixelSize(tree_widget.font_size)

        # Get the size of the text according to the chosen font
        fm = QtGui.QFontMetrics(font)

        # Separate the line in a list of tuple (text, color) to draw the text
        if item.script_line.has_children(
        ) and not tree_widget.isExpanded(index):
            to_write = [(line + "...}", color_default)]
        else:
            to_write = [(line, color_default)]

        if highlight_value:

            # Try to highlight the name and the value(s) if possible
            tuple_split = item.script_line.clean_line.split(" ", 1)
            if len(tuple_split) > 1:
                if tuple_split[-1].strip() not in ["{", "{...}"]:
                    to_write = [(tuple_split[0], color_default),
                                (tuple_split[-1], color_value)]

        # Set line number indentation
        font_line_number = self._font_default
        font_line_number.setPixelSize(tree_widget.font_size)
        fm_line_number = QtGui.QFontMetrics(font_line_number)

        self.line_numbers_indent = fm_line_number.width(
            str(model.total_line_number))

        # Draw the line number if the option has been set
        painter.setPen(
            QtGui.QPen(self._color_line_number, 1, QtCore.Qt.SolidLine))
        painter.setFont(font_line_number)
        painter.drawText(5, rect.top() + 15, str(item.line_number))
        interval_left = rect.left() + 15 + self.line_numbers_indent

        # Draw the filter if we need one
        if tree_widget.filter != None:
            self._color_selection.setAlpha(70)
            elements = re.findall(tree_widget.filter, line, re.IGNORECASE)
            tmp_line = line
            interval_rect = interval_left
            for element in elements:
                prefix, tmp_line = tmp_line.split(element, 1)
                interval_rect += fm.width(prefix)
                width = fm.width(element)
                rect_selection = QtCore.QRect(interval_rect, rect.y(), width,
                                              rect.height())
                painter.setBrush(self._color_selection)
                painter.setPen(
                    QtGui.QPen(self._color_selection, 2, QtCore.Qt.SolidLine))
                painter.drawRect(rect_selection)
                interval_rect += width

        # Draw the text
        for tuple_to_write in to_write:
            text, color = tuple_to_write
            pen = QtGui.QPen(color, 1, QtCore.Qt.SolidLine)
            painter.setPen(QtGui.QPen(color, 1, QtCore.Qt.SolidLine))
            painter.setFont(font)
            painter.drawText(interval_left, rect.top() + 15, text)
            interval_left += fm.width(text) + 5
    def setupUI(self):
        super(ScriptPublisherDialog, self).setupUI()

        self.resize(1226, 790)
        self.setMinimumWidth(1226)
        self.setMinimumHeight(790)

        # self.tasks_frame.setStyleSheet("background-color:grey;")

        # HEADER

        self.asset_conn_container = QtGui.QWidget(self.main_container)
        self.asset_conn_container_layout = QtGui.QHBoxLayout()
        self.asset_conn_container.setLayout(self.asset_conn_container_layout)
        # self.main_container_layout.addWidget(self.asset_conn_container)

        self.asset_conn_label = QtGui.QLabel('Type', self.main_container)
        self.asset_conn_label.setMinimumWidth(60)

        self.asset_conn_combo = QtGui.QComboBox(self.main_container)
        self.asset_conn_combo.setMinimumHeight(23)
        self.asset_conn_combo.addItems(self._connectors_per_type.keys())

        spacer_asset_type = QtGui.QSpacerItem(0, 0,
                                              QtGui.QSizePolicy.Expanding,
                                              QtGui.QSizePolicy.Minimum)

        self.asset_conn_container_layout.addWidget(self.asset_conn_label)
        self.asset_conn_container_layout.addWidget(self.asset_conn_combo)
        self.asset_conn_container_layout.addItem(spacer_asset_type)

        self.tasks_main_container_layout.addWidget(self.asset_conn_container)

        # Create "main content" for the publisher
        self.publish_container = QtGui.QWidget(self.main_container)
        self.publish_container.setSizePolicy(
            QtGui.QSizePolicy.Expanding,
            QtGui.QSizePolicy.Expanding,
        )
        self.publish_container_layout = QtGui.QHBoxLayout()
        self.publish_container_layout.setContentsMargins(0, 0, 0, 0)
        self.publish_container.setLayout(self.publish_container_layout)

        self.main_container_layout.addWidget(self.publish_container)

        # Create "main content" splitter for the publisher
        self.publish_splitter = QtGui.QSplitter(self.publish_container)
        self.publish_splitter.setContentsMargins(0, 0, 0, 0)
        self.publish_splitter.setChildrenCollapsible(False)

        self.publish_container_layout.addWidget(self.publish_splitter)
        self.publish_container_layout.setContentsMargins(0, 0, 0, 0)

        # Create left and right containers for the splitter
        self.publish_left_container = QtGui.QWidget(self.publish_splitter)
        self.publish_right_container = QtGui.QWidget(self.publish_splitter)

        self.publish_left_container_layout = QtGui.QVBoxLayout()
        self.publish_right_container_layout = QtGui.QVBoxLayout()
        self.publish_right_container_layout.setContentsMargins(5, 0, 0, 0)

        self.publish_left_container.setLayout(
            self.publish_left_container_layout)
        self.publish_right_container.setLayout(
            self.publish_right_container_layout)

        # Left Splitter Container
        self.publish_left_container_layout.setContentsMargins(0, 0, 5, 0)

        self.left_tasks_widget = TaskWidget(self.publish_left_container)
        self.left_tasks_widget.set_read_only(False)
        self.left_tasks_widget.set_selection_mode(False)
        self.publish_left_container_layout.addWidget(self.left_tasks_widget)

        # Right Splitter Containers
        css_asset_version = "color: #de8888; font-weight: bold;"

        self.right_top_container = QtGui.QFrame(self.publish_right_container)
        self.right_mid_container = QtGui.QFrame(self.publish_right_container)
        self.right_bot_container = QtGui.QFrame(self.publish_right_container)

        self.right_top_container_layout = QtGui.QHBoxLayout()
        self.right_mid_container_layout = QtGui.QHBoxLayout()
        self.right_bot_container_layout = QtGui.QHBoxLayout()

        self.right_top_container.setLayout(self.right_top_container_layout)
        self.right_mid_container.setLayout(self.right_mid_container_layout)
        self.right_bot_container.setLayout(self.right_bot_container_layout)

        self.publish_right_container_layout.addWidget(self.right_top_container)
        self.publish_right_container_layout.addWidget(self.right_mid_container)
        self.publish_right_container_layout.addWidget(self.right_bot_container)

        # Right Splitter TOP Container
        asset_title_label = QtGui.QLabel('Asset', self.right_top_container)
        self._asset_name = QtGui.QLabel('Loading...', self.right_top_container)
        asset_spacer = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Expanding,
                                         QtGui.QSizePolicy.Minimum)
        version_title_label = QtGui.QLabel('Version', self.right_top_container)
        self._asset_version = QtGui.QLabel('Loading...',
                                           self.right_top_container)

        self._asset_version.setStyleSheet(css_asset_version)

        self.right_top_container_layout.addWidget(asset_title_label)
        self.right_top_container_layout.addWidget(self._asset_name)
        self.right_top_container_layout.addItem(asset_spacer)
        self.right_top_container_layout.addWidget(version_title_label)
        self.right_top_container_layout.addWidget(self._asset_version)

        # Right Splitter MID Container
        self._snapshotWidget = SnapshotsWidget(self.right_mid_container)
        self.right_mid_container_layout.addWidget(self._snapshotWidget)

        # Right Splitter BOT Container
        self._comment_widget = CommentWidget(self.right_bot_container)
        self.right_bot_container_layout.addWidget(self._comment_widget)

        self._save_btn.setText("Publish and Save script")
        self._save_btn.clicked.disconnect()

        self.modify_layouts(self.asset_conn_container,
                            spacing=0,
                            margin=(0, 0, 0, 0),
                            alignment=QtCore.Qt.AlignTop)

        self.append_css(self.global_css)
        self.set_css(self.main_container)
        self._connect_script_signals()
示例#3
0
    def __init__(self, parent=None):
        super(ScriptEditorItemDelegate, self).__init__(parent)
        self.line_numbers_indent = 0

        # Fonts
        self._font_default = QtGui.QFont()
        self._font_default.setWeight(QtGui.QFont.Normal)
        self._font_comment = QtGui.QFont()
        self._font_comment.setWeight(QtGui.QFont.Expanded)
        self._font_has_children = QtGui.QFont()
        self._font_has_children.setWeight(QtGui.QFont.DemiBold)

        # Colors
        self._color_default = QtGui.QColor(210, 210, 210)
        self._color_default_value = QtGui.QColor(255, 167, 21)
        self._color_comment = QtGui.QColor(30, 30, 30)
        self._color_layer_addition = QtGui.QColor(217, 60, 60)
        self._color_stacked_pushed = QtGui.QColor(210, 210, 210)
        self._color_stacked_pushed_value = QtGui.QColor(83, 129, 198)
        self._color_has_children = QtGui.QColor(230, 230, 230)
        self._color_line_number = QtGui.QColor(40, 40, 40)
        self._color_selection = QtGui.QColor(255, 230, 183)
    def setupUI(self):
        css_asset_global = """
        QFrame { padding: 3px;
                 background: #222; color: #FFF; font-size: 13px; }
        QLabel { padding: 0px; background: none; }
        """
        self._css_lbl = "color: #AAA;"
        css_asset_name = "color: #c3cfa4; font-weight: bold;"
        css_asset_version = "color: #de8888; font-weight: bold;"
        css_comment = """
        color: #f0f0f0; background: #444; padding: 3px ; border-radius: 2px;
        """
        self._css_value = "color: #FFF; text-decoration: none;"

        self.setMinimumWidth(700)

        asset_frame_layout = QtGui.QVBoxLayout(self)
        asset_frame_layout.setContentsMargins(0, 0, 0, 0)
        asset_frame_layout.setSpacing(10)

        asset_main_frame = QtGui.QFrame(self)
        asset_main_frame.setStyleSheet(css_asset_global)
        asset_main_frame_layout = QtGui.QHBoxLayout(asset_main_frame)
        asset_main_frame_layout.setSpacing(10)
        asset_name_lbl = QtGui.QLabel("Asset", asset_main_frame)
        self._asset_name = QtGui.QLabel("...", asset_main_frame)
        self._asset_name.setStyleSheet(css_asset_name)
        spacer_asset = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Expanding,
                                         QtGui.QSizePolicy.Minimum)

        asset_version_lbl = QtGui.QLabel("Version", asset_main_frame)
        self._asset_version = QtGui.QLabel("...", asset_main_frame)
        self._asset_version.setStyleSheet(css_asset_version)
        asset_main_frame_layout.addWidget(asset_name_lbl)
        asset_main_frame_layout.addWidget(self._asset_name)
        asset_main_frame_layout.addItem(spacer_asset)
        asset_main_frame_layout.addWidget(asset_version_lbl)
        asset_main_frame_layout.addWidget(self._asset_version)
        asset_frame_layout.addWidget(asset_main_frame)

        overview_layout = QtGui.QHBoxLayout()
        overview_layout.setContentsMargins(0, 0, 0, 0)
        overview_layout.setSpacing(10)

        self._thumbnail_widget = ThumbnailWidget(self)
        overview_layout.addWidget(self._thumbnail_widget)

        self._infos_layout = QtGui.QFormLayout()
        self._infos_layout.setContentsMargins(0, 0, 0, 0)
        self._infos_layout.setSpacing(10)

        asset_type_lbl = QtGui.QLabel("Asset type", self)
        asset_type_lbl.setStyleSheet(self._css_lbl)
        self._asset_type = QtGui.QLabel(self)
        self.set_asset_type("...")
        status_lbl = QtGui.QLabel("Status", self)
        status_lbl.setStyleSheet(self._css_lbl)
        self._status = StatusWidget(ftrack.getTaskStatuses(), self)
        self._status.set_read_only(True)

        publish_lbl = QtGui.QLabel("Published by", self)
        publish_lbl.setStyleSheet(self._css_lbl)
        self._owner = QtGui.QLabel("...", self)
        self._owner.setTextFormat(QtCore.Qt.RichText)
        self._owner.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)
        self._owner.setOpenExternalLinks(True)
        date_lbl = QtGui.QLabel("on", self)
        date_lbl.setStyleSheet(self._css_lbl)
        self._date = QtGui.QLabel(self)
        self._date.setStyleSheet(self._css_value)

        self._editor = None
        self._date_edit = None

        availability_lbl = QtGui.QLabel("Availability", self)
        availability_lbl.setStyleSheet(self._css_lbl)
        self._availability = QtGui.QLabel(self)
        self._availability.setStyleSheet(self._css_value)
        comment_lbl = QtGui.QLabel("Comment", self)
        comment_lbl.setStyleSheet(self._css_lbl)
        self._comment = QtGui.QLabel("...", self)
        self._comment.setWordWrap(True)
        self._comment.setStyleSheet(css_comment)

        self._infos_layout.setWidget(0, QtGui.QFormLayout.LabelRole,
                                     asset_type_lbl)
        self._infos_layout.setWidget(0, QtGui.QFormLayout.FieldRole,
                                     self._asset_type)
        self._infos_layout.setWidget(1, QtGui.QFormLayout.LabelRole,
                                     status_lbl)
        self._infos_layout.setWidget(1, QtGui.QFormLayout.FieldRole,
                                     self._status)
        self._infos_layout.setWidget(2, QtGui.QFormLayout.LabelRole,
                                     publish_lbl)
        self._infos_layout.setWidget(2, QtGui.QFormLayout.FieldRole,
                                     self._owner)
        self._infos_layout.setWidget(3, QtGui.QFormLayout.LabelRole, date_lbl)
        self._infos_layout.setWidget(3, QtGui.QFormLayout.FieldRole,
                                     self._date)
        self._infos_layout.setWidget(4, QtGui.QFormLayout.LabelRole,
                                     availability_lbl)
        self._infos_layout.setWidget(4, QtGui.QFormLayout.FieldRole,
                                     self._availability)
        self._infos_layout.setWidget(5, QtGui.QFormLayout.LabelRole,
                                     comment_lbl)
        self._infos_layout.setWidget(5, QtGui.QFormLayout.FieldRole,
                                     self._comment)
        overview_layout.addItem(self._infos_layout)

        spacer_overview = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Expanding,
                                            QtGui.QSizePolicy.Minimum)
        overview_layout.addItem(spacer_overview)
        asset_frame_layout.addItem(overview_layout)

        self._tab_widget = QtGui.QTabWidget(self)
        css_tab = """
        /*
        QTabWidget::pane { border-top: 2px solid #151515; top: -2px;
                           border-top-left-radius: 0px;
                           border-top-right-radius: 0px;
                           background: #282828; }
        QTabBar::tab { padding: 6px 10px; background: #151515;
                       border-top: 2px solid #151515;
                       border-right: 2px solid #151515;
                       border-left: 2px solid #151515;
                       border-radius: 0px; }
        QTabBar::tab:selected { background: #333;
                                border-top-left-radius: 4px;
                                border-top-right-radius: 4px; }
        QTabBar::tab:hover { background: #222; }
        QTabBar::tab:!selected { margin-top: 2px; }
        */
        """
        self._tab_widget.setStyleSheet(css_tab)

        # Display asset history

        tab_asset_history = QtGui.QWidget()
        tab_asset_history_layout = QtGui.QVBoxLayout(tab_asset_history)
        tab_asset_history_layout.setContentsMargins(0, 8, 0, 0)
        self._graph_widget = StatisticWidget(self.scene_version, self)
        tab_asset_history_layout.addWidget(self._graph_widget)
        self._tab_widget.addTab(tab_asset_history, "Asset history")

        asset_frame_layout.addWidget(self._tab_widget)

        spacer_global = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Minimum,
                                          QtGui.QSizePolicy.Expanding)
        asset_frame_layout.addItem(spacer_global)
    def _buildClipsTab(self):

        l = FnAssetAPI.l

        imageSpecification = ImageSpecification()

        # > Media Ta

        mediaWidget = QtGui.QWidget()
        mediaWidget.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                  QtGui.QSizePolicy.Expanding)
        mediaWidgetLayout = QtGui.QVBoxLayout()
        mediaWidgetLayout.setAlignment(QtCore.Qt.AlignLeft
                                       | QtCore.Qt.AlignTop)
        mediaWidget.setLayout(mediaWidgetLayout)

        # - Shared Media

        self._sharedClipsGroup = QtGui.QGroupBox(
            l("Some Source Clips are Shared " +
              "and used in more than one Shot in the Edit"))
        mediaWidgetLayout.addWidget(self._sharedClipsGroup)
        sharedClipsGroupLayout = QtGui.QVBoxLayout()
        self._sharedClipsGroup.setLayout(sharedClipsGroupLayout)

        self._sharedIgnoredRadio = QtGui.QRadioButton(l("Don't {publish}"))
        self._sharedToSequenceRadio = QtGui.QRadioButton(
            l("{publish} at the level above the Shots"))
        self._sharedToCustomRadio = QtGui.QRadioButton(
            l("{publish} to another location"))
        self._sharedIgnoredRadio.setChecked(True)
        sharedClipsGroupLayout.addWidget(self._sharedIgnoredRadio)
        sharedClipsGroupLayout.addWidget(self._sharedToSequenceRadio)
        sharedClipsGroupLayout.addWidget(self._sharedToCustomRadio)

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

        pickerCls = self._session.getManagerWidget(
            FnAssetAPI.ui.constants.kInlinePickerWidgetId, instantiate=False)

        self._sharedClipParentPicker = pickerCls(imageSpecification,
                                                 self._context)
        self._sharedClipParentPicker.setVisible(False)
        sharedClipsGroupLayout.addWidget(self._sharedClipParentPicker)

        self._previewWidget = PublishShotClipsSummaryWidget()
        self._previewWidget.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                          QtGui.QSizePolicy.Expanding)
        mediaWidgetLayout.addWidget(self._previewWidget)

        # - Options

        self._clipOptionsGroup = QtGui.QGroupBox(l("Options"))
        optionsGroupLayout = QtGui.QVBoxLayout()
        self._clipOptionsGroup.setLayout(optionsGroupLayout)
        mediaWidgetLayout.addWidget(self._clipOptionsGroup)

        # See if we have any options from the manager
        self._managerOptionsClip = self._session.getManagerWidget(
            FnAssetAPI.ui.constants.kRegistrationManagerOptionsWidgetId,
            throw=False,
            args=(imageSpecification, self._context))

        if self._managerOptionsClip:
            optionsGroupLayout.addWidget(self._managerOptionsClip)
            optionsGroupLayout.addSpacing(10)

        hieroOptionsGrid = QtGui.QGridLayout()

        ## @todo we should have some base widget for this

        hieroOptionsGrid.addWidget(QtGui.QLabel(l("{asset} name:")), 0, 0)

        self._clipNameCombo = QtGui.QComboBox()
        self._clipNameCombo.addItems(("Clip Name", "Custom"))
        hieroOptionsGrid.addWidget(self._clipNameCombo, 0, 1)

        self._clipNameCustomField = QtGui.QLineEdit()
        hieroOptionsGrid.addWidget(self._clipNameCustomField, 0, 2)

        self._replaceClipSource = QtGui.QCheckBox(
            l("Link Source Clips to " + "{published} {assets}"))
        hieroOptionsGrid.addWidget(self._replaceClipSource, 1, 1, 1, 2)

        self._ignorePublishedClips = QtGui.QCheckBox(
            l("Ignore Source Clips that are " + "already {published}"))
        hieroOptionsGrid.addWidget(self._ignorePublishedClips, 2, 1, 1, 2)

        # Make sure we don't stretch the grid layout too much and make the last
        #column really wide
        hieroOptionsHBox = QtGui.QHBoxLayout()
        optionsGroupLayout.addLayout(hieroOptionsHBox)
        hieroOptionsHBox.addLayout(hieroOptionsGrid)
        hieroOptionsHBox.addStretch()

        return mediaWidget
示例#6
0
    def _publish(self):
        asset_name = self.asset_name
        comment = self.comment
        file_path = self.gizmo_path

        # new api
        task = self.session.get('Task', self.current_task.getId())
        parent_task = task['parent']

        try:

            asset_type = self.session.query(
                'AssetType where short is "nuke_gizmo"'
            ).one()

        except ftrack_api.exception.NoResultFoundError:

            message_box = QtGui.QMessageBox()

            message_box.setText(
                'Missing required Asset Type "Gizmo" with short name "nuke_gizmo"'
            )

            message_box.setDetailedText(
                'In order to publish gizmos the Asset Type "Gizmo" with the short '
                'name "nuke_gizmo" must be created from the ftrack system settings.'
            )
            message_box.setIcon(
                QtGui.QMessageBox.Critical
            )

            return message_box.exec_()

        asset = self.session.query(
            u'select parent, name , type.short from'
            u' Asset where parent.id is "{0}"'
            u' and name is "{1}"'
            u' and type.short is "{2}"'.format(
                parent_task['id'],
                asset_name,
                asset_type['short']
            )
        ).first()

        if not asset:
            asset = self.session.create('Asset', {
                'parent': parent_task,
                'name': asset_name,
                'type': asset_type
            })

        version = self.session.create('AssetVersion', {
            'comment': comment,
            'asset': asset,
            'task': task
        })

        # Commit version so component can be added.
        self.session.commit()

        location = self.session.pick_location()

        version.create_component(
            file_path,
            {'name': 'gizmo'},
            location=location
        )

        self.session.commit()

        message = u'Asset {0} correctly published'.format(asset['name'])
        self.header.setMessage(message, 'info')
 def sizeHint(self, option, index):
     tree_widget = self.parent()
     font = self._font_has_children
     font.setPixelSize(tree_widget.font_size)
     fm = QtGui.QFontMetrics(font)
     return QtCore.QSize(200, fm.height() + 5)
示例#8
0
    def __init__(self, parent, minimum_width=200, show_thumbnail=True):
        super(TreeDelegateStyle, self).__init__(parent)

        self._view = parent
        self._minimum_width = minimum_width
        self._show_thumbnail = show_thumbnail

        self._thumnbail_default = QtGui.QImage()
        default_thumb = os.environ["FTRACK_SERVER"] + "/img/thumbnail2.png"
        self._thumnbail_default.loadFromData(
            urllib.urlopen(default_thumb).read())

        # Fonts...
        self._font_name = QtGui.QFont()
        self._font_name.setPixelSize(12)
        self._font_name.setWeight(QtGui.QFont.Bold)
        self._fm_name = QtGui.QFontMetrics(self._font_name)

        self._font_desc = QtGui.QFont()
        self._font_desc.setPixelSize(11)
        self._font_desc.setWeight(QtGui.QFont.Normal)
        self._fm_desc = QtGui.QFontMetrics(self._font_desc)

        # Sizes...
        self._thumnbail_size = QtCore.QSize(150, 100)
        self._thumnbail_child_size = QtCore.QSize(96, 64)

        self._type_indicator_width = 12

        # Colors...
        self._background = QtGui.QColor(68, 68, 68)
        self._background_regenerated = QtGui.QColor(20, 20, 20)

        self._background_comment = QtGui.QColor(58, 58, 58)

        self._name_color = QtGui.QColor(195, 207, 164)
        self._desc_color = QtGui.QColor(240, 240, 240)
        self._owner_color = QtGui.QColor(200, 200, 200)
        self._comment_color = QtGui.QColor(240, 240, 240)

        self._btn_color = QtGui.QColor(255, 255, 255, 80)
        self._btn_color_hover = QtGui.QColor(255, 255, 255, 200)
        self._btn_color_pressed = QtGui.QColor(255, 255, 255, 255)

        # Flags...
        self._comment_flags = QtCore.Qt.TextWordWrap | QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop

        # Paddings...
        self._padding_item = dict(left=3, top=3, right=3, bottom=0)
        self._padding_content = dict(left=5, top=5, right=5, bottom=10)
        self._padding_comment = 5
        self._inter_text = 5
        self._inter_item = 3
        self._space_before_btn = 8

        # method...
        self._width = self._minimum_width

        # Keep the QRect of the "show previous versions" button if necessary
        self._button_rect = None

        # Keep the QRect of the "date" to show the real date in hover mode
        self._date_rect = None

        # Hover state
        self._hover_state = dict(no_hover=0,
                                 btn_hover=1,
                                 btn_pressed=2,
                                 date_hover=3)

        # Keep in memory the index under the mouse
        self._current_index = None
示例#9
0
    def paint(self, painter, option, index):
        painter.setRenderHints(QtGui.QPainter.Antialiasing
                               | QtGui.QPainter.TextAntialiasing)
        padding_left = option.rect.left(
        ) + self._padding_item["left"] + self._padding_content["left"]
        padding_right = self._padding_item["right"] + self._padding_content[
            "right"]
        padding_top = option.rect.top() + self._padding_item["top"]

        is_btn = index.data(TreeItem.is_button_role)

        if is_btn:
            text_btn = "show more versions..."

            padding_top += self._fm_desc.height()

            padding_left_btn = option.rect.width() - option.rect.width() * 0.5
            padding_left_btn -= self._fm_desc.width(text_btn) * 0.5

            self._button_rect = QtCore.QRect(option.rect.left(), 0,
                                             option.rect.width(),
                                             option.rect.height())

            self.draw_button(painter, text_btn, padding_left_btn, padding_top,
                             index)

        else:
            asset_type = index.data(TreeItem.asset_type_role)

            name = index.data(TreeItem.name_role)
            version_nb = index.data(TreeItem.version_nb_role)
            publisher = index.data(TreeItem.publisher_role)
            date = index.data(TreeItem.date_role)
            is_edited = index.data(TreeItem.is_edited_role)
            comment = index.data(TreeItem.comment_role)
            locked = index.data(TreeItem.is_locked_role)
            thumbnail = index.data(TreeItem.thumbnail_role)

            locations = index.data(TreeItem.location_role)
            available = index.data(TreeItem.is_available_role)

            main_color = QtGui.QColor()
            main_color.setNamedColor('#333')
            legend_color = QtGui.QColor()
            legend_color.setNamedColor(self._view.asset_color(asset_type))

            # Get status
            if self._is_top_asset_version(index):
                if available is None:
                    background = self._background_regenerated
                elif available:
                    background = self._background
                else:
                    background = self._background_not_available
                background_comment = self._background_comment
                size_thumbnail = self._thumnbail_size

            else:
                if available is None:
                    background = self._background_regenerated
                elif available:
                    background = self._background.lighter(111)
                else:
                    background = self._background_child_not_available
                background_comment = self._background_comment.lighter(111)
                size_thumbnail = self._thumnbail_child_size

            background_comment = main_color
            background = QtGui.QColor()
            background.setNamedColor('#222')
            # Draw background
            if option.state & QtGui.QStyle.State_Selected:
                painter.setPen(
                    QtGui.QPen(QtCore.Qt.lightGray, 2, QtCore.Qt.SolidLine))
            else:
                painter.setPen(QtGui.QPen(background, 0, QtCore.Qt.SolidLine))
            painter.setBrush(background)

            adjusted_rect = option.rect.adjusted(
                self._padding_item["left"], self._padding_item["top"],
                -self._padding_item["right"],
                -self._padding_item["top"] - self._padding_item["bottom"])
            painter.drawRoundedRect(adjusted_rect, 3, 3)

            # Draw type
            type_indicator_rect = QtCore.QRect(adjusted_rect.left() + 3,
                                               adjusted_rect.top() + 3,
                                               self._type_indicator_width - 6,
                                               adjusted_rect.height() - 6)

            painter.setPen(QtGui.QPen(legend_color, 0, QtCore.Qt.SolidLine))
            painter.setBrush(legend_color)

            # painter.drawRoundedRect(type_indicator_rect, 3, 3)

            padding_left += self._type_indicator_width
            padding_top += self._padding_content["top"]

            # Draw thumbnail if necessary
            if self._show_thumbnail:
                if thumbnail is None:
                    pixmap = QtGui.QImage(self._thumnbail_default)
                else:
                    pixmap = QtGui.QImage(thumbnail)

                pixmap_scaled = pixmap.scaled(size_thumbnail,
                                              QtCore.Qt.KeepAspectRatio)

                thumbnail_rect = QtCore.QRect(padding_left, padding_top,
                                              pixmap_scaled.width(),
                                              pixmap_scaled.height())

                painter.setPen(
                    QtGui.QPen(self._background.darker(190), 0.5,
                               QtCore.Qt.SolidLine))
                painter.setBrushOrigin(padding_left, padding_top)
                painter.setBrush(pixmap_scaled)
                painter.drawRoundedRect(thumbnail_rect, 3, 3)

                # If it's a top asset, we draw the legend
                if self._is_top_asset_version(index):
                    padding_top_rect = padding_top + thumbnail_rect.height(
                    ) - self._fm_desc.height()
                    type_rect = QtCore.QRect(
                        padding_left, padding_top_rect - 6,
                        self._fm_desc.width(asset_type) + 10,
                        self._fm_desc.height() + 6)

                    painter.setBrush(legend_color)
                    painter.drawRoundedRect(type_rect, 3, 3)

                    if legend_color.lightness() < 127.5:
                        legend_text_color = legend_color.lighter(190)
                    else:
                        legend_text_color = legend_color.darker(190)

                    painter.setPen(
                        QtGui.QPen(legend_text_color, 0, QtCore.Qt.SolidLine))

                    padding_top_legend = padding_top + thumbnail_rect.height(
                    ) - 6
                    painter.drawText(padding_left + 2, padding_top_legend,
                                     asset_type)

                padding_left += size_thumbnail.width() + 10

            # Draw version number
            if self._is_top_asset_version(index):
                color_number = self._name_color
            else:
                color_number = self._name_color.darker(130)

            painter.setPen(QtGui.QPen(color_number, 1, QtCore.Qt.SolidLine))
            painter.setFont(self._font_name)

            version_nb_str = "v%02d" % version_nb
            painter.drawText(
                option.rect.right() - padding_right -
                self._fm_name.width(version_nb_str),
                padding_top + self._fm_name.height(), version_nb_str)

            # Draw name asset if necessary
            if self._is_top_asset_version(index):
                padding_top += self._fm_name.height()
                painter.drawText(padding_left, padding_top, name)
                padding_top += self._inter_text

            # If publisher is None, that means that the asset is being
            # regenerated
            if publisher != None:

                # Draw publisher
                painter.setPen(
                    QtGui.QPen(self._desc_color, 1, QtCore.Qt.SolidLine))
                painter.setFont(self._font_desc)

                label = "published by " if not is_edited else "edited by "
                padding_top += self._fm_desc.height()
                painter.drawText(padding_left, padding_top,
                                 label + publisher.getName())

                # Draw Date
                painter.setPen(
                    QtGui.QPen(self._owner_color, 1, QtCore.Qt.SolidLine))

                padding_top += self._fm_desc.height() + self._inter_text

                self.draw_date(painter, date, padding_left, padding_top, index)

                self._date_rect = QtCore.QRect(
                    padding_left,
                    padding_top - self._fm_desc.height() - option.rect.top(),
                    option.rect.width() - padding_left - 10,
                    self._fm_desc.height() + 10)

                # # Draw Location if necessary
                # if not available:
                #     locations_info = "Locations: "
                #     if len(locations) > 0:
                #       locations_info += ", ".join(locations)
                #     else:
                #       locations_info += "Hmmm... nowhere?"
                #     painter.setPen(
                #         QtGui.QPen(QtCore.Qt.red, 1, QtCore.Qt.SolidLine))

                #     padding_top += self._fm_desc.height() + self._inter_text
                #     painter.drawText(padding_left, padding_top, locations_info)

                # Draw comment
                painter.setPen(
                    QtGui.QPen(background_comment, 0, QtCore.Qt.SolidLine))
                painter.setBrush(background_comment)

                padding_top += self._inter_text * 2

                r_comment, r_comment_text = self._bounding_boxes(
                    comment, option.rect.width(), padding_left, padding_top)

                painter.drawRoundedRect(r_comment, 3, 3)
                painter.setPen(
                    QtGui.QPen(self._comment_color, 1, QtCore.Qt.SolidLine))
                painter.drawText(r_comment_text, self._comment_flags, comment)

            else:

                # Draw loading asset...
                painter.setPen(
                    QtGui.QPen(self._desc_color, 1, QtCore.Qt.SolidLine))
                painter.setFont(self._font_desc)

                padding_top += self._fm_desc.height()
                painter.drawText(padding_left, padding_top, "Loading...")

        # Get the width to update the sizeHint
        self._width = option.rect.width()
示例#10
0
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)
示例#11
0
    def paintEvent(self, event):
        painter = QtGui.QPainter(self)
        painter.setRenderHint(QtGui.QPainter.Antialiasing)

        # Design the graph
        width_graph = self.width() - (self._pad_left + self._pad_right)
        height_graph = self.height() - (self._pad_top + self._pad_bottom)

        rect = QtCore.QRect(
            self._pad_left, self._pad_top, width_graph, height_graph)
        painter.fillRect(self.rect(), self._color_back_2)
        painter.fillRect(rect, self._color_back_1)

        # Sort graphs to draw the highlighted one at the end
        unhighlight_graphs = [
            p for p in self._points.keys() if p != self._highlight_graph]
        all_graphs_type = unhighlight_graphs + [self._highlight_graph]

        # Collect the axis values to draw it at the end...
        pts_legend_Y = dict()
        pts_legend_X = dict()

        versions = range(self._version_number)
        width_interval = 1 if len(
            versions) == 1 else 1 / float(len(versions) - 1)
        for i in versions:
            pts_legend_X[i] = self._pad_left + width_graph * i * width_interval

        # collect the highlighted point to get the tool-tips..
        points_h = dict()

        # Get the highlighted point
        hover_point = None

        # Draw each graph...
        for type_graph in all_graphs_type:
            if self._points[type_graph] == None:
                continue

            points_tuples = []
            highlighted = type_graph == self._highlight_graph
            for i in sorted(pts_legend_X.keys(), reverse=True):
                hover = False

                try:
                    graph_point = self._points[type_graph][i]

                except IndexError:
                    pass

                else:
                    padding = self._pad_top + height_graph
                    relative_position = height_graph * self.raise_level * 0.1
                    ypos = padding - relative_position * \
                        graph_point.normalized_value

                    pt = (pts_legend_X[i], ypos)
                    points_tuples.append(pt)

                    pts_legend_Y[graph_point.value] = ypos

                    if highlighted:
                        points_h[pt] = graph_point

                        if self._cursor != None and hover_point == None:
                            inter_points = width_interval * width_graph * 0.5
                            if (self._cursor[0] > pts_legend_X[i] - inter_points
                                    and self._cursor[0] < pts_legend_X[i] + inter_points):
                                hover_point = (pts_legend_X[i], ypos)
                                hover = True

                # Draw vertical lines of the graph (and horizontal if
                # necessary)
                color = self._color_dot_lines_hover if hover else self._color_dot_lines
                painter.setPen(
                    QtGui.QPen(QtGui.QColor(color), 1, QtCore.Qt.DotLine))
                line_tuples = [(pts_legend_X[i], self._pad_top),
                               (pts_legend_X[i], self.height() - self._pad_bottom)]
                line_polys = QtGui.QPolygonF(
                    map(lambda p: QtCore.QPointF(*p), line_tuples))
                painter.drawPolyline(line_polys)

                if hover:
                    line_H = [(self._pad_left, hover_point[1]),
                              (self._pad_left + width_graph, hover_point[1])]
                    line_H_polys = QtGui.QPolygonF(
                        map(lambda p: QtCore.QPointF(*p), line_H))
                    painter.drawPolyline(line_H_polys)

            # Draw the lines of the graph
            width_line = 3 if highlighted else 2
            color = self._points_colors[
                type_graph] if highlighted else self._points_colors[type_graph].darker(110)
            painter.setPen(QtGui.QPen(QtGui.QColor(color), width_line))
            points_polys = QtGui.QPolygonF(
                map(lambda p: QtCore.QPointF(*p), points_tuples))
            painter.drawPolyline(points_polys)

            # Draw points
            for point_tuple in points_tuples:
                painter.drawEllipse(
                    QtCore.QRectF(point_tuple[0] - 2, point_tuple[1] - 2, 4, 4))

        # Draw highlighted graph points...
        if hover_point != None and self._highlight_graph in self._points_colors.keys():
            x_pos, y_pos = hover_point
            color = self._points_colors[self._highlight_graph].lighter(160)
            painter.setBrush(QtGui.QBrush(color))
            painter.setPen(QtGui.QPen(QtGui.QColor(QtCore.Qt.black), 1))
            painter.drawEllipse(QtCore.QRectF(x_pos - 5, y_pos - 5, 10, 10))

        painter.setPen(QtGui.QPen(QtGui.QColor(self._color_axis_text), 2))

        # Draw X Axis
        buf_X = 0
        for version_nb in sorted(pts_legend_X.keys(), reverse=True):
            version_str = "v%d" % (version_nb + 1)
            version_position_X = pts_legend_X[
                version_nb] - len(version_str) * 5
            if buf_X == 0 or buf_X - version_position_X > 40:
                pt_legend_X = QtCore.QPointF(version_position_X,
                                             self._pad_top + height_graph + 15)
                painter.drawText(pt_legend_X, version_str)
                buf_X = version_position_X

        # Draw Y Axis
        buf_Y = 0
        for value_Y in sorted(pts_legend_Y.keys(), reverse=True):
            if buf_Y == 0 or pts_legend_Y[value_Y] - buf_Y > 15:
                value_str = str(value_Y)
                pt_legend_Y = QtCore.QPointF(self._pad_left - len(value_str) * 15,
                                             pts_legend_Y[value_Y] + 10)
                bounding_rect = QtCore.QRect(0, pts_legend_Y[value_Y] - 4,
                                             self._pad_left - 15, pts_legend_Y[value_Y] + 10)
                painter.drawText(
                    bounding_rect, QtCore.Qt.AlignRight, value_str)
                buf_Y = pts_legend_Y[value_Y]

        if hover_point != None:
            td = QtGui.QTextDocument()
            td.setHtml(points_h[hover_point].tooltip)
            width_tooltip = 180
            td.setTextWidth(width_tooltip)
            height_tooltip = td.size().height()

            pos_topleft = QtCore.QPoint(
                self._cursor[0] + 5, self._cursor[1] + 5)
            if pos_topleft.x() + width_tooltip > self.width() - self._pad_right - 10:
                pos_topleft.setX(
                    self.width() - self._pad_right - width_tooltip - 10)
            if pos_topleft.y() + height_tooltip > self.height() - self._pad_bottom - 10:
                pos_topleft.setY(
                    self.height() - self._pad_bottom - height_tooltip - 10)

            painter.setOpacity(0.6)
            rect = QtCore.QRect(pos_topleft.x(), pos_topleft.y(),
                                width_tooltip + 20, height_tooltip + 20)
            painter.fillRect(rect, self._color_tooltip)

            painter.setOpacity(1.0)
            painter.translate(pos_topleft.x() + 10, pos_topleft.y() + 10)
            ctx = QtGui.QAbstractTextDocumentLayout.PaintContext()
            ctx.clip = QtCore.QRect(0, 0, width_tooltip, height_tooltip)
            td.documentLayout().draw(painter, ctx)

        # Place the buttons
        pad_left = 5
        pos_bottom = self.height() - 25
        for button_name in ["tracked", "in_tree", "enabled", "total"]:
            if self._buttons[button_name] != None:
                width_btn = self._buttons[button_name].width()
                self._buttons[button_name].move(
                    self.width() - width_btn - pad_left, pos_bottom)
                pad_left += width_btn + 5

                if self._highlight_graph == button_name:
                    btn_css = "background:%s; color:#FFF; border:none; border-radius:3px;" % self._points_colors[
                        button_name].name()
                else:
                    btn_css = "background:#444; color:#FFF; border:none; border-radius:3px;"
                self._buttons[button_name].setStyleSheet(btn_css)

#   Raise the curve at the first display....
        if self.raise_level < 10:
            self.raise_level += 1
            time.sleep(0.000015)
            self.update()
示例#12
0
    def __init__(self, nodes_name, version_number, infos_dict=None, in_tree=True, parent=None):
        super(GraphWidget, self).__init__(parent)
        self.setMinimumHeight(360)

        self.setMouseTracking(True)

        self._buttons = dict(
            total=None, enabled=None, in_tree=None, tracked=None)
        self._cursor = None
        self.raise_level = 7

        self.nodes_name = nodes_name
        self.in_tree = in_tree
        self._version_number = version_number

        self._points = dict(total=[], enabled=[], in_tree=None, tracked=None)
        self._highlight_graph = "total"

        self._pad_left = 60
        self._pad_top = 20
        self._pad_right = 20
        self._pad_bottom = 50

        self._color_back_2 = QtGui.QColor()
        self._color_back_1 = QtGui.QColor()

        self._color_back_2.setNamedColor('#222')
        self._color_back_1.setNamedColor('#333')
        self._color_dot_lines = QtGui.QColor(150, 150, 150)
        self._color_dot_lines_hover = QtGui.QColor(80, 80, 80)
        self._color_axis_text = QtGui.QColor(80, 80, 80)
        self._color_tooltip = QtGui.QColor(100, 100, 100)
        self._color_tooltip_text = QtGui.QColor(30, 30, 30)

        self._color_btn_on = QtGui.QColor(170, 170, 170)
        self._color_btn_off = QtGui.QColor(80, 80, 80)

        self._points_colors = dict(total=QtGui.QColor(112, 129, 69),
                                   enabled=QtGui.QColor(83, 128, 162),
                                   in_tree=QtGui.QColor(187, 151, 89),
                                   tracked=QtGui.QColor(131, 30, 22))

        self.set_infos(infos_dict)
        self.set_buttons()
示例#13
0
    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)
示例#14
0
    def _updateNavigator(self, targetReference):
        '''Update navigator to display entries under *targetReference*.'''
        entity = self._bridge.getEntityById(targetReference)

        # Display path to entity.
        self._locationField.setText(
            self._bridge.getEntityPath(targetReference,
                                       slash=True,
                                       includeAssettype=True))

        # Update selection.
        self._currentBrowsingId = targetReference
        entityType = self._bridge.getEntityType(targetReference)
        self._selectionValid = self._isValid(entityType, entity)
        self.clickedIdSignal.emit(self._currentBrowsingId)

        # Update details view.
        self._detailView.updateDetails(self._currentBrowsingId)

        # Update other navigators.
        if hasattr(entity, 'getVersions'):
            if self._showAssetVersions == True:
                self._updateVersionsNavigator(entity)
                self._versionsNavigator.show()
            return

        elif hasattr(entity, 'getComponents'):
            components = entity.getComponents()
            importableComponents = []
            self._componentsNavigator.hide()

            for component in components:
                if self._componentNamesFilter:
                    if not component in self._componentNamesFilter:
                        continue

                if self._metaFilters:
                    metaData = component.getMeta()

                    # img_main to be replaced by settable option
                    for metaFilter in self._metaFilters:
                        if metaFilter in metaData:
                            importableComponents.append(component)

                else:
                    importableComponents.append(component)

            if len(importableComponents) > 1:
                self._updateComponentsNavigator(importableComponents)
                self._componentsNavigator.show()

            elif len(importableComponents) == 1:
                self._updateNavigator(importableComponents[0].getEntityRef())

            return

        elif entityType == 'Task':
            return

        elif isinstance(entity, ftrack.Component):
            return

        else:
            self._versionsNavigator.hide()
            self._componentsNavigator.hide()

        # Update main navigator view.
        self._navigator.setRowCount(0)
        self._versionsNavigator.setRowCount(0)

        self._navigator.setHorizontalHeaderLabels(
            [self._bridge.getEntityName(targetReference)])

        children = []
        tasks = []
        assets = []

        if isinstance(entity, ftrack.Project) or isinstance(
                entity, ftrack.Task):
            children = entity.getChildren()

        if hasattr(entity, 'getTasks') and self._showTasks == True:
            tasks = entity.getTasks()

        if hasattr(entity, 'getAssets'):
            if (not isinstance(entity, ftrack.Project)
                    and entity.getObjectType() in ['Shot', 'Sequence']
                    and self._showAssets == True):
                if self._componentNamesFilter:
                    assets = entity.getAssets(
                        componentNames=self._componentNamesFilter)
                else:
                    assets = entity.getAssets()

        entities = children + tasks + assets
        entities = sorted(entities,
                          key=lambda entity: self._bridge.getEntityName(
                              entity.getEntityRef()).lower())

        self._navigator.setRowCount(len(entities))
        for index, entity in enumerate(entities):
            makeBold = None
            makeItalic = None
            makeDisabled = None

            if (isinstance(entity, ftrack.Task)
                    and entity.getObjectType() in ['Shot', 'Sequence']):
                text = self._bridge.getEntityName(entity.getEntityRef()) + '/'
                makeBold = True

            elif (isinstance(entity, ftrack.Task)
                  and entity.getObjectType() in ['Task']):
                text = self._bridge.getEntityName(entity.getEntityRef())
                makeItalic = True
                if isinstance(entity.getParent(), ftrack.Project):
                    makeDisabled = True

            elif isinstance(entity, ftrack.Asset):
                text = (self._bridge.getEntityName(entity.getEntityRef()) +
                        '.' + entity.getType().getShort())

            else:
                text = self._bridge.getEntityName(entity.getEntityRef())

            if entityType == 'Sequence' and self._shotsEnabled == False:
                makeDisabled = True

            item = QtWidgets.QTableWidgetItem(text)
            item.setData(QtCore.Qt.UserRole, entity.getEntityRef())

            icon = self._getIcon(entity)
            if icon:
                item.setIcon(icon)

            if makeDisabled:
                item.setFlags(QtCore.Qt.NoItemFlags)

            self._navigator.setItem(index, 0, item)

            if makeBold:
                font = QtGui.QFont()
                font.setBold(True)
                self._navigator.item(index, 0).setFont(font)

            elif makeItalic:
                font = QtGui.QFont()
                font.setItalic(True)
                self._navigator.item(index, 0).setFont(font)