mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
using custom dbconnector instead of avalon.io
This commit is contained in:
parent
62160ab368
commit
2bae09f4e0
4 changed files with 63 additions and 46 deletions
|
|
@ -2,7 +2,9 @@ import sys
|
|||
import copy
|
||||
|
||||
from avalon.vendor.Qt import QtWidgets, QtCore, QtGui
|
||||
from avalon import io, style
|
||||
from avalon import style
|
||||
|
||||
from pype.modules.ftrack.lib.io_nonsingleton import DbConnector
|
||||
|
||||
from avalon.tools import lib as tools_lib
|
||||
from avalon.tools.widgets import AssetWidget
|
||||
|
|
@ -86,17 +88,19 @@ class ProjectsPanel(QtWidgets.QWidget):
|
|||
|
||||
project_clicked = QtCore.Signal(str)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
def __init__(self, dbcon, parent=None):
|
||||
super(ProjectsPanel, self).__init__(parent=parent)
|
||||
|
||||
layout = QtWidgets.QVBoxLayout(self)
|
||||
|
||||
io.install()
|
||||
self.dbcon = dbcon
|
||||
self.dbcon.install()
|
||||
|
||||
view = IconListView(parent=self)
|
||||
view.setSelectionMode(QtWidgets.QListView.NoSelection)
|
||||
flick = FlickCharm(parent=self)
|
||||
flick.activateOn(view)
|
||||
model = ProjectModel()
|
||||
model = ProjectModel(self.dbcon)
|
||||
model.hide_invisible = True
|
||||
model.refresh()
|
||||
view.setModel(model)
|
||||
|
|
@ -118,31 +122,35 @@ class AssetsPanel(QtWidgets.QWidget):
|
|||
"""Assets page"""
|
||||
back_clicked = QtCore.Signal()
|
||||
|
||||
def __init__(self, parent=None):
|
||||
def __init__(self, dbcon, parent=None):
|
||||
super(AssetsPanel, self).__init__(parent=parent)
|
||||
|
||||
self.dbcon = dbcon
|
||||
|
||||
# project bar
|
||||
project_bar_widget = QtWidgets.QWidget()
|
||||
project_bar_widget = QtWidgets.QWidget(self)
|
||||
|
||||
layout = QtWidgets.QHBoxLayout(project_bar_widget)
|
||||
layout.setSpacing(4)
|
||||
|
||||
btn_back_icon = qtawesome.icon("fa.angle-left", color="white")
|
||||
btn_back = QtWidgets.QPushButton()
|
||||
btn_back = QtWidgets.QPushButton(project_bar_widget)
|
||||
btn_back.setIcon(btn_back_icon)
|
||||
btn_back.setFixedWidth(23)
|
||||
btn_back.setFixedHeight(23)
|
||||
|
||||
project_bar = ProjectBar()
|
||||
project_bar = ProjectBar(self.dbcon, project_bar_widget)
|
||||
|
||||
layout.addWidget(btn_back)
|
||||
layout.addWidget(project_bar)
|
||||
|
||||
# assets
|
||||
assets_proxy_widgets = QtWidgets.QWidget()
|
||||
assets_proxy_widgets = QtWidgets.QWidget(self)
|
||||
assets_proxy_widgets.setContentsMargins(0, 0, 0, 0)
|
||||
assets_layout = QtWidgets.QVBoxLayout(assets_proxy_widgets)
|
||||
assets_widget = AssetWidget()
|
||||
assets_widget = AssetWidget(
|
||||
dbcon=self.dbcon, parent=assets_proxy_widgets
|
||||
)
|
||||
|
||||
# Make assets view flickable
|
||||
flick = FlickCharm(parent=self)
|
||||
|
|
@ -153,7 +161,7 @@ class AssetsPanel(QtWidgets.QWidget):
|
|||
assets_layout.addWidget(assets_widget)
|
||||
|
||||
# tasks
|
||||
tasks_widget = TasksWidget()
|
||||
tasks_widget = TasksWidget(self.dbcon, self)
|
||||
body = QtWidgets.QSplitter()
|
||||
body.setContentsMargins(0, 0, 0, 0)
|
||||
body.setSizePolicy(
|
||||
|
|
@ -197,7 +205,7 @@ class AssetsPanel(QtWidgets.QWidget):
|
|||
|
||||
def on_project_changed(self):
|
||||
project_name = self.project_bar.get_current_project()
|
||||
io.Session["AVALON_PROJECT"] = project_name
|
||||
self.dbcon.Session["AVALON_PROJECT"] = project_name
|
||||
self.assets_widget.refresh()
|
||||
|
||||
# Force asset change callback to ensure tasks are correctly reset
|
||||
|
|
@ -220,7 +228,7 @@ class AssetsPanel(QtWidgets.QWidget):
|
|||
|
||||
def get_current_session(self):
|
||||
asset_doc = self.assets_widget.get_active_asset_document()
|
||||
session = copy.deepcopy(io.Session)
|
||||
session = copy.deepcopy(self.dbcon.Session)
|
||||
|
||||
# Clear some values that we are about to collect if available
|
||||
session.pop("AVALON_SILO", None)
|
||||
|
|
@ -242,6 +250,8 @@ class Window(QtWidgets.QDialog):
|
|||
def __init__(self, parent=None):
|
||||
super(Window, self).__init__(parent)
|
||||
|
||||
self.dbcon = DbConnector()
|
||||
|
||||
self.setWindowTitle("Launcher")
|
||||
self.setFocusPolicy(QtCore.Qt.StrongFocus)
|
||||
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
|
||||
|
|
@ -251,15 +261,15 @@ class Window(QtWidgets.QDialog):
|
|||
self.windowFlags() | QtCore.Qt.WindowMinimizeButtonHint
|
||||
)
|
||||
|
||||
project_panel = ProjectsPanel()
|
||||
asset_panel = AssetsPanel()
|
||||
project_panel = ProjectsPanel(self.dbcon)
|
||||
asset_panel = AssetsPanel(self.dbcon)
|
||||
|
||||
page_slider = SlidePageWidget()
|
||||
page_slider.addWidget(project_panel)
|
||||
page_slider.addWidget(asset_panel)
|
||||
|
||||
# actions
|
||||
actions_bar = ActionBar()
|
||||
actions_bar = ActionBar(self.dbcon, self)
|
||||
|
||||
# statusbar
|
||||
statusbar = QtWidgets.QWidget()
|
||||
|
|
@ -356,7 +366,7 @@ class Window(QtWidgets.QDialog):
|
|||
|
||||
def on_project_changed(self):
|
||||
project_name = self.asset_panel.project_bar.get_current_project()
|
||||
io.Session["AVALON_PROJECT"] = project_name
|
||||
self.dbcon.Session["AVALON_PROJECT"] = project_name
|
||||
|
||||
# Update the Action plug-ins available for the current project
|
||||
self.actions_bar.model.discover()
|
||||
|
|
@ -368,7 +378,7 @@ class Window(QtWidgets.QDialog):
|
|||
tools_lib.schedule(self.on_refresh_actions, delay)
|
||||
|
||||
def on_project_clicked(self, project_name):
|
||||
io.Session["AVALON_PROJECT"] = project_name
|
||||
self.dbcon.Session["AVALON_PROJECT"] = project_name
|
||||
# Refresh projects
|
||||
self.asset_panel.project_bar.refresh()
|
||||
self.asset_panel.set_project(project_name)
|
||||
|
|
@ -407,7 +417,7 @@ class Window(QtWidgets.QDialog):
|
|||
# Assets page
|
||||
return self.asset_panel.get_current_session()
|
||||
|
||||
session = copy.deepcopy(io.Session)
|
||||
session = copy.deepcopy(self.dbcon.Session)
|
||||
|
||||
# Remove some potential invalid session values
|
||||
# that we know are not set when not browsing in
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ provides a bridge between the file-based project inventory and configuration.
|
|||
|
||||
import os
|
||||
from Qt import QtGui
|
||||
from avalon import io, lib, pipeline
|
||||
from avalon import lib, pipeline
|
||||
from avalon.vendor import qtawesome
|
||||
from pype.api import resources
|
||||
|
||||
|
|
@ -24,12 +24,6 @@ ICON_CACHE = {}
|
|||
NOT_FOUND = type("NotFound", (object, ), {})
|
||||
|
||||
|
||||
def list_project_tasks():
|
||||
"""List the project task types available in the current project"""
|
||||
project = io.find_one({"type": "project"})
|
||||
return [task["name"] for task in project["config"]["tasks"]]
|
||||
|
||||
|
||||
def get_application_actions(project):
|
||||
"""Define dynamic Application classes for project using `.toml` files
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import collections
|
|||
from . import lib
|
||||
from Qt import QtCore, QtGui
|
||||
from avalon.vendor import qtawesome
|
||||
from avalon import io, style, api
|
||||
from avalon import style, api
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -13,8 +13,10 @@ log = logging.getLogger(__name__)
|
|||
class TaskModel(QtGui.QStandardItemModel):
|
||||
"""A model listing the tasks combined for a list of assets"""
|
||||
|
||||
def __init__(self, parent=None):
|
||||
def __init__(self, dbcon, parent=None):
|
||||
super(TaskModel, self).__init__(parent=parent)
|
||||
self.dbcon = dbcon
|
||||
|
||||
self._num_assets = 0
|
||||
|
||||
self.default_icon = qtawesome.icon(
|
||||
|
|
@ -29,11 +31,11 @@ class TaskModel(QtGui.QStandardItemModel):
|
|||
self._get_task_icons()
|
||||
|
||||
def _get_task_icons(self):
|
||||
if io.Session.get("AVALON_PROJECT") is None:
|
||||
if not self.dbcon.Session.get("AVALON_PROJECT"):
|
||||
return
|
||||
|
||||
# Get the project configured icons from database
|
||||
project = io.find_one({"type": "project"})
|
||||
project = self.dbcon.find_one({"type": "project"})
|
||||
for task in project["config"].get("tasks") or []:
|
||||
icon_name = task.get("icon")
|
||||
if icon_name:
|
||||
|
|
@ -52,7 +54,7 @@ class TaskModel(QtGui.QStandardItemModel):
|
|||
|
||||
if asset_docs is None and asset_ids is not None:
|
||||
# find assets in db by query
|
||||
asset_docs = list(io.find({
|
||||
asset_docs = list(self.dbcon.find({
|
||||
"type": "asset",
|
||||
"_id": {"$in": asset_ids}
|
||||
}))
|
||||
|
|
@ -108,8 +110,10 @@ class ActionModel(QtGui.QStandardItemModel):
|
|||
ACTION_ROLE = QtCore.Qt.UserRole
|
||||
GROUP_ROLE = QtCore.Qt.UserRole + 1
|
||||
|
||||
def __init__(self, parent=None):
|
||||
def __init__(self, dbcon, parent=None):
|
||||
super(ActionModel, self).__init__(parent=parent)
|
||||
self.dbcon = dbcon
|
||||
|
||||
self._session = {}
|
||||
self._groups = {}
|
||||
self.default_icon = qtawesome.icon("fa.cube", color="white")
|
||||
|
|
@ -120,7 +124,7 @@ class ActionModel(QtGui.QStandardItemModel):
|
|||
|
||||
def discover(self):
|
||||
"""Set up Actions cache. Run this for each new project."""
|
||||
if not io.Session.get("AVALON_PROJECT"):
|
||||
if not self.dbcon.Session.get("AVALON_PROJECT"):
|
||||
self._registered_actions = list()
|
||||
return
|
||||
|
||||
|
|
@ -128,7 +132,7 @@ class ActionModel(QtGui.QStandardItemModel):
|
|||
actions = api.discover(api.Action)
|
||||
|
||||
# Get available project actions and the application actions
|
||||
project_doc = io.find_one({"type": "project"})
|
||||
project_doc = self.dbcon.find_one({"type": "project"})
|
||||
app_actions = lib.get_application_actions(project_doc)
|
||||
actions.extend(app_actions)
|
||||
|
||||
|
|
@ -233,9 +237,11 @@ class ActionModel(QtGui.QStandardItemModel):
|
|||
class ProjectModel(QtGui.QStandardItemModel):
|
||||
"""List of projects"""
|
||||
|
||||
def __init__(self, parent=None):
|
||||
def __init__(self, dbcon, parent=None):
|
||||
super(ProjectModel, self).__init__(parent=parent)
|
||||
|
||||
self.dbcon = dbcon
|
||||
|
||||
self.hide_invisible = False
|
||||
self.project_icon = qtawesome.icon("fa.map", color="white")
|
||||
|
||||
|
|
@ -251,7 +257,9 @@ class ProjectModel(QtGui.QStandardItemModel):
|
|||
|
||||
def get_projects(self):
|
||||
project_docs = []
|
||||
for project_doc in sorted(io.projects(), key=lambda x: x["name"]):
|
||||
for project_doc in sorted(
|
||||
self.dbcon.projects(), key=lambda x: x["name"]
|
||||
):
|
||||
if (
|
||||
self.hide_invisible
|
||||
and not project_doc["data"].get("visible", True)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import copy
|
||||
from Qt import QtWidgets, QtCore, QtGui
|
||||
from avalon.vendor import qtawesome
|
||||
from avalon import io
|
||||
|
||||
from .delegates import ActionDelegate
|
||||
from .models import TaskModel, ActionModel, ProjectModel
|
||||
|
|
@ -11,10 +10,12 @@ from .flickcharm import FlickCharm
|
|||
class ProjectBar(QtWidgets.QWidget):
|
||||
project_changed = QtCore.Signal(int)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
def __init__(self, dbcon, parent=None):
|
||||
super(ProjectBar, self).__init__(parent)
|
||||
|
||||
self.model = ProjectModel()
|
||||
self.dbcon = dbcon
|
||||
|
||||
self.model = ProjectModel(self.dbcon)
|
||||
self.model.hide_invisible = True
|
||||
|
||||
self.project_combobox = QtWidgets.QComboBox()
|
||||
|
|
@ -37,7 +38,7 @@ class ProjectBar(QtWidgets.QWidget):
|
|||
self.project_combobox.currentIndexChanged.connect(self.project_changed)
|
||||
|
||||
# Set current project by default if it's set.
|
||||
project_name = io.Session.get("AVALON_PROJECT")
|
||||
project_name = self.dbcon.Session.get("AVALON_PROJECT")
|
||||
if project_name:
|
||||
self.set_project(project_name)
|
||||
|
||||
|
|
@ -68,9 +69,11 @@ class ActionBar(QtWidgets.QWidget):
|
|||
|
||||
action_clicked = QtCore.Signal(object)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
def __init__(self, dbcon, parent=None):
|
||||
super(ActionBar, self).__init__(parent)
|
||||
|
||||
self.dbcon = dbcon
|
||||
|
||||
layout = QtWidgets.QHBoxLayout(self)
|
||||
layout.setContentsMargins(8, 0, 8, 0)
|
||||
|
||||
|
|
@ -86,7 +89,7 @@ class ActionBar(QtWidgets.QWidget):
|
|||
view.setSpacing(0)
|
||||
view.setWordWrap(True)
|
||||
|
||||
model = ActionModel(self)
|
||||
model = ActionModel(self.dbcon, self)
|
||||
view.setModel(model)
|
||||
|
||||
delegate = ActionDelegate(model.GROUP_ROLE, self)
|
||||
|
|
@ -140,12 +143,14 @@ class TasksWidget(QtWidgets.QWidget):
|
|||
QtCore.QItemSelectionModel.Select | QtCore.QItemSelectionModel.Rows
|
||||
)
|
||||
|
||||
def __init__(self):
|
||||
super(TasksWidget, self).__init__()
|
||||
def __init__(self, dbcon, parent=None):
|
||||
super(TasksWidget, self).__init__(parent)
|
||||
|
||||
view = QtWidgets.QTreeView()
|
||||
self.dbcon = dbcon
|
||||
|
||||
view = QtWidgets.QTreeView(self)
|
||||
view.setIndentation(0)
|
||||
model = TaskModel()
|
||||
model = TaskModel(self.dbcon)
|
||||
view.setModel(model)
|
||||
|
||||
layout = QtWidgets.QVBoxLayout(self)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue