diff --git a/openpype/tools/new_publisher/control.py b/openpype/tools/new_publisher/control.py index d87c4124a7..2a7d0e4c55 100644 --- a/openpype/tools/new_publisher/control.py +++ b/openpype/tools/new_publisher/control.py @@ -258,6 +258,8 @@ class PublisherController: self._publish_up_validation = False # All publish plugins are processed self._publish_finished = False + self._publish_max_progress = 0 + self._publish_progress = 0 # Validation order # - plugin with order same or higher than this value is extractor or @@ -521,6 +523,14 @@ class PublisherController: def publish_has_crashed(self): return bool(self._publish_error) + @property + def publish_max_progress(self): + return self._publish_max_progress + + @property + def publish_progress(self): + return self._publish_progress + def get_publish_crash_error(self): return self._publish_error @@ -544,6 +554,9 @@ class PublisherController: self._publish_current_plugin_validation_errors = None self._publish_error = None + self._publish_max_progress = len(self.publish_plugins) + self._publish_progress = 0 + self._trigger_callbacks(self._publish_reset_callback_refs) def publish(self): @@ -606,7 +619,8 @@ class PublisherController: self._main_thread_processor.add_item(item) def _publish_iterator(self): - for plugin in self.publish_plugins: + for idx, plugin in enumerate(self.publish_plugins): + self._publish_progress = idx # Add plugin to publish report self._publish_report.add_plugin_iter(plugin, self._publish_context) @@ -681,6 +695,7 @@ class PublisherController: self._publish_report.set_plugin_skipped() self._publish_finished = True + self._publish_progress = self._publish_max_progress yield MainThreadItem(self.stop_publish) def _add_validation_error(self, result): diff --git a/openpype/tools/new_publisher/widgets/publish_widget.py b/openpype/tools/new_publisher/widgets/publish_widget.py index 0b20da2c24..c7e3d3a6a8 100644 --- a/openpype/tools/new_publisher/widgets/publish_widget.py +++ b/openpype/tools/new_publisher/widgets/publish_widget.py @@ -133,14 +133,6 @@ class PublishFrame(QtWidgets.QFrame): self.validate_btn = validate_btn self.publish_btn = publish_btn - def set_progress_range(self, max_value): - # TODO implement triggers for this method - self.progress_widget.setMaximum(max_value) - - def set_progress(self, value): - # TODO implement triggers for this method - self.progress_widget.setValue(value) - def _on_publish_reset(self): self._set_success_property() self._change_bg_property() @@ -154,6 +146,9 @@ class PublishFrame(QtWidgets.QFrame): self.validate_btn.setEnabled(True) self.publish_btn.setEnabled(True) + self.progress_widget.setValue(self.controller.publish_progress) + self.progress_widget.setMaximum(self.controller.publish_max_progress) + def _on_publish_start(self): self.validation_errors_widget.clear() @@ -194,10 +189,13 @@ class PublishFrame(QtWidgets.QFrame): if hasattr(plugin, "label") and plugin.label: plugin_name = plugin.label + self.progress_widget.setValue(self.controller.publish_progress) self.plugin_label.setText(plugin_name) QtWidgets.QApplication.processEvents() def _on_publish_stop(self): + self.progress_widget.setValue(self.controller.publish_progress) + self.reset_btn.setEnabled(True) self.stop_btn.setEnabled(False) validate_enabled = not self.controller.publish_has_crashed