Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publisher: show visual difference default vs overridden attributes #146

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open
Changes from 3 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
e59292b
enhancement/AY-2614_display_overriden_vs_default_attributes_in_publisher
Mar 5, 2024
d744eec
enhancement/AY-2614_display_overriden_vs_default_attributes_in_publisher
Mar 5, 2024
d48f97c
enhancement/AY-2614_display_overriden_vs_default_attributes_in_publisher
Mar 5, 2024
b4f37f0
enhancement/AY-2614_display_overriden_vs_default_attributes_in_publisher
Mar 5, 2024
cf8792b
enhancement/AY-2614_display_overriden_vs_default_attributes_in_publisher
Mar 5, 2024
7d1ffe7
enhancement/AY-2614_display_overriden_vs_default_attributes_in_publisher
Mar 5, 2024
18afb0f
Merge branch 'develop' into enhancement/AY-2614_display_overriden_vs_…
jakubjezek001 Mar 7, 2024
a7fa42e
apply stylesheet on multi select and when loading widget
Mar 10, 2024
2113400
Merge branch 'enhancement/AY-2614_display_overriden_vs_default_attrib…
Mar 10, 2024
de9eadf
apply stylesheet on multi select and when loading widget
Mar 10, 2024
d5c6d65
Merge branch 'develop' into enhancement/AY-2614_display_overriden_vs_…
jakubjezek001 Mar 11, 2024
23a4475
Merge branch 'develop' into enhancement/AY-2614_display_overriden_vs_…
LiborBatek Mar 12, 2024
633612a
Merge branch 'develop' into enhancement/AY-2614_display_overriden_vs_…
iLLiCiTiT May 16, 2024
f213dca
change style only on existing label widgets
iLLiCiTiT May 17, 2024
f6532cb
use property to change style
iLLiCiTiT May 17, 2024
ee8abf5
fix set value of multiselection
iLLiCiTiT May 17, 2024
953b605
separate overriden logic from set value logic
iLLiCiTiT May 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions client/ayon_core/tools/publisher/widgets/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,7 @@ def __init__(self, controller, parent):

self._attr_def_id_to_instances = {}
self._attr_def_id_to_attr_def = {}
self._attr_def_id_to_label = {}

# To store content of scroll area to prevent garbage collection
self._content_widget = None
Expand All @@ -1381,6 +1382,7 @@ def set_current_instances(self, instances):
self._content_widget = None
self._attr_def_id_to_instances = {}
self._attr_def_id_to_attr_def = {}
self._attr_def_id_to_label = {}

result = self._controller.get_creator_attribute_definitions(
instances
Expand Down Expand Up @@ -1423,6 +1425,7 @@ def set_current_instances(self, instances):
label = attr_def.label or attr_def.key
if label:
label_widget = QtWidgets.QLabel(label, self)
self._attr_def_id_to_label[attr_def.id] = label_widget
tooltip = attr_def.tooltip
if tooltip:
label_widget.setToolTip(tooltip)
Expand Down Expand Up @@ -1451,6 +1454,23 @@ def _input_value_changed(self, value, attr_id):
if not instances or not attr_def:
return

# Update the styling of the associated label if is default or override
label_widget = self._attr_def_id_to_label.get(attr_id)
if label_widget:
# NOTE: The default returned by attr_def.default is returning a
# float, when it should be a int. So lets cast the widget value
# (argument to this method) to a float to match the type.
_value = value
if isinstance(_value, int):
_value = float(_value)
is_default = _value == attr_def.default
font = label_widget.font()
if is_default:
label_widget.setStyleSheet("")
else:
label_widget.setStyleSheet("font: bold")
label_widget.setFont(font)

for instance in instances:
creator_attributes = instance["creator_attributes"]
if attr_def.key in creator_attributes:
Expand Down Expand Up @@ -1495,6 +1515,7 @@ def __init__(self, controller, parent):
self._attr_def_id_to_instances = {}
self._attr_def_id_to_attr_def = {}
self._attr_def_id_to_plugin_name = {}
self._attr_def_id_to_label = {}

# Store content of scroll area to prevent garbage collection
self._content_widget = None
Expand All @@ -1521,6 +1542,7 @@ def set_current_instances(self, instances, context_selected):
self._attr_def_id_to_instances = {}
self._attr_def_id_to_attr_def = {}
self._attr_def_id_to_plugin_name = {}
self._attr_def_id_to_label = {}

result = self._controller.get_publish_attribute_definitions(
instances, context_selected
Expand Down Expand Up @@ -1565,6 +1587,7 @@ def set_current_instances(self, instances, context_selected):
label = attr_def.label or attr_def.key
if label:
label_widget = QtWidgets.QLabel(label, content_widget)
self._attr_def_id_to_label[attr_def.id] = label_widget
tooltip = attr_def.tooltip
if tooltip:
label_widget.setToolTip(tooltip)
Expand Down Expand Up @@ -1615,6 +1638,23 @@ def _input_value_changed(self, value, attr_id):
if not instances or not attr_def or not plugin_name:
return

# Update the styling of the associated label if is default or override
label_widget = self._attr_def_id_to_label.get(attr_id)
if label_widget:
# NOTE: The default returned by attr_def.default is returning a
bradenjennings marked this conversation as resolved.
Show resolved Hide resolved
# float, when it should be a int. So lets cast the widget value
# (argument to this method) to a float to match the type.
_value = value
if isinstance(_value, int):
_value = float(_value)
is_default = _value == attr_def.default
font = label_widget.font()
if is_default:
label_widget.setStyleSheet("")
else:
label_widget.setStyleSheet("font: bold")
label_widget.setFont(font)
bradenjennings marked this conversation as resolved.
Show resolved Hide resolved

for instance in instances:
plugin_val = instance.publish_attributes[plugin_name]
plugin_val[attr_def.key] = value
Expand Down