-
Notifications
You must be signed in to change notification settings - Fork 62
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
SHOT-2850 Small update to the task_required UI display #130
base: master
Are you sure you want to change the base?
Changes from all commits
7f4ac94
24c05a6
2229dad
6e7b62e
074eb18
c51be0a
aef3d8c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -668,9 +668,36 @@ def _create_item_details(self, tree_item): | |
self.ui.context_widget.show() | ||
|
||
if item.context_change_allowed: | ||
self.ui.context_widget.enable_editing( | ||
True, "<p>Task and Entity Link to apply to the selected item:</p>" | ||
) | ||
# Check for task_required and change UI styling accordingly | ||
if not self._validate_task_required(): | ||
# Change task label color to SG_ALERT_COLOR | ||
self.ui.context_widget.ui.task_label.setStyleSheet( | ||
"color: " | ||
+ sgtk.platform.current_bundle().style_constants[ | ||
"SG_ALERT_COLOR" | ||
] | ||
) | ||
# Also change the text and color of the label | ||
# Use SG_HIGHLIGHT_COLOR for better readability | ||
self.ui.context_widget.enable_editing( | ||
True, | ||
"<p>Task Required is <b>True</b> in your configuration. " | ||
"Please select a Task to continue.</p>", | ||
) | ||
self.ui.context_widget.ui.label.setStyleSheet( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you should be able to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also could the color be set through the |
||
"color: " | ||
+ sgtk.platform.current_bundle().style_constants[ | ||
"SG_HIGHLIGHT_COLOR" | ||
] | ||
) | ||
else: | ||
self.ui.context_widget.enable_editing( | ||
True, | ||
"<p>Task and Entity Link to apply to the selected item:</p>", | ||
) | ||
# Ensure styling overrides are cleared | ||
self.ui.context_widget.ui.task_label.setStyleSheet("") | ||
self.ui.context_widget.ui.label.setStyleSheet("") | ||
else: | ||
self.ui.context_widget.enable_editing( | ||
False, | ||
|
@@ -787,17 +814,63 @@ def _create_master_summary_details(self): | |
# the summary view's context widget | ||
context_key = list(current_contexts.keys())[0] | ||
self.ui.context_widget.set_context(current_contexts[context_key]) | ||
context_label_text = "Task and Entity Link to apply to all items:" | ||
# Check for task_required and change UI styling accordingly | ||
if not self._validate_task_required(): | ||
# Change task label color to SG_ALERT_COLOR | ||
self.ui.context_widget.ui.task_label.setStyleSheet( | ||
"color: " | ||
+ sgtk.platform.current_bundle().style_constants["SG_ALERT_COLOR"] | ||
) | ||
# Also change the text and color of the label | ||
# Use SG_HIGHLIGHT_COLOR for better readability | ||
context_label_text = ( | ||
"<p>Task Required is <b>True</b> in your configuration. " | ||
"Please confirm all Tasks are assigned to continue.</p>" | ||
) | ||
self.ui.context_widget.ui.label.setStyleSheet( | ||
"color: " | ||
+ sgtk.platform.current_bundle().style_constants[ | ||
"SG_HIGHLIGHT_COLOR" | ||
] | ||
) | ||
else: | ||
context_label_text = "Task and Entity Link to apply to all items:" | ||
# Ensure styling overrides are cleared | ||
self.ui.context_widget.ui.label.setStyleSheet("") | ||
self.ui.context_widget.ui.task_label.setStyleSheet("") | ||
Comment on lines
+817
to
+840
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Other than the |
||
else: | ||
self.ui.context_widget.set_context( | ||
None, | ||
task_display_override=" -- Multiple values -- ", | ||
link_display_override=" -- Multiple values -- ", | ||
) | ||
context_label_text = ( | ||
"Currently publishing items to %s contexts. " | ||
"Override all items here:" % (len(current_contexts),) | ||
) | ||
# Check for task_required and change UI styling accordingly | ||
if not self._validate_task_required(): | ||
# Change task label color to SG_ALERT_COLOR | ||
self.ui.context_widget.ui.task_label.setStyleSheet( | ||
"color: " | ||
+ sgtk.platform.current_bundle().style_constants["SG_ALERT_COLOR"] | ||
) | ||
# Also change the text and color of the label | ||
# Use SG_HIGHLIGHT_COLOR for better readability | ||
context_label_text = ( | ||
"<p>Task Required is <b>True</b> in your configuration. " | ||
"Please confirm all Tasks are assigned to continue.</p>" | ||
) | ||
self.ui.context_widget.ui.label.setStyleSheet( | ||
"color: " | ||
+ sgtk.platform.current_bundle().style_constants[ | ||
"SG_HIGHLIGHT_COLOR" | ||
] | ||
) | ||
else: | ||
context_label_text = ( | ||
"Currently publishing items to %s contexts. " | ||
"Override all items here:" % (len(current_contexts),) | ||
) | ||
# Ensure styling overrides are cleared | ||
self.ui.context_widget.ui.label.setStyleSheet("") | ||
self.ui.context_widget.ui.task_label.setStyleSheet("") | ||
|
||
self.ui.context_widget.show() | ||
self.ui.context_widget.enable_editing(True, context_label_text) | ||
|
@@ -1554,6 +1627,8 @@ def _on_item_context_change(self, context): | |
|
||
# Make the task validation if the setting `task_required` exists and it's True | ||
self._validate_task_required() | ||
# Re-draw the summary for styling updates | ||
self._create_master_summary_details() | ||
|
||
def _on_browse(self, folders=False): | ||
"""Opens a file dialog to browse to files for publishing.""" | ||
|
@@ -1637,12 +1712,11 @@ def _show_no_items_error(self): | |
def _validate_task_required(self): | ||
""" | ||
Validates that a task is selected for every item and disables/enables the | ||
validate and publish buttons and finally change the color for the task | ||
label. | ||
validate and publish buttons | ||
""" | ||
# Avoid validation if the setting `task_required` is False or not exists | ||
if not self._bundle.get_setting("task_required"): | ||
return | ||
return True | ||
|
||
all_items_selected_task = True | ||
for context_index in range(self.ui.items_tree.topLevelItemCount()): | ||
|
@@ -1656,15 +1730,12 @@ def _validate_task_required(self): | |
# disable buttons | ||
self.ui.publish.setEnabled(False) | ||
self.ui.validate.setEnabled(False) | ||
# change task label color to RED | ||
self.ui.context_widget.ui.task_label.setStyleSheet("color: red") | ||
return False | ||
else: | ||
# enable buttons | ||
self.ui.publish.setEnabled(True) | ||
self.ui.validate.setEnabled(True) | ||
|
||
# change task label color to the default value | ||
self.ui.context_widget.ui.task_label.setStyleSheet("") | ||
return True | ||
|
||
|
||
class _TaskSelection(object): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like I mentioned bellow, I'm not sure it's a good idea to go via the
context_widget.ui
, the widgets in there might get updated. Though it looks like this particular label is not exposed publicly.I guess the correct thing to do would be to update the qtwidgets framework to publicly expose that label.
@jfboismenu what do you think?