mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
show workfile just calls ensure visible on workfiles tool
This commit is contained in:
parent
55ff302d21
commit
3fac738361
2 changed files with 47 additions and 21 deletions
|
|
@ -60,31 +60,14 @@ class HostToolsHelper:
|
|||
|
||||
return self._workfiles_tool
|
||||
|
||||
def show_workfiles(self, parent=None, use_context=None, save=None):
|
||||
def show_workfiles(
|
||||
self, parent=None, use_context=None, save=None, on_top=None
|
||||
):
|
||||
"""Workfiles tool for changing context and saving workfiles."""
|
||||
if use_context is None:
|
||||
use_context = True
|
||||
|
||||
if save is None:
|
||||
save = True
|
||||
|
||||
with qt_app_context():
|
||||
workfiles_tool = self.get_workfiles_tool(parent)
|
||||
workfiles_tool.set_save_enabled(save)
|
||||
|
||||
if not workfiles_tool.isVisible():
|
||||
workfiles_tool.show()
|
||||
|
||||
if use_context:
|
||||
context = {
|
||||
"asset": legacy_io.Session["AVALON_ASSET"],
|
||||
"task": legacy_io.Session["AVALON_TASK"]
|
||||
}
|
||||
workfiles_tool.set_context(context)
|
||||
|
||||
# Pull window to the front.
|
||||
workfiles_tool.raise_()
|
||||
workfiles_tool.activateWindow()
|
||||
workfiles_tool.ensure_visible(use_context, save, on_top)
|
||||
|
||||
def get_loader_tool(self, parent):
|
||||
"""Create, cache and return loader tool window."""
|
||||
|
|
|
|||
|
|
@ -229,6 +229,49 @@ class Window(QtWidgets.QWidget):
|
|||
self._first_show = True
|
||||
self._context_to_set = None
|
||||
|
||||
def ensure_visible(
|
||||
self, use_context=None, save=None, on_top=None
|
||||
):
|
||||
if save is None:
|
||||
save = True
|
||||
|
||||
self.set_save_enabled(save)
|
||||
|
||||
if self.isVisible():
|
||||
use_context = False
|
||||
elif use_context is None:
|
||||
use_context = True
|
||||
|
||||
if on_top is None and self._first_show:
|
||||
on_top = self.parent() is None
|
||||
|
||||
window_flags = self.windowFlags()
|
||||
new_window_flags = window_flags
|
||||
if on_top is True:
|
||||
new_window_flags = window_flags | QtCore.Qt.WindowStaysOnTopHint
|
||||
elif on_top is False:
|
||||
new_window_flags = window_flags & ~QtCore.Qt.WindowStaysOnTopHint
|
||||
|
||||
if new_window_flags != window_flags:
|
||||
# Note this is not propagated after initialization of widget in
|
||||
# some Qt builds
|
||||
self.setWindowFlags(new_window_flags)
|
||||
self.show()
|
||||
|
||||
elif not self.isVisible():
|
||||
self.show()
|
||||
|
||||
if use_context is None or use_context is True:
|
||||
context = {
|
||||
"asset": legacy_io.Session["AVALON_ASSET"],
|
||||
"task": legacy_io.Session["AVALON_TASK"]
|
||||
}
|
||||
self.set_context(context)
|
||||
|
||||
# Pull window to the front.
|
||||
self.raise_()
|
||||
self.activateWindow()
|
||||
|
||||
@property
|
||||
def project_name(self):
|
||||
return legacy_io.Session["AVALON_PROJECT"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue