From 7f4ac947a7b9ff193317db0c9de36b9da1fb1845 Mon Sep 17 00:00:00 2001 From: Rob Aitchison Date: Wed, 22 Jul 2020 17:11:05 -0400 Subject: [PATCH 1/7] Updated text in the UI when task_required set to true --- python/tk_multi_publish2/dialog.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/python/tk_multi_publish2/dialog.py b/python/tk_multi_publish2/dialog.py index 897739e5..32ccdbc1 100644 --- a/python/tk_multi_publish2/dialog.py +++ b/python/tk_multi_publish2/dialog.py @@ -1656,8 +1656,18 @@ 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") + # 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 parent label + self.ui.context_widget.ui.label.setText( + "Task Required is turned ON 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: # enable buttons self.ui.publish.setEnabled(True) From 24c05a64b25862c6f8c659b7ba66610cbe8b7919 Mon Sep 17 00:00:00 2001 From: Rob Aitchison Date: Mon, 27 Jul 2020 13:01:33 -0400 Subject: [PATCH 2/7] Added a clearing call for text and color after Task is selected --- python/tk_multi_publish2/dialog.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/tk_multi_publish2/dialog.py b/python/tk_multi_publish2/dialog.py index 32ccdbc1..398e79ec 100644 --- a/python/tk_multi_publish2/dialog.py +++ b/python/tk_multi_publish2/dialog.py @@ -1673,9 +1673,12 @@ def _validate_task_required(self): self.ui.publish.setEnabled(True) self.ui.validate.setEnabled(True) - # change task label color to the default value + # change task label color and text back to the default values self.ui.context_widget.ui.task_label.setStyleSheet("") - + self.ui.context_widget.ui.label.setText( + "Task and Entity Link to apply to the selected item:" + ) + self.ui.context_widget.ui.label.setStyleSheet("") class _TaskSelection(object): """ From 2229dade0149eb1849d76f39e879223721b4d4e3 Mon Sep 17 00:00:00 2001 From: rob-aitchison Date: Wed, 5 Aug 2020 16:52:16 -0400 Subject: [PATCH 3/7] Ran pre-commit hooks to ensure build will work. --- python/tk_multi_publish2/dialog.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/tk_multi_publish2/dialog.py b/python/tk_multi_publish2/dialog.py index 398e79ec..ebf93fde 100644 --- a/python/tk_multi_publish2/dialog.py +++ b/python/tk_multi_publish2/dialog.py @@ -1658,7 +1658,8 @@ def _validate_task_required(self): self.ui.validate.setEnabled(False) # 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"] + "color: " + + sgtk.platform.current_bundle().style_constants["SG_ALERT_COLOR"] ) # Also change the text and color of the parent label self.ui.context_widget.ui.label.setText( @@ -1666,7 +1667,8 @@ def _validate_task_required(self): "Please select a Task to continue." ) self.ui.context_widget.ui.label.setStyleSheet( - "color: " + sgtk.platform.current_bundle().style_constants["SG_HIGHLIGHT_COLOR"] + "color: " + + sgtk.platform.current_bundle().style_constants["SG_HIGHLIGHT_COLOR"] ) else: # enable buttons @@ -1680,6 +1682,7 @@ def _validate_task_required(self): ) self.ui.context_widget.ui.label.setStyleSheet("") + class _TaskSelection(object): """ Allows to manipulate a task selection as if it was a single object. It will hold a list of From 6e7b62eb2843db783d19c2da8528ed3e05360f1d Mon Sep 17 00:00:00 2001 From: rob-aitchison Date: Tue, 11 Aug 2020 17:21:29 -0400 Subject: [PATCH 4/7] Moved style tweak to _create_item_details function. Working for single file so committing now. --- python/tk_multi_publish2/dialog.py | 48 +++++++++++++++--------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/python/tk_multi_publish2/dialog.py b/python/tk_multi_publish2/dialog.py index ebf93fde..5515afc8 100644 --- a/python/tk_multi_publish2/dialog.py +++ b/python/tk_multi_publish2/dialog.py @@ -668,9 +668,30 @@ 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 accordingly + if self._bundle.get_setting("task_required"): + if hasattr(item, "context") and not item.context.task: + # 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 parent label + 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:

" + ) + self.ui.context_widget.ui.task_label.setStyleSheet("") + self.ui.context_widget.ui.label.setStyleSheet("") else: self.ui.context_widget.enable_editing( False, @@ -1656,32 +1677,11 @@ def _validate_task_required(self): # disable buttons self.ui.publish.setEnabled(False) self.ui.validate.setEnabled(False) - # 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 parent label - self.ui.context_widget.ui.label.setText( - "Task Required is turned ON 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: # enable buttons self.ui.publish.setEnabled(True) self.ui.validate.setEnabled(True) - # change task label color and text back to the default values - self.ui.context_widget.ui.task_label.setStyleSheet("") - self.ui.context_widget.ui.label.setText( - "Task and Entity Link to apply to the selected item:" - ) - self.ui.context_widget.ui.label.setStyleSheet("") - class _TaskSelection(object): """ From 074eb1847b2b6d2c16a29b8fbba42759c3a49b0e Mon Sep 17 00:00:00 2001 From: rob-aitchison Date: Tue, 11 Aug 2020 17:25:54 -0400 Subject: [PATCH 5/7] Black pre-commit hook changes. --- python/tk_multi_publish2/dialog.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/python/tk_multi_publish2/dialog.py b/python/tk_multi_publish2/dialog.py index 5515afc8..d70f7fe1 100644 --- a/python/tk_multi_publish2/dialog.py +++ b/python/tk_multi_publish2/dialog.py @@ -674,21 +674,26 @@ def _create_item_details(self, tree_item): # 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"] + + sgtk.platform.current_bundle().style_constants[ + "SG_ALERT_COLOR" + ] ) # Also change the text and color of the parent label self.ui.context_widget.enable_editing( True, - "Task Required is True in your configuration. " - "Please select a Task to continue." + "

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

" + True, + "

Task and Entity Link to apply to the selected item:

", ) self.ui.context_widget.ui.task_label.setStyleSheet("") self.ui.context_widget.ui.label.setStyleSheet("") From c51be0a5341e303b6b16f5cac9f4a260c335f444 Mon Sep 17 00:00:00 2001 From: rob-aitchison Date: Tue, 11 Aug 2020 18:36:07 -0400 Subject: [PATCH 6/7] Multiple file publish flows now working as expected. Style changes apply to each item and to the summary. --- python/tk_multi_publish2/dialog.py | 55 ++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/python/tk_multi_publish2/dialog.py b/python/tk_multi_publish2/dialog.py index d70f7fe1..5594683e 100644 --- a/python/tk_multi_publish2/dialog.py +++ b/python/tk_multi_publish2/dialog.py @@ -813,17 +813,55 @@ 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 on task_required for the summary styling + if not self._validate_task_required(): + 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" + ] + ) + self.ui.context_widget.ui.task_label.setStyleSheet( + "color: " + + sgtk.platform.current_bundle().style_constants["SG_ALERT_COLOR"] + ) + else: + context_label_text = "Task and Entity Link to apply to all items:" + 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 on task_required for the summary styling + if not self._validate_task_required(): + 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" + ] + ) + self.ui.context_widget.ui.task_label.setStyleSheet( + "color: " + + sgtk.platform.current_bundle().style_constants["SG_ALERT_COLOR"] + ) + else: + context_label_text = ( + "Currently publishing items to %s contexts. " + "Override all items here:" % (len(current_contexts),) + ) + 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) @@ -1580,6 +1618,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 application + self._create_master_summary_details() def _on_browse(self, folders=False): """Opens a file dialog to browse to files for publishing.""" @@ -1663,8 +1703,7 @@ 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"): @@ -1682,10 +1721,12 @@ def _validate_task_required(self): # disable buttons self.ui.publish.setEnabled(False) self.ui.validate.setEnabled(False) + return False else: # enable buttons self.ui.publish.setEnabled(True) self.ui.validate.setEnabled(True) + return True class _TaskSelection(object): From aef3d8c4087d1bde280b1322cb34a2541329143c Mon Sep 17 00:00:00 2001 From: rob-aitchison Date: Tue, 11 Aug 2020 18:52:22 -0400 Subject: [PATCH 7/7] Updated code comments to make consistent. --- python/tk_multi_publish2/dialog.py | 91 ++++++++++++++++-------------- 1 file changed, 50 insertions(+), 41 deletions(-) diff --git a/python/tk_multi_publish2/dialog.py b/python/tk_multi_publish2/dialog.py index 5594683e..26755747 100644 --- a/python/tk_multi_publish2/dialog.py +++ b/python/tk_multi_publish2/dialog.py @@ -668,35 +668,36 @@ def _create_item_details(self, tree_item): self.ui.context_widget.show() if item.context_change_allowed: - # Check for task_required and change UI accordingly - if self._bundle.get_setting("task_required"): - if hasattr(item, "context") and not item.context.task: - # 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 parent label - 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:

", - ) - self.ui.context_widget.ui.task_label.setStyleSheet("") - self.ui.context_widget.ui.label.setStyleSheet("") + # 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, @@ -813,8 +814,15 @@ 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]) - # Check on task_required for the summary styling + # 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.

" @@ -825,12 +833,9 @@ def _create_master_summary_details(self): "SG_HIGHLIGHT_COLOR" ] ) - self.ui.context_widget.ui.task_label.setStyleSheet( - "color: " - + sgtk.platform.current_bundle().style_constants["SG_ALERT_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: @@ -839,8 +844,15 @@ def _create_master_summary_details(self): task_display_override=" -- Multiple values -- ", link_display_override=" -- Multiple values -- ", ) - # Check on task_required for the summary styling + # 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.

" @@ -851,15 +863,12 @@ def _create_master_summary_details(self): "SG_HIGHLIGHT_COLOR" ] ) - self.ui.context_widget.ui.task_label.setStyleSheet( - "color: " - + sgtk.platform.current_bundle().style_constants["SG_ALERT_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("") @@ -1618,7 +1627,7 @@ 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 application + # Re-draw the summary for styling updates self._create_master_summary_details() def _on_browse(self, folders=False): @@ -1707,7 +1716,7 @@ def _validate_task_required(self): """ # 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()):