mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-02 00:44:52 +01:00
add icon to select version dialog
This commit is contained in:
parent
266ea1daef
commit
ace46cd441
2 changed files with 18 additions and 1 deletions
|
|
@ -2,6 +2,7 @@ import uuid
|
|||
|
||||
from qtpy import QtWidgets, QtCore, QtGui
|
||||
|
||||
from ayon_core.tools.utils import get_qt_icon
|
||||
from ayon_core.tools.utils.delegates import StatusDelegate
|
||||
|
||||
from .model import (
|
||||
|
|
@ -20,13 +21,15 @@ class VersionOption:
|
|||
label,
|
||||
status_name,
|
||||
status_short,
|
||||
status_color
|
||||
status_color,
|
||||
status_icon,
|
||||
):
|
||||
self.version = version
|
||||
self.label = label
|
||||
self.status_name = status_name
|
||||
self.status_short = status_short
|
||||
self.status_color = status_color
|
||||
self.status_icon = status_icon
|
||||
|
||||
|
||||
class SelectVersionModel(QtGui.QStandardItemModel):
|
||||
|
|
@ -130,7 +133,17 @@ class SelectVersionComboBox(QtWidgets.QComboBox):
|
|||
root_item.removeRows(0, root_item.rowCount())
|
||||
|
||||
new_items = []
|
||||
icons_by_name = {}
|
||||
for version_option in version_options:
|
||||
icon = icons_by_name.get(version_option.status_icon)
|
||||
if icon is None:
|
||||
icon = get_qt_icon({
|
||||
"type": "material-symbols",
|
||||
"name": version_option.status_icon,
|
||||
"color": QtGui.QColor(version_option.status_color)
|
||||
})
|
||||
icons_by_name[version_option.status_icon] = icon
|
||||
|
||||
item_id = uuid.uuid4().hex
|
||||
item = QtGui.QStandardItem(version_option.label)
|
||||
item.setColumnCount(root_item.columnCount())
|
||||
|
|
@ -143,6 +156,7 @@ class SelectVersionComboBox(QtWidgets.QComboBox):
|
|||
item.setData(
|
||||
version_option.status_color, STATUS_COLOR_ROLE
|
||||
)
|
||||
item.setData(icon, STATUS_ICON_ROLE)
|
||||
item.setData(item_id, ITEM_ID_ROLE)
|
||||
|
||||
new_items.append(item)
|
||||
|
|
|
|||
|
|
@ -726,10 +726,12 @@ class SceneInventoryView(QtWidgets.QTreeView):
|
|||
status_name = version_item.status
|
||||
status_short = None
|
||||
status_color = None
|
||||
status_icon = None
|
||||
status_item = status_items_by_name.get(status_name)
|
||||
if status_item:
|
||||
status_short = status_item.short
|
||||
status_color = status_item.color
|
||||
status_icon = status_item.icon
|
||||
version_options.append(
|
||||
VersionOption(
|
||||
version,
|
||||
|
|
@ -737,6 +739,7 @@ class SceneInventoryView(QtWidgets.QTreeView):
|
|||
status_name,
|
||||
status_short,
|
||||
status_color,
|
||||
status_icon,
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue