mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Merge pull request #4120 from pypeclub/feature/OP-4475_Publisher-Open-on-specific-tab
Publisher: Open on specific tab
This commit is contained in:
commit
f739809c71
7 changed files with 138 additions and 23 deletions
|
|
@ -674,9 +674,16 @@ class InstanceCardView(AbstractInstanceView):
|
|||
instances_by_group[group_name]
|
||||
)
|
||||
|
||||
self._update_ordered_group_nameS()
|
||||
self._update_ordered_group_names()
|
||||
|
||||
def _update_ordered_group_nameS(self):
|
||||
def has_items(self):
|
||||
if self._convertor_items_group is not None:
|
||||
return True
|
||||
if self._widgets_by_group:
|
||||
return True
|
||||
return False
|
||||
|
||||
def _update_ordered_group_names(self):
|
||||
ordered_group_names = [CONTEXT_GROUP]
|
||||
for idx in range(self._content_layout.count()):
|
||||
if idx > 0:
|
||||
|
|
|
|||
|
|
@ -912,6 +912,13 @@ class InstanceListView(AbstractInstanceView):
|
|||
if not self._instance_view.isExpanded(proxy_index):
|
||||
self._instance_view.expand(proxy_index)
|
||||
|
||||
def has_items(self):
|
||||
if self._convertor_group_widget is not None:
|
||||
return True
|
||||
if self._group_items:
|
||||
return True
|
||||
return False
|
||||
|
||||
def get_selected_items(self):
|
||||
"""Get selected instance ids and context selection.
|
||||
|
||||
|
|
|
|||
|
|
@ -205,6 +205,10 @@ class OverviewWidget(QtWidgets.QFrame):
|
|||
self._subset_views_widget.height()
|
||||
)
|
||||
|
||||
def has_items(self):
|
||||
view = self._subset_views_layout.currentWidget()
|
||||
return view.has_items()
|
||||
|
||||
def _on_create_clicked(self):
|
||||
"""Pass signal to parent widget which should care about changing state.
|
||||
|
||||
|
|
|
|||
|
|
@ -54,6 +54,9 @@ class PublisherTabsWidget(QtWidgets.QFrame):
|
|||
self._buttons_by_identifier = {}
|
||||
|
||||
def is_current_tab(self, identifier):
|
||||
if isinstance(identifier, int):
|
||||
identifier = self.get_tab_by_index(identifier)
|
||||
|
||||
if isinstance(identifier, PublisherTabBtn):
|
||||
identifier = identifier.identifier
|
||||
return self._current_identifier == identifier
|
||||
|
|
@ -68,7 +71,16 @@ class PublisherTabsWidget(QtWidgets.QFrame):
|
|||
self.set_current_tab(identifier)
|
||||
return button
|
||||
|
||||
def get_tab_by_index(self, index):
|
||||
if 0 >= index < self._btns_layout.count():
|
||||
item = self._btns_layout.itemAt(index)
|
||||
return item.widget()
|
||||
return None
|
||||
|
||||
def set_current_tab(self, identifier):
|
||||
if isinstance(identifier, int):
|
||||
identifier = self.get_tab_by_index(identifier)
|
||||
|
||||
if isinstance(identifier, PublisherTabBtn):
|
||||
identifier = identifier.identifier
|
||||
|
||||
|
|
|
|||
|
|
@ -306,6 +306,20 @@ class AbstractInstanceView(QtWidgets.QWidget):
|
|||
"{} Method 'refresh' is not implemented."
|
||||
).format(self.__class__.__name__))
|
||||
|
||||
def has_items(self):
|
||||
"""View has at least one item.
|
||||
|
||||
This is more a question for controller but is called from widget
|
||||
which should probably should not use controller.
|
||||
|
||||
Returns:
|
||||
bool: There is at least one instance or conversion item.
|
||||
"""
|
||||
|
||||
raise NotImplementedError((
|
||||
"{} Method 'has_items' is not implemented."
|
||||
).format(self.__class__.__name__))
|
||||
|
||||
def get_selected_items(self):
|
||||
"""Selected instances required for callbacks.
|
||||
|
||||
|
|
@ -579,6 +593,11 @@ class TasksCombobox(QtWidgets.QComboBox):
|
|||
|
||||
self._text = None
|
||||
|
||||
# Make sure combobox is extended horizontally
|
||||
size_policy = self.sizePolicy()
|
||||
size_policy.setHorizontalPolicy(size_policy.MinimumExpanding)
|
||||
self.setSizePolicy(size_policy)
|
||||
|
||||
def set_invalid_empty_task(self, invalid=True):
|
||||
self._proxy_model.set_filter_empty(invalid)
|
||||
if invalid:
|
||||
|
|
@ -1181,7 +1200,7 @@ class GlobalAttrsWidget(QtWidgets.QWidget):
|
|||
"""Set currently selected instances.
|
||||
|
||||
Args:
|
||||
instances(list<CreatedInstance>): List of selected instances.
|
||||
instances(List[CreatedInstance]): List of selected instances.
|
||||
Empty instances tells that nothing or context is selected.
|
||||
"""
|
||||
self._set_btns_visible(False)
|
||||
|
|
@ -1626,6 +1645,7 @@ class SubsetAttributesWidget(QtWidgets.QWidget):
|
|||
instances(List[CreatedInstance]): List of currently selected
|
||||
instances.
|
||||
context_selected(bool): Is context selected.
|
||||
convertor_identifiers(List[str]): Identifiers of convert items.
|
||||
"""
|
||||
|
||||
all_valid = True
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ class PublisherWindow(QtWidgets.QDialog):
|
|||
footer_layout.addWidget(footer_bottom_widget, 0)
|
||||
|
||||
# Content
|
||||
# - wrap stacked widget under one more widget to be able propagate
|
||||
# - wrap stacked widget under one more widget to be able to propagate
|
||||
# margins (QStackedLayout can't have margins)
|
||||
content_widget = QtWidgets.QWidget(under_publish_widget)
|
||||
|
||||
|
|
@ -267,6 +267,9 @@ class PublisherWindow(QtWidgets.QDialog):
|
|||
controller.event_system.add_callback(
|
||||
"publish.reset.finished", self._on_publish_reset
|
||||
)
|
||||
controller.event_system.add_callback(
|
||||
"controller.reset.finished", self._on_controller_reset
|
||||
)
|
||||
controller.event_system.add_callback(
|
||||
"publish.process.started", self._on_publish_start
|
||||
)
|
||||
|
|
@ -337,11 +340,13 @@ class PublisherWindow(QtWidgets.QDialog):
|
|||
self._controller = controller
|
||||
|
||||
self._first_show = True
|
||||
self._first_reset = True
|
||||
# This is a little bit confusing but 'reset_on_first_show' is too long
|
||||
# forin init
|
||||
# for init
|
||||
self._reset_on_first_show = reset_on_show
|
||||
self._reset_on_show = True
|
||||
self._publish_frame_visible = None
|
||||
self._tab_on_reset = None
|
||||
|
||||
self._error_messages_to_show = collections.deque()
|
||||
self._errors_dialog_message_timer = errors_dialog_message_timer
|
||||
|
|
@ -353,12 +358,21 @@ class PublisherWindow(QtWidgets.QDialog):
|
|||
|
||||
self._show_timer = show_timer
|
||||
self._show_counter = 0
|
||||
self._window_is_visible = False
|
||||
|
||||
@property
|
||||
def controller(self):
|
||||
return self._controller
|
||||
|
||||
def make_sure_is_visible(self):
|
||||
if self._window_is_visible:
|
||||
self.setWindowState(QtCore.Qt.ActiveWindow)
|
||||
|
||||
else:
|
||||
self.show()
|
||||
|
||||
def showEvent(self, event):
|
||||
self._window_is_visible = True
|
||||
super(PublisherWindow, self).showEvent(event)
|
||||
if self._first_show:
|
||||
self._first_show = False
|
||||
|
|
@ -372,6 +386,7 @@ class PublisherWindow(QtWidgets.QDialog):
|
|||
self._update_create_overlay_size()
|
||||
|
||||
def closeEvent(self, event):
|
||||
self._window_is_visible = False
|
||||
self._uninstall_app_event_listener()
|
||||
self.save_changes()
|
||||
self._reset_on_show = True
|
||||
|
|
@ -432,7 +447,7 @@ class PublisherWindow(QtWidgets.QDialog):
|
|||
|
||||
self._update_create_overlay_size()
|
||||
self._update_create_overlay_visibility()
|
||||
if self._is_current_tab("create"):
|
||||
if self._is_on_create_tab():
|
||||
self._install_app_event_listener()
|
||||
|
||||
# Reset if requested
|
||||
|
|
@ -449,8 +464,21 @@ class PublisherWindow(QtWidgets.QDialog):
|
|||
def set_context_label(self, label):
|
||||
self._context_label.setText(label)
|
||||
|
||||
def set_tab_on_reset(self, tab):
|
||||
"""Define tab that will be selected on window show.
|
||||
|
||||
This is single use method, when publisher window is showed the value is
|
||||
unset and not used on next show.
|
||||
|
||||
Args:
|
||||
tab (Union[int, Literal[create, publish, details, report]]: Index
|
||||
or name of tab which will be selected on show (after reset).
|
||||
"""
|
||||
|
||||
self._tab_on_reset = tab
|
||||
|
||||
def _update_publish_details_widget(self, force=False):
|
||||
if not force and not self._is_current_tab("details"):
|
||||
if not force and not self._is_on_details_tab():
|
||||
return
|
||||
|
||||
report_data = self.controller.get_publish_report()
|
||||
|
|
@ -524,6 +552,11 @@ class PublisherWindow(QtWidgets.QDialog):
|
|||
def _set_current_tab(self, identifier):
|
||||
self._tabs_widget.set_current_tab(identifier)
|
||||
|
||||
def set_current_tab(self, tab):
|
||||
self._set_current_tab(tab)
|
||||
if not self._window_is_visible:
|
||||
self.set_tab_on_reset(tab)
|
||||
|
||||
def _is_current_tab(self, identifier):
|
||||
return self._tabs_widget.is_current_tab(identifier)
|
||||
|
||||
|
|
@ -539,6 +572,18 @@ class PublisherWindow(QtWidgets.QDialog):
|
|||
def _go_to_report_tab(self):
|
||||
self._set_current_tab("report")
|
||||
|
||||
def _is_on_create_tab(self):
|
||||
return self._is_current_tab("create")
|
||||
|
||||
def _is_on_publish_tab(self):
|
||||
return self._is_current_tab("publish")
|
||||
|
||||
def _is_on_details_tab(self):
|
||||
return self._is_current_tab("details")
|
||||
|
||||
def _is_on_report_tab(self):
|
||||
return self._is_current_tab("report")
|
||||
|
||||
def _set_publish_overlay_visibility(self, visible):
|
||||
if visible:
|
||||
widget = self._publish_overlay
|
||||
|
|
@ -589,11 +634,33 @@ class PublisherWindow(QtWidgets.QDialog):
|
|||
self._set_publish_visibility(False)
|
||||
self._set_footer_enabled(False)
|
||||
self._update_publish_details_widget()
|
||||
if (
|
||||
not self._is_current_tab("create")
|
||||
and not self._is_current_tab("publish")
|
||||
|
||||
def _on_controller_reset(self):
|
||||
self._first_reset, first_reset = False, self._first_reset
|
||||
if self._tab_on_reset is not None:
|
||||
self._tab_on_reset, new_tab = None, self._tab_on_reset
|
||||
self._set_current_tab(new_tab)
|
||||
return
|
||||
|
||||
# On first reset change tab based on available items
|
||||
# - if there is at least one instance the tab is changed to 'publish'
|
||||
# otherwise 'create' is used
|
||||
# - this happens only on first show
|
||||
if first_reset:
|
||||
if self._overview_widget.has_items():
|
||||
self._go_to_publish_tab()
|
||||
else:
|
||||
self._go_to_create_tab()
|
||||
|
||||
elif (
|
||||
not self._is_on_create_tab()
|
||||
and not self._is_on_publish_tab()
|
||||
):
|
||||
self._set_current_tab("publish")
|
||||
# If current tab is not 'Create' or 'Publish' go to 'Publish'
|
||||
# - this can happen when publishing started and was reset
|
||||
# at that moment it doesn't make sense to stay at publish
|
||||
# specific tabs.
|
||||
self._go_to_publish_tab()
|
||||
|
||||
def _on_publish_start(self):
|
||||
self._create_tab.setEnabled(False)
|
||||
|
|
@ -609,8 +676,8 @@ class PublisherWindow(QtWidgets.QDialog):
|
|||
|
||||
self._publish_details_widget.close_details_popup()
|
||||
|
||||
if self._is_current_tab(self._create_tab):
|
||||
self._set_current_tab("publish")
|
||||
if self._is_on_create_tab():
|
||||
self._go_to_publish_tab()
|
||||
|
||||
def _on_publish_validated_change(self, event):
|
||||
if event["value"]:
|
||||
|
|
@ -623,7 +690,7 @@ class PublisherWindow(QtWidgets.QDialog):
|
|||
publish_has_crashed = self._controller.publish_has_crashed
|
||||
validate_enabled = not publish_has_crashed
|
||||
publish_enabled = not publish_has_crashed
|
||||
if self._is_current_tab("publish"):
|
||||
if self._is_on_publish_tab():
|
||||
self._go_to_report_tab()
|
||||
|
||||
if validate_enabled:
|
||||
|
|
|
|||
|
|
@ -285,14 +285,12 @@ class HostToolsHelper:
|
|||
|
||||
return self._publisher_tool
|
||||
|
||||
def show_publisher_tool(self, parent=None, controller=None):
|
||||
def show_publisher_tool(self, parent=None, controller=None, tab=None):
|
||||
with qt_app_context():
|
||||
dialog = self.get_publisher_tool(parent, controller)
|
||||
|
||||
dialog.show()
|
||||
dialog.raise_()
|
||||
dialog.activateWindow()
|
||||
dialog.showNormal()
|
||||
window = self.get_publisher_tool(parent, controller)
|
||||
if tab:
|
||||
window.set_current_tab(tab)
|
||||
window.make_sure_is_visible()
|
||||
|
||||
def get_tool_by_name(self, tool_name, parent=None, *args, **kwargs):
|
||||
"""Show tool by it's name.
|
||||
|
|
@ -446,8 +444,8 @@ def show_publish(parent=None):
|
|||
_SingletonPoint.show_tool_by_name("publish", parent)
|
||||
|
||||
|
||||
def show_publisher(parent=None):
|
||||
_SingletonPoint.show_tool_by_name("publisher", parent)
|
||||
def show_publisher(parent=None, **kwargs):
|
||||
_SingletonPoint.show_tool_by_name("publisher", parent, **kwargs)
|
||||
|
||||
|
||||
def show_experimental_tools_dialog(parent=None):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue