mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 13:52:15 +01:00
added more options how to icon can be defined
This commit is contained in:
parent
172fc27fa0
commit
05ba75c5e9
1 changed files with 17 additions and 0 deletions
|
|
@ -1,11 +1,13 @@
|
|||
import os
|
||||
import sys
|
||||
import io
|
||||
import contextlib
|
||||
import collections
|
||||
import traceback
|
||||
from functools import partial
|
||||
from typing import Union, Any
|
||||
|
||||
import ayon_api
|
||||
from qtpy import QtWidgets, QtCore, QtGui
|
||||
import qtawesome
|
||||
import qtmaterialsymbols
|
||||
|
|
@ -485,6 +487,9 @@ class _IconsCache:
|
|||
if isinstance(color, QtGui.QColor):
|
||||
color = color.name()
|
||||
parts = [icon_type, icon_def["name"] or "", color]
|
||||
|
||||
elif icon_type in {"url", "ayon_url"}:
|
||||
parts = [icon_type, icon_def["url"]]
|
||||
return "|".join(parts)
|
||||
|
||||
@classmethod
|
||||
|
|
@ -517,6 +522,18 @@ class _IconsCache:
|
|||
if qtmaterialsymbols.get_icon_name_char(icon_name) is not None:
|
||||
icon = qtmaterialsymbols.get_icon(icon_name, icon_color)
|
||||
|
||||
elif icon_type == "url":
|
||||
url = icon_def["url"]
|
||||
icon = QtGui.QPixmap(url)
|
||||
|
||||
elif icon_type == "ayon_url":
|
||||
url = ayon_api.get_base_url() + icon_def["url"]
|
||||
stream = io.BytesIO()
|
||||
ayon_api.download_file_to_stream(url, stream)
|
||||
pix = QtGui.QPixmap()
|
||||
pix.loadFromData(stream.getvalue())
|
||||
icon = QtGui.QIcon(pix)
|
||||
|
||||
if icon is None:
|
||||
icon = cls.get_default()
|
||||
cls._cache[cache_key] = icon
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue