diff --git a/openpype/modules/shotgun/hooks/post_shotgun_changes.py b/openpype/modules/shotgun/hooks/post_shotgun_changes.py new file mode 100644 index 00000000000..83e975e4fc5 --- /dev/null +++ b/openpype/modules/shotgun/hooks/post_shotgun_changes.py @@ -0,0 +1,11 @@ +import os + +from openpype.lib import PostLaunchHook + + +class PostShotgunHook(PostLaunchHook): + order = None + + def execute(self, *args, **kwargs): + print(args, kwargs) + pass diff --git a/openpype/modules/shotgun/plugins/publish/collect_more_information.py b/openpype/modules/shotgun/plugins/publish/collect_more_information.py new file mode 100644 index 00000000000..bda4011a717 --- /dev/null +++ b/openpype/modules/shotgun/plugins/publish/collect_more_information.py @@ -0,0 +1,13 @@ +import pyblish.api + + +class CollectMoreInformation(pyblish.api.InstancePlugin): + """Collect test information withing test collector""" + + order = pyblish.api.CollectorOrder - 0.5 + label = "Collect more info family" + families = ["model", "model", "animation", "look", "rig", "camera"] + hosts = ["maya"] + + def process(self, instance): + print(type(instance)) diff --git a/openpype/modules/shotgun/shotgun_module.py b/openpype/modules/shotgun/shotgun_module.py index bb6c4aca5e0..9c9b4e49627 100644 --- a/openpype/modules/shotgun/shotgun_module.py +++ b/openpype/modules/shotgun/shotgun_module.py @@ -1,12 +1,17 @@ +import os from typing import Optional, Dict, AnyStr, Any from Qt import QtWidgets -from openpype.modules import PypeModule, ITrayModule +from openpype.modules import PypeModule, ITrayModule, IPluginPaths, ILaunchHookPaths +from openpype.modules.shotgun.tray.shotgun_tray import ShotgunTrayWrapper +SHOTGUN_MODULE_DIR = os.path.dirname(os.path.abspath(__file__)) -class ShotgunModule(PypeModule, ITrayModule): + +class ShotgunModule(PypeModule, ITrayModule, IPluginPaths, ILaunchHookPaths): name: str = "shotgun" enabled: bool = False project_id: Optional[str] = None + tray_wrapper: ShotgunTrayWrapper def initialize(self, modules_settings: Dict[AnyStr, Any]): shotgun_settings = modules_settings.get(self.name, dict()) @@ -19,19 +24,24 @@ def initialize(self, modules_settings: Dict[AnyStr, Any]): def connect_with_modules(self, enabled_modules): pass - def get_global_environments(self): + def get_global_environments(self) -> Dict[AnyStr, Any]: return {"PROJECT_ID": self.project_id} + def get_plugin_paths(self) -> Dict[AnyStr, Any]: + return {"publish": [os.path.join(SHOTGUN_MODULE_DIR, "plugins", "publish")]} + + def get_launch_hook_paths(self) -> AnyStr: + return os.path.join(SHOTGUN_MODULE_DIR, "hooks") + def tray_init(self): - pass + self.tray_wrapper = ShotgunTrayWrapper(self) def tray_start(self): - pass + return self.tray_wrapper.validate() def tray_exit(self, *args, **kwargs): - pass + return self.tray_wrapper def tray_menu(self, tray_menu): - print(type(tray_menu)) - menu = QtWidgets.QMenu("Shotgun", tray_menu) - tray_menu.addMenu(menu) + return self.tray_wrapper.tray_menu(tray_menu) + diff --git a/openpype/modules/shotgun/tray/_empty b/openpype/modules/shotgun/tray/_empty deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/openpype/modules/shotgun/tray/credential_dialog.py b/openpype/modules/shotgun/tray/credential_dialog.py new file mode 100644 index 00000000000..20fa887763f --- /dev/null +++ b/openpype/modules/shotgun/tray/credential_dialog.py @@ -0,0 +1,79 @@ +import os +from typing import Any + +import requests +from openpype import style +from openpype.modules.ftrack.lib import credentials +from openpype import resources +from Qt import QtCore, QtGui, QtWidgets + + +class CredentialsDialog(QtWidgets.QDialog): + SIZE_W = 300 + SIZE_H = 230 + + _module: Any = None + _is_logged: bool = False + url_label: QtWidgets.QLabel + login_label: QtWidgets.QLabel + password_label: QtWidgets.QLabel + url_input: QtWidgets.QLineEdit + login_input: QtWidgets.QLineEdit + password_input: QtWidgets.QLineEdit + input_layout: QtWidgets.QFormLayout + login_button: QtWidgets.QPushButton + buttons_layout: QtWidgets.QHBoxLayout + input_layout: QtWidgets.QFormLayout + main_widget: QtWidgets.QVBoxLayout + + def __init__(self, module, parent=None): + super(CredentialsDialog, self).__init__(parent) + + self._module = module + self._is_logged = False + self.setWindowTitle("OpenPype - Shotgun Login") + + self.setWindowFlags( + QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.WindowMinimizeButtonHint + ) + self.setMinimumSize(QtCore.QSize(self.SIZE_W, self.SIZE_H)) + self.setMaximumSize(QtCore.QSize(self.SIZE_W + 100, self.SIZE_H + 100)) + self.setStyleSheet(style.load_stylesheet()) + + self.ui_init() + + def ui_init(self): + self.url_label = QtWidgets.QLabel("Shotgun URL:") + self.login_label = QtWidgets.QLabel("Login:") + self.password_label = QtWidgets.QLabel("Password:") + # self.url_input = QtWidgets.QLabel() + # self.url_input.setTextInteractionFlags( + # QtCore.Qt.TextBrowserInteraction + # ) + # self.url_input.setCursor(QtGui.QCursor(QtCore.Qt.IBeamCursor)) + + self.url_input = QtWidgets.QLineEdit() + self.url_input.setPlaceholderText("shotgun url") + + self.login_input = QtWidgets.QLineEdit() + self.login_input.setPlaceholderText("login") + + self.password_input = QtWidgets.QLineEdit() + self.password_input.setPlaceholderText("password") + + self.input_layout = QtWidgets.QFormLayout() + self.input_layout.setContentsMargins(10, 15, 10, 5) + + self.input_layout.addRow(self.url_label, self.url_input) + self.input_layout.addRow(self.login_label, self.login_input) + self.input_layout.addRow(self.password_label, self.password_input) + + self.login_button = QtWidgets.QPushButton("Login") + self.login_button.setToolTip("Login into shotgun instance") + self.buttons_layout = QtWidgets.QHBoxLayout() + self.buttons_layout.addWidget(self.login_button) + + self.main_widget = QtWidgets.QVBoxLayout(self) + self.main_widget.addLayout(self.input_layout) + self.main_widget.addLayout(self.buttons_layout) + self.setLayout(self.main_widget) diff --git a/openpype/modules/shotgun/tray/shotgun_tray.py b/openpype/modules/shotgun/tray/shotgun_tray.py new file mode 100644 index 00000000000..deb76a0cea3 --- /dev/null +++ b/openpype/modules/shotgun/tray/shotgun_tray.py @@ -0,0 +1,27 @@ +from typing import Any + +from openpype.modules.shotgun.tray.credential_dialog import CredentialsDialog +from Qt import QtWidgets + +class ShotgunTrayWrapper: + module: Any + credentials_dialog: CredentialsDialog + + def __init__(self, module) -> None: + self.module = module + self.credentials_dialog = CredentialsDialog(module) + + def show_credential_dialog(self): + self.credentials_dialog.show() + self.credentials_dialog.activateWindow() + self.credentials_dialog.raise_() + + def tray_menu(self, tray_menu): + print(type(tray_menu)) + menu = QtWidgets.QMenu("Shotgun", tray_menu) + tray_menu.addMenu(menu) + + def validate(self): + self.show_credential_dialog() + return True +