mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
fix updates of the label
This commit is contained in:
parent
4bf0bbe6c3
commit
0f480ee410
1 changed files with 16 additions and 6 deletions
|
|
@ -288,6 +288,8 @@ class InstanceCardWidget(CardWidget):
|
|||
self._last_product_name = None
|
||||
self._last_variant = None
|
||||
self._last_label = None
|
||||
self._last_folder_path = None
|
||||
self._last_task_name = None
|
||||
|
||||
icon_widget = IconValuePixmapLabel(group_icon, self)
|
||||
icon_widget.setObjectName("ProductTypeIconLabel")
|
||||
|
|
@ -384,15 +386,18 @@ class InstanceCardWidget(CardWidget):
|
|||
self._context_warning.setVisible(not valid)
|
||||
|
||||
@staticmethod
|
||||
def _get_card_widget_sub_label(folder_path, task_name):
|
||||
def _get_card_widget_sub_label(
|
||||
folder_path: Optional[str],
|
||||
task_name: Optional[str],
|
||||
) -> str:
|
||||
parts = []
|
||||
if folder_path:
|
||||
folder_name = folder_path.split("/")[-1]
|
||||
parts.append(f"<b>{folder_name}</b>")
|
||||
if task_name:
|
||||
parts.append(folder_name)
|
||||
parts.append(task_name)
|
||||
if not parts:
|
||||
return None
|
||||
return ""
|
||||
sublabel = " - ".join(parts)
|
||||
return f"<span style=\"font-size: 8pt;\">{sublabel}</span>"
|
||||
|
||||
|
|
@ -400,25 +405,30 @@ class InstanceCardWidget(CardWidget):
|
|||
variant = self.instance.variant
|
||||
product_name = self.instance.product_name
|
||||
label = self.instance.label
|
||||
folder_path = self.instance.get_folder_path()
|
||||
task_name = self.instance.get_task_name()
|
||||
folder_path = self.instance.folder_path
|
||||
task_name = self.instance.task_name
|
||||
|
||||
if (
|
||||
variant == self._last_variant
|
||||
and product_name == self._last_product_name
|
||||
and label == self._last_label
|
||||
and folder_path == self._last_folder_path
|
||||
and task_name == self._last_task_name
|
||||
):
|
||||
return
|
||||
|
||||
self._last_variant = variant
|
||||
self._last_product_name = product_name
|
||||
self._last_label = label
|
||||
self._last_folder_path = folder_path
|
||||
self._last_task_name = task_name
|
||||
|
||||
# Make `variant` bold
|
||||
label = html_escape(self.instance.label)
|
||||
found_parts = set(re.findall(variant, label, re.IGNORECASE))
|
||||
if found_parts:
|
||||
for part in found_parts:
|
||||
replacement = "<b>{}</b>".format(part)
|
||||
replacement = f"<b>{part}</b>"
|
||||
label = label.replace(part, replacement)
|
||||
sublabel = self._get_card_widget_sub_label(folder_path, task_name)
|
||||
if sublabel:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue