Skip to content

Commit

Permalink
Add very first shotgun login dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
victorbartel authored and ClementHector committed Feb 7, 2022
1 parent a20b3c9 commit ac015e8
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 9 deletions.
11 changes: 11 additions & 0 deletions openpype/modules/shotgun/hooks/post_shotgun_changes.py
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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))
28 changes: 19 additions & 9 deletions openpype/modules/shotgun/shotgun_module.py
Original file line number Diff line number Diff line change
@@ -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())
Expand All @@ -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)

Empty file.
79 changes: 79 additions & 0 deletions openpype/modules/shotgun/tray/credential_dialog.py
Original file line number Diff line number Diff line change
@@ -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)
27 changes: 27 additions & 0 deletions openpype/modules/shotgun/tray/shotgun_tray.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ac015e8

Please sign in to comment.