diff --git a/client/ayon_core/tools/loader/ui/products_delegates.py b/client/ayon_core/tools/loader/ui/products_delegates.py index 12ed1165ae..6bcb78ec66 100644 --- a/client/ayon_core/tools/loader/ui/products_delegates.py +++ b/client/ayon_core/tools/loader/ui/products_delegates.py @@ -6,6 +6,9 @@ from ayon_core.tools.utils.lib import format_version from .products_model import ( PRODUCT_ID_ROLE, VERSION_NAME_EDIT_ROLE, + VERSION_STATUS_NAME_ROLE, + VERSION_STATUS_SHORT_ROLE, + VERSION_STATUS_COLOR_ROLE, VERSION_ID_ROLE, PRODUCT_IN_SCENE_ROLE, ACTIVE_SITE_ICON_ROLE, @@ -194,6 +197,49 @@ class LoadedInSceneDelegate(QtWidgets.QStyledItemDelegate): option.palette.setBrush(QtGui.QPalette.Text, color) +class StatusDelegate(QtWidgets.QStyledItemDelegate): + """Delegate showing status name and short name.""" + + def paint(self, painter, option, index): + if option.widget: + style = option.widget.style() + else: + style = QtWidgets.QApplication.style() + + style.drawControl( + style.CE_ItemViewItem, option, painter, option.widget + ) + + painter.save() + + text_rect = style.subElementRect(style.SE_ItemViewItemText, option) + text_margin = style.proxy().pixelMetric( + style.PM_FocusFrameHMargin, option, option.widget + ) + 1 + padded_text_rect = text_rect.adjusted( + text_margin, 0, - text_margin, 0 + ) + + fm = QtGui.QFontMetrics(option.font) + text = index.data(VERSION_STATUS_NAME_ROLE) + if padded_text_rect.width() < fm.width(text): + text = index.data(VERSION_STATUS_SHORT_ROLE) + + status_color = index.data(VERSION_STATUS_COLOR_ROLE) + fg_color = QtGui.QColor(status_color) + pen = painter.pen() + pen.setColor(fg_color) + painter.setPen(pen) + + painter.drawText( + padded_text_rect, + option.displayAlignment, + text + ) + + painter.restore() + + class SiteSyncDelegate(QtWidgets.QStyledItemDelegate): """Paints icons and downloaded representation ration for both sites.""" diff --git a/client/ayon_core/tools/loader/ui/products_widget.py b/client/ayon_core/tools/loader/ui/products_widget.py index 9c6a1dbb85..3a30d83d52 100644 --- a/client/ayon_core/tools/loader/ui/products_widget.py +++ b/client/ayon_core/tools/loader/ui/products_widget.py @@ -22,7 +22,8 @@ from .products_model import ( from .products_delegates import ( VersionDelegate, LoadedInSceneDelegate, - SiteSyncDelegate + StatusDelegate, + SiteSyncDelegate, ) from .actions_utils import show_actions_menu @@ -89,6 +90,7 @@ class ProductsWidget(QtWidgets.QWidget): 90, # Product type 130, # Folder label 60, # Version + 100, # Status 125, # Time 75, # Author 75, # Frames @@ -129,12 +131,14 @@ class ProductsWidget(QtWidgets.QWidget): version_delegate = VersionDelegate() time_delegate = PrettyTimeDelegate() + status_delegate = StatusDelegate() in_scene_delegate = LoadedInSceneDelegate() sitesync_delegate = SiteSyncDelegate() for col, delegate in ( (products_model.version_col, version_delegate), (products_model.published_time_col, time_delegate), + (products_model.status_col, status_delegate), (products_model.in_scene_col, in_scene_delegate), (products_model.sitesync_avail_col, sitesync_delegate), ): @@ -172,6 +176,7 @@ class ProductsWidget(QtWidgets.QWidget): self._version_delegate = version_delegate self._time_delegate = time_delegate + self._status_delegate = status_delegate self._in_scene_delegate = in_scene_delegate self._sitesync_delegate = sitesync_delegate