mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-02 08:54:53 +01:00
moved plugin/instance change callbacks to overlay
This commit is contained in:
parent
bbb6840b13
commit
058d801bbc
2 changed files with 32 additions and 32 deletions
|
|
@ -907,7 +907,7 @@ class ThumbnailWidget(QtWidgets.QWidget):
|
|||
class PublishOverlayFrame(QtWidgets.QFrame):
|
||||
hide_requested = QtCore.Signal()
|
||||
|
||||
def __init__(self, parent):
|
||||
def __init__(self, controller, parent):
|
||||
super(PublishOverlayFrame, self).__init__(parent)
|
||||
|
||||
self.setObjectName("PublishOverlayFrame")
|
||||
|
|
@ -976,6 +976,11 @@ class PublishOverlayFrame(QtWidgets.QFrame):
|
|||
|
||||
hide_btn.clicked.connect(self.hide_requested)
|
||||
|
||||
controller.add_instance_change_callback(self._on_instance_change)
|
||||
controller.add_plugin_change_callback(self._on_plugin_change)
|
||||
|
||||
self.controller = controller
|
||||
|
||||
self.hide_btn = hide_btn
|
||||
|
||||
self.main_label = main_label
|
||||
|
|
@ -990,11 +995,31 @@ class PublishOverlayFrame(QtWidgets.QFrame):
|
|||
self.refresh_btn = refresh_btn
|
||||
self.publish_btn = publish_btn
|
||||
|
||||
def set_instance(self, instance_name):
|
||||
self.instance_label.setText(instance_name)
|
||||
def _on_instance_change(self, context, instance):
|
||||
if instance is None:
|
||||
new_name = (
|
||||
context.data.get("label")
|
||||
or getattr(context, "label", None)
|
||||
or context.data.get("name")
|
||||
or "Context"
|
||||
)
|
||||
else:
|
||||
new_name = (
|
||||
instance.data.get("label")
|
||||
or getattr(instance, "label", None)
|
||||
or instance.data["name"]
|
||||
)
|
||||
|
||||
self.instance_label.setText(new_name)
|
||||
QtWidgets.QApplication.processEvents()
|
||||
|
||||
def _on_plugin_change(self, plugin):
|
||||
plugin_name = plugin.__name__
|
||||
if hasattr(plugin, "label") and plugin.label:
|
||||
plugin_name = plugin.label
|
||||
|
||||
def set_plugin(self, plugin_name):
|
||||
self.plugin_label.setText(plugin_name)
|
||||
QtWidgets.QApplication.processEvents()
|
||||
|
||||
def set_progress_range(self, max_value):
|
||||
self.progress_widget.setMaximum(max_value)
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class PublisherWindow(QtWidgets.QWidget):
|
|||
# TODO Title, Icon, Stylesheet
|
||||
main_frame = QtWidgets.QWidget(self)
|
||||
# Overlay MUST be created after Main to be painted on top of it
|
||||
overlay_frame = PublishOverlayFrame(self)
|
||||
overlay_frame = PublishOverlayFrame(controller, self)
|
||||
overlay_frame.setVisible(False)
|
||||
|
||||
# Header
|
||||
|
|
@ -161,8 +161,6 @@ class PublisherWindow(QtWidgets.QWidget):
|
|||
)
|
||||
overlay_frame.hide_requested.connect(self._on_overlay_hide_request)
|
||||
|
||||
controller.add_instance_change_callback(self._on_instance_change)
|
||||
controller.add_plugin_change_callback(self._on_plugin_change)
|
||||
controller.add_publish_stopped_callback(self._on_publish_stop)
|
||||
|
||||
self.main_frame = main_frame
|
||||
|
|
@ -302,11 +300,11 @@ class PublisherWindow(QtWidgets.QWidget):
|
|||
|
||||
def _on_validate_clicked(self):
|
||||
self._set_overlay_visibility(True)
|
||||
# self.controller.validate()
|
||||
self.controller.validate()
|
||||
|
||||
def _on_publish_clicked(self):
|
||||
self._set_overlay_visibility(True)
|
||||
# self.controller.publish()
|
||||
self.controller.publish()
|
||||
|
||||
def _refresh_instances(self):
|
||||
if self._refreshing_instances:
|
||||
|
|
@ -339,29 +337,6 @@ class PublisherWindow(QtWidgets.QWidget):
|
|||
|
||||
self.subset_attributes_widget.set_current_instances(instances)
|
||||
|
||||
def _on_plugin_change(self, plugin):
|
||||
plugin_name = plugin.__name__
|
||||
if hasattr(plugin, "label") and plugin.label:
|
||||
plugin_name = plugin.label
|
||||
self.overlay_frame.set_plugin(plugin_name)
|
||||
|
||||
def _on_instance_change(self, context, instance):
|
||||
if instance is None:
|
||||
new_name = (
|
||||
context.data.get("label")
|
||||
or getattr(context, "label", None)
|
||||
or context.data.get("name")
|
||||
or "Context"
|
||||
)
|
||||
else:
|
||||
new_name = (
|
||||
instance.data.get("label")
|
||||
or getattr(instance, "label", None)
|
||||
or instance.data["name"]
|
||||
)
|
||||
|
||||
self.overlay_frame.set_instance(new_name)
|
||||
|
||||
def _on_publish_stop(self):
|
||||
pass
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue