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 __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
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)