diff --git a/python/tk_multi_publish2/dialog.py b/python/tk_multi_publish2/dialog.py index 897739e5..26755747 100644 --- a/python/tk_multi_publish2/dialog.py +++ b/python/tk_multi_publish2/dialog.py @@ -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, "

Task and Entity Link to apply to the selected item:

" - ) + # 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, + "

Task Required is True in your configuration. " + "Please select a Task to continue.

", + ) + self.ui.context_widget.ui.label.setStyleSheet( + "color: " + + sgtk.platform.current_bundle().style_constants[ + "SG_HIGHLIGHT_COLOR" + ] + ) + else: + self.ui.context_widget.enable_editing( + True, + "

Task and Entity Link to apply to the selected item:

", + ) + # 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 = ( + "

Task Required is True in your configuration. " + "Please confirm all Tasks are assigned to continue.

" + ) + 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("") 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 = ( + "

Task Required is True in your configuration. " + "Please confirm all Tasks are assigned to continue.

" + ) + 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):