mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
basic implementation of setting filters in launcher
This commit is contained in:
parent
37bf4a28c7
commit
d7b5e06077
3 changed files with 77 additions and 19 deletions
|
|
@ -160,8 +160,8 @@ class AbstractLauncherFrontEnd(AbstractLauncherCommon):
|
||||||
Returns:
|
Returns:
|
||||||
list[FolderItem]: Minimum possible information needed
|
list[FolderItem]: Minimum possible information needed
|
||||||
for visualisation of folder hierarchy.
|
for visualisation of folder hierarchy.
|
||||||
"""
|
|
||||||
|
|
||||||
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
|
|
@ -180,8 +180,8 @@ class AbstractLauncherFrontEnd(AbstractLauncherCommon):
|
||||||
Returns:
|
Returns:
|
||||||
list[TaskItem]: Minimum possible information needed
|
list[TaskItem]: Minimum possible information needed
|
||||||
for visualisation of tasks.
|
for visualisation of tasks.
|
||||||
"""
|
|
||||||
|
|
||||||
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
|
|
@ -190,8 +190,8 @@ class AbstractLauncherFrontEnd(AbstractLauncherCommon):
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Union[str, None]: Selected project name.
|
Union[str, None]: Selected project name.
|
||||||
"""
|
|
||||||
|
|
||||||
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
|
|
@ -200,8 +200,8 @@ class AbstractLauncherFrontEnd(AbstractLauncherCommon):
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Union[str, None]: Selected folder id.
|
Union[str, None]: Selected folder id.
|
||||||
"""
|
|
||||||
|
|
||||||
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
|
|
@ -210,8 +210,8 @@ class AbstractLauncherFrontEnd(AbstractLauncherCommon):
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Union[str, None]: Selected task id.
|
Union[str, None]: Selected task id.
|
||||||
"""
|
|
||||||
|
|
||||||
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
|
|
@ -220,8 +220,8 @@ class AbstractLauncherFrontEnd(AbstractLauncherCommon):
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Union[str, None]: Selected task name.
|
Union[str, None]: Selected task name.
|
||||||
"""
|
|
||||||
|
|
||||||
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
|
|
@ -238,8 +238,8 @@ class AbstractLauncherFrontEnd(AbstractLauncherCommon):
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
dict[str, Union[str, None]]: Selected context.
|
dict[str, Union[str, None]]: Selected context.
|
||||||
"""
|
|
||||||
|
|
||||||
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
|
|
@ -249,8 +249,8 @@ class AbstractLauncherFrontEnd(AbstractLauncherCommon):
|
||||||
Args:
|
Args:
|
||||||
project_name (Union[str, None]): Project nameor None if no project
|
project_name (Union[str, None]): Project nameor None if no project
|
||||||
is selected.
|
is selected.
|
||||||
"""
|
|
||||||
|
|
||||||
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
|
|
@ -260,8 +260,8 @@ class AbstractLauncherFrontEnd(AbstractLauncherCommon):
|
||||||
Args:
|
Args:
|
||||||
folder_id (Union[str, None]): Folder id or None if no folder
|
folder_id (Union[str, None]): Folder id or None if no folder
|
||||||
is selected.
|
is selected.
|
||||||
"""
|
|
||||||
|
|
||||||
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
|
|
@ -273,8 +273,8 @@ class AbstractLauncherFrontEnd(AbstractLauncherCommon):
|
||||||
is selected.
|
is selected.
|
||||||
task_name (Union[str, None]): Task name or None if no task
|
task_name (Union[str, None]): Task name or None if no task
|
||||||
is selected.
|
is selected.
|
||||||
"""
|
|
||||||
|
|
||||||
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Actions
|
# Actions
|
||||||
|
|
@ -290,8 +290,8 @@ class AbstractLauncherFrontEnd(AbstractLauncherCommon):
|
||||||
Returns:
|
Returns:
|
||||||
list[ActionItem]: List of action items that should be shown
|
list[ActionItem]: List of action items that should be shown
|
||||||
for given context.
|
for given context.
|
||||||
"""
|
|
||||||
|
|
||||||
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
|
|
@ -303,8 +303,8 @@ class AbstractLauncherFrontEnd(AbstractLauncherCommon):
|
||||||
folder_id (Union[str, None]): Folder id.
|
folder_id (Union[str, None]): Folder id.
|
||||||
task_id (Union[str, None]): Task id.
|
task_id (Union[str, None]): Task id.
|
||||||
action_id (str): Action identifier.
|
action_id (str): Action identifier.
|
||||||
"""
|
|
||||||
|
|
||||||
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
|
|
@ -317,10 +317,10 @@ class AbstractLauncherFrontEnd(AbstractLauncherCommon):
|
||||||
project_name (Union[str, None]): Project name.
|
project_name (Union[str, None]): Project name.
|
||||||
folder_id (Union[str, None]): Folder id.
|
folder_id (Union[str, None]): Folder id.
|
||||||
task_id (Union[str, None]): Task id.
|
task_id (Union[str, None]): Task id.
|
||||||
action_id (Iterable[str]): Action identifiers.
|
action_ids (Iterable[str]): Action identifiers.
|
||||||
enabled (bool): New value of force not open workfile.
|
enabled (bool): New value of force not open workfile.
|
||||||
"""
|
|
||||||
|
|
||||||
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
|
|
@ -340,5 +340,17 @@ class AbstractLauncherFrontEnd(AbstractLauncherCommon):
|
||||||
Triggers 'controller.refresh.actions.started' event at the beginning
|
Triggers 'controller.refresh.actions.started' event at the beginning
|
||||||
and 'controller.refresh.actions.finished' at the end.
|
and 'controller.refresh.actions.finished' at the end.
|
||||||
"""
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def get_my_tasks_entity_ids(self, project_name: str):
|
||||||
|
"""Get entity ids for my tasks.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
project_name (str): Project name.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict[str, Union[list[str]]]: Folder and task ids.
|
||||||
|
|
||||||
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
from ayon_core.lib import Logger
|
from ayon_core.lib import Logger, get_ayon_username
|
||||||
from ayon_core.lib.events import QueuedEventSystem
|
from ayon_core.lib.events import QueuedEventSystem
|
||||||
from ayon_core.settings import get_project_settings
|
from ayon_core.settings import get_project_settings
|
||||||
from ayon_core.tools.common_models import ProjectsModel, HierarchyModel
|
from ayon_core.tools.common_models import ProjectsModel, HierarchyModel
|
||||||
|
|
@ -6,6 +6,8 @@ from ayon_core.tools.common_models import ProjectsModel, HierarchyModel
|
||||||
from .abstract import AbstractLauncherFrontEnd, AbstractLauncherBackend
|
from .abstract import AbstractLauncherFrontEnd, AbstractLauncherBackend
|
||||||
from .models import LauncherSelectionModel, ActionsModel
|
from .models import LauncherSelectionModel, ActionsModel
|
||||||
|
|
||||||
|
NOT_SET = object()
|
||||||
|
|
||||||
|
|
||||||
class BaseLauncherController(
|
class BaseLauncherController(
|
||||||
AbstractLauncherFrontEnd, AbstractLauncherBackend
|
AbstractLauncherFrontEnd, AbstractLauncherBackend
|
||||||
|
|
@ -15,6 +17,8 @@ class BaseLauncherController(
|
||||||
self._event_system = None
|
self._event_system = None
|
||||||
self._log = None
|
self._log = None
|
||||||
|
|
||||||
|
self._username = NOT_SET
|
||||||
|
|
||||||
self._selection_model = LauncherSelectionModel(self)
|
self._selection_model = LauncherSelectionModel(self)
|
||||||
self._projects_model = ProjectsModel(self)
|
self._projects_model = ProjectsModel(self)
|
||||||
self._hierarchy_model = HierarchyModel(self)
|
self._hierarchy_model = HierarchyModel(self)
|
||||||
|
|
@ -168,5 +172,19 @@ class BaseLauncherController(
|
||||||
|
|
||||||
self._emit_event("controller.refresh.actions.finished")
|
self._emit_event("controller.refresh.actions.finished")
|
||||||
|
|
||||||
|
def get_my_tasks_entity_ids(self, project_name: str):
|
||||||
|
username = self._get_my_username()
|
||||||
|
assignees = []
|
||||||
|
if username:
|
||||||
|
assignees.append(username)
|
||||||
|
return self._hierarchy_model.get_entity_ids_for_assignees(
|
||||||
|
project_name, assignees
|
||||||
|
)
|
||||||
|
|
||||||
|
def _get_my_username(self):
|
||||||
|
if self._username is NOT_SET:
|
||||||
|
self._username = get_ayon_username()
|
||||||
|
return self._username
|
||||||
|
|
||||||
def _emit_event(self, topic, data=None):
|
def _emit_event(self, topic, data=None):
|
||||||
self.emit_event(topic, data, "controller")
|
self.emit_event(topic, data, "controller")
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,13 @@ from ayon_core.tools.utils import (
|
||||||
ProjectsCombobox,
|
ProjectsCombobox,
|
||||||
FoldersWidget,
|
FoldersWidget,
|
||||||
TasksWidget,
|
TasksWidget,
|
||||||
|
NiceCheckbox,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class HierarchyPage(QtWidgets.QWidget):
|
class HierarchyPage(QtWidgets.QWidget):
|
||||||
def __init__(self, controller, parent):
|
def __init__(self, controller, parent):
|
||||||
super(HierarchyPage, self).__init__(parent)
|
super().__init__(parent)
|
||||||
|
|
||||||
# Header
|
# Header
|
||||||
header_widget = QtWidgets.QWidget(self)
|
header_widget = QtWidgets.QWidget(self)
|
||||||
|
|
@ -46,14 +47,23 @@ class HierarchyPage(QtWidgets.QWidget):
|
||||||
# - Folders widget with filter
|
# - Folders widget with filter
|
||||||
folders_wrapper = QtWidgets.QWidget(content_body)
|
folders_wrapper = QtWidgets.QWidget(content_body)
|
||||||
|
|
||||||
folders_filter_text = PlaceholderLineEdit(folders_wrapper)
|
filters_widget = QtWidgets.QWidget(folders_wrapper)
|
||||||
|
|
||||||
|
folders_filter_text = PlaceholderLineEdit(filters_widget)
|
||||||
folders_filter_text.setPlaceholderText("Filter folders...")
|
folders_filter_text.setPlaceholderText("Filter folders...")
|
||||||
|
|
||||||
|
my_tasks_checkbox = NiceCheckbox(filters_widget)
|
||||||
|
|
||||||
|
filters_layout = QtWidgets.QHBoxLayout(filters_widget)
|
||||||
|
filters_layout.setContentsMargins(0, 0, 0, 0)
|
||||||
|
filters_layout.addWidget(folders_filter_text, 1)
|
||||||
|
filters_layout.addWidget(my_tasks_checkbox, 0)
|
||||||
|
|
||||||
folders_widget = FoldersWidget(controller, folders_wrapper)
|
folders_widget = FoldersWidget(controller, folders_wrapper)
|
||||||
|
|
||||||
folders_wrapper_layout = QtWidgets.QVBoxLayout(folders_wrapper)
|
folders_wrapper_layout = QtWidgets.QVBoxLayout(folders_wrapper)
|
||||||
folders_wrapper_layout.setContentsMargins(0, 0, 0, 0)
|
folders_wrapper_layout.setContentsMargins(0, 0, 0, 0)
|
||||||
folders_wrapper_layout.addWidget(folders_filter_text, 0)
|
folders_wrapper_layout.addWidget(filters_widget, 0)
|
||||||
folders_wrapper_layout.addWidget(folders_widget, 1)
|
folders_wrapper_layout.addWidget(folders_widget, 1)
|
||||||
|
|
||||||
# - Tasks widget
|
# - Tasks widget
|
||||||
|
|
@ -72,6 +82,9 @@ class HierarchyPage(QtWidgets.QWidget):
|
||||||
btn_back.clicked.connect(self._on_back_clicked)
|
btn_back.clicked.connect(self._on_back_clicked)
|
||||||
refresh_btn.clicked.connect(self._on_refresh_clicked)
|
refresh_btn.clicked.connect(self._on_refresh_clicked)
|
||||||
folders_filter_text.textChanged.connect(self._on_filter_text_changed)
|
folders_filter_text.textChanged.connect(self._on_filter_text_changed)
|
||||||
|
my_tasks_checkbox.stateChanged.connect(
|
||||||
|
self._on_my_tasks_checkbox_state_changed
|
||||||
|
)
|
||||||
|
|
||||||
self._is_visible = False
|
self._is_visible = False
|
||||||
self._controller = controller
|
self._controller = controller
|
||||||
|
|
@ -81,6 +94,8 @@ class HierarchyPage(QtWidgets.QWidget):
|
||||||
self._folders_widget = folders_widget
|
self._folders_widget = folders_widget
|
||||||
self._tasks_widget = tasks_widget
|
self._tasks_widget = tasks_widget
|
||||||
|
|
||||||
|
self._project_name = None
|
||||||
|
|
||||||
# Post init
|
# Post init
|
||||||
projects_combobox.set_listen_to_selection_change(self._is_visible)
|
projects_combobox.set_listen_to_selection_change(self._is_visible)
|
||||||
|
|
||||||
|
|
@ -91,6 +106,7 @@ class HierarchyPage(QtWidgets.QWidget):
|
||||||
self._projects_combobox.set_listen_to_selection_change(visible)
|
self._projects_combobox.set_listen_to_selection_change(visible)
|
||||||
if visible and project_name:
|
if visible and project_name:
|
||||||
self._projects_combobox.set_selection(project_name)
|
self._projects_combobox.set_selection(project_name)
|
||||||
|
self._project_name = project_name
|
||||||
|
|
||||||
def refresh(self):
|
def refresh(self):
|
||||||
self._folders_widget.refresh()
|
self._folders_widget.refresh()
|
||||||
|
|
@ -104,3 +120,15 @@ class HierarchyPage(QtWidgets.QWidget):
|
||||||
|
|
||||||
def _on_filter_text_changed(self, text):
|
def _on_filter_text_changed(self, text):
|
||||||
self._folders_widget.set_name_filter(text)
|
self._folders_widget.set_name_filter(text)
|
||||||
|
|
||||||
|
def _on_my_tasks_checkbox_state_changed(self, state):
|
||||||
|
folder_ids = None
|
||||||
|
task_ids = None
|
||||||
|
if state == QtCore.Qt.Checked:
|
||||||
|
entity_ids = self._controller.get_my_tasks_entity_ids(
|
||||||
|
self._project_name
|
||||||
|
)
|
||||||
|
folder_ids = entity_ids["folder_ids"]
|
||||||
|
task_ids = entity_ids["task_ids"]
|
||||||
|
self._folders_widget.set_folder_ids_filter(folder_ids)
|
||||||
|
self._tasks_widget.set_task_ids_filter(task_ids)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue