Skip to content

Commit

Permalink
Squashed commits photoshop-add-Scriptmenu
Browse files Browse the repository at this point in the history
commit 4f8ab6d
Author: BenoitConnan <82808268+BenoitConnan@users.noreply.github.com>
Date:   Tue Feb 8 10:59:57 2022 +0100

    Use qt

    Suggestion from code review

    Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>

commit 509792e
Author: BenoitConnan <benoitconnan.pro@gmail.com>
Date:   Wed Feb 2 18:29:24 2022 +0100

    hound fix

commit 022fce8
Author: BenoitConnan <benoitconnan.pro@gmail.com>
Date:   Wed Feb 2 18:21:35 2022 +0100

    clean photoshop settings examples

commit 07ab742
Author: BenoitConnan <benoitconnan.pro@gmail.com>
Date:   Wed Feb 2 18:10:41 2022 +0100

    Add studio tools launch logic for photoshop

commit aee4f0d
Author: BenoitConnan <benoitconnan.pro@gmail.com>
Date:   Fri Jan 21 17:46:50 2022 +0100

    add photoshop settings for scriptemenu

commit ce79d66
Author: BenoitConnan <benoitconnan.pro@gmail.com>
Date:   Fri Jan 21 17:46:19 2022 +0100

    Add studio tool as host tool

commit 6f79251
Merge: ecae9f6 6468751
Author: Petr Kalis <petr.kalis@gmail.com>
Date:   Mon Feb 7 10:05:55 2022 +0100

    Merge pull request ynput#2634 from Ellipsanime/fix-photoshop-environement-workfiles-on-launch

    Fix open workfile on launch in photoshop

commit ecae9f6
Merge: 4b3834e 3160199
Author: Milan Kolar <mkolar@users.noreply.github.com>
Date:   Mon Feb 7 09:52:39 2022 +0100

    Merge pull request ynput#2556 from pypeclub/feature/OP-2429_Publisher-Preparations-before-standalone-publisher

commit 4b3834e
Merge: ccea535 604a590
Author: pypebot <82967070+pypebot@users.noreply.github.com>
Date:   Mon Feb 7 09:38:20 2022 +0100

    [Automated] Merged release main into develop

commit ccea535
Merge: f2a9543 a11700e
Author: pypebot <82967070+pypebot@users.noreply.github.com>
Date:   Sat Feb 5 04:34:51 2022 +0100

    [Automated] Merged main into develop

commit 6468751
Author: clement.hector <clement.hector@gmail.com>
Date:   Fri Feb 4 12:11:05 2022 +0100

    use env_value_to_bool instead of ast.literal_eval + os.getenv

commit fe46093
Author: clement.hector <clement.hector@gmail.com>
Date:   Wed Feb 2 19:36:49 2022 +0100

    fix test on string to boolean

commit 3160199
Author: Jakub Trllo <jakub.trllo@gmail.com>
Date:   Tue Jan 25 14:15:19 2022 +0100

    fix grammar

commit d739364
Author: Jakub Trllo <jakub.trllo@gmail.com>
Date:   Tue Jan 25 13:48:18 2022 +0100

    handle default value of 'is_label_horizontal'

commit 7ec4d50
Author: Jakub Trllo <jakub.trllo@gmail.com>
Date:   Tue Jan 25 13:48:03 2022 +0100

    precreate widget is separated from create dialog completely

commit f8be576
Author: iLLiCiTiT <jakub.trllo@gmail.com>
Date:   Tue Jan 18 18:05:32 2022 +0100

    renamed method 'get_attribute_defs' to 'get_instance_attr_defs'

commit 20f5e8f
Author: iLLiCiTiT <jakub.trllo@gmail.com>
Date:   Tue Jan 18 17:51:25 2022 +0100

    hound fixes

commit 95176b6
Author: iLLiCiTiT <jakub.trllo@gmail.com>
Date:   Tue Jan 18 17:26:16 2022 +0100

    modified example creator

commit 23c3bc8
Author: iLLiCiTiT <jakub.trllo@gmail.com>
Date:   Tue Jan 18 17:26:09 2022 +0100

    style changes of header view nad checkbox

commit 2d75212
Author: iLLiCiTiT <jakub.trllo@gmail.com>
Date:   Tue Jan 18 17:25:51 2022 +0100

    ui attribute definitions are skipped for storing data

commit f0b7f72
Author: iLLiCiTiT <jakub.trllo@gmail.com>
Date:   Tue Jan 18 17:25:34 2022 +0100

    creator dialog has context widget and creator's attributes

commit 9c6a57a
Author: iLLiCiTiT <jakub.trllo@gmail.com>
Date:   Tue Jan 18 17:23:37 2022 +0100

    creator can define precreate attribute definitions and allowing context change

commit 3878c52
Author: iLLiCiTiT <jakub.trllo@gmail.com>
Date:   Tue Jan 18 17:22:57 2022 +0100

    added widgett for pre create attributes

commit fffdef5
Author: iLLiCiTiT <jakub.trllo@gmail.com>
Date:   Tue Jan 18 17:22:41 2022 +0100

    added publisher specific asset and task widgets

commit fbdd1d8
Author: iLLiCiTiT <jakub.trllo@gmail.com>
Date:   Tue Jan 18 17:22:08 2022 +0100

    moved few widgets to tools/utils and modified asset/task widgets to easily change source model

commit 396bdfd
Author: iLLiCiTiT <jakub.trllo@gmail.com>
Date:   Tue Jan 18 17:16:32 2022 +0100

    added few new attribute definitions and their widgets
  • Loading branch information
BenoitConnan committed Feb 28, 2022
1 parent 10611cf commit 4febd45
Show file tree
Hide file tree
Showing 8 changed files with 195 additions and 10 deletions.
32 changes: 22 additions & 10 deletions openpype/hosts/photoshop/api/extension/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
}
button {width: 100%;}
</style>

<style>
button {width: 100%;}
body {margin:0; padding:0; height: 100%;}
html {height: 100%;}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
</script>

<script type=text/javascript>
$(function() {
$("a#workfiles-button").bind("click", function() {
Expand All @@ -31,7 +31,7 @@
});
});
</script>

<script type=text/javascript>
$(function() {
$("a#creator-button").bind("click", function() {
Expand All @@ -42,7 +42,7 @@
});
});
</script>

<script type=text/javascript>
$(function() {
$("a#loader-button").bind("click", function() {
Expand All @@ -53,7 +53,7 @@
});
});
</script>

<script type=text/javascript>
$(function() {
$("a#publish-button").bind("click", function() {
Expand All @@ -64,7 +64,18 @@
});
});
</script>


<script type=text/javascript>
$(function() {
$("a#studio-tools-button").bind("click", function() {
RPC.call('Photoshop.studio_tools_route').then(function (data) {
}, function (error) {
alert(error);
});
});
});
</script>

<script type=text/javascript>
$(function() {
$("a#sceneinventory-button").bind("click", function() {
Expand All @@ -86,7 +97,7 @@
});
});
</script>

<script type=text/javascript>
$(function() {
$("a#experimental-button").bind("click", function() {
Expand All @@ -102,16 +113,17 @@
<script type="text/javascript" src="./client/wsrpc.js"></script>
<script type="text/javascript" src="./client/CSInterface.js"></script>
<script type="text/javascript" src="./client/loglevel.min.js"></script>

<!-- helper library for better debugging of .jsx check its license! -->
<script type="text/javascript" src="./host/JSX.js"></script>

<script type="text/javascript" src="./client/client.js"></script>

<a href=# id=workfiles-button><button>Workfiles...</button></a>
<a href=# id=creator-button><button>Create...</button></a>
<a href=# id=loader-button><button>Load...</button></a>
<a href=# id=publish-button><button>Publish...</button></a>
<a href=# id=studio-tools-button><button>Studio Tools...</button></a>
<a href=# id=sceneinventory-button><button>Manage...</button></a>
<a href=# id=subsetmanager-button><button>Subset Manager...</button></a>
<a href=# id=experimental-button><button>Experimental Tools...</button></a>
Expand Down
3 changes: 3 additions & 0 deletions openpype/hosts/photoshop/api/launch_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,9 @@ async def loader_route(self):
async def publish_route(self):
self._tool_route("publish")

async def studio_tools_route(self):
self._tool_route("studio_tools")

async def sceneinventory_route(self):
self._tool_route("sceneinventory")

Expand Down
16 changes: 16 additions & 0 deletions openpype/settings/defaults/project_settings/photoshop.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,22 @@
}
}
},
"scriptsmenu": {
"name": "OpenPype Tools",
"definition": [
{
"type": "action",
"command": "import sys; sys.stdout.write('Hello');",
"sourcetype": "python",
"title": "Example script",
"tooltip": "A polite example script",
"tags": [
"pipeline",
"test"
]
}
]
},
"workfile_builder": {
"create_first_version": false,
"custom_templates": []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@
}
]
},
{
"type": "schema",
"name": "schema_photoshop_scriptsmenu"
},
{
"type": "schema_template",
"name": "template_workfile_options",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"type": "dict",
"collapsible": true,
"key": "scriptsmenu",
"label": "Scripts Menu Definition",
"children": [
{
"type": "text",
"key": "name",
"label": "Menu Name"
},
{
"type": "splitter"
},
{
"type": "raw-json",
"key": "definition",
"label": "Menu definition",
"is_list": true
}
]
}
9 changes: 9 additions & 0 deletions openpype/tools/studio_tools/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from .app import (
StudioToolsDialog,
show
)

__all__ = [
"StudioToolsDialog",
"show"
]
94 changes: 94 additions & 0 deletions openpype/tools/studio_tools/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import sys
import os
from Qt import QtCore
from Qt import QtWidgets
from openpype import style
from openpype.settings import get_project_settings
from openpype.tools.utils import lib as tools_lib

import scriptsmenu
import logging

log = logging.getLogger(__name__)
module = sys.modules[__name__]
module.window = None


class StudioToolsDialog(QtWidgets.QWidget):
def __init__(self, parent=None):
super(StudioToolsDialog, self).__init__(parent)

self.resize(400, 300)
self.setStyleSheet(style.load_stylesheet())

project_settings = get_project_settings(os.getenv("AVALON_PROJECT"))
host = os.getenv("AVALON_APP")
config = project_settings[host]["scriptsmenu"]["definition"]
_menu = project_settings[host]["scriptsmenu"]["name"]
self.setWindowTitle(_menu)

title = _menu.title()
objectName = _menu.title().lower().replace(" ", "_")

layout = QtWidgets.QVBoxLayout()

try:
log.info("Attempting to build menu ...")
object_name = objectName or title.lower()
menu = scriptsmenu.ScriptsMenu(title=title,
parent=parent,
objectName=object_name)
layout.addWidget(menu)
menu.aboutToHide.connect(menu.show) # IF menu try to hide -> Don't
except Exception as e:
log.error(e)
return
finally:
self.setLayout(layout)

# apply configuration
self.layout = layout
menu.build_from_configuration(menu, config)
self.menu = menu


def show(debug=False, parent=None):
"""Display Loader GUI
Arguments:
debug (bool, optional): Run loader in debug-mode,
defaults to False
parent (QtCore.QObject, optional): The Qt object to parent to.
use_context (bool): Whether to apply the current context upon launch
"""
# Remember window
if module.window is not None:
try:
module.window.show()

# If the window is minimized then unminimize it.
if module.window.windowState() & QtCore.Qt.WindowMinimized:
module.window.setWindowState(QtCore.Qt.WindowActive)

# Raise and activate the window
module.window.raise_() # for MacOS
module.window.activateWindow() # for Windows
module.window.refresh()
return
except RuntimeError as e:
if not e.message.rstrip().endswith("already deleted."):
raise

# Garbage collected
module.window = None

if debug:
import traceback
sys.excepthook = lambda typ, val, tb: traceback.print_last()

with tools_lib.qt_app_context():
window = StudioToolsDialog(parent)
window.show()

module.window = window
25 changes: 25 additions & 0 deletions openpype/tools/utils/host_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(self, parent=None):
self._library_loader_tool = None
self._look_assigner_tool = None
self._experimental_tools_dialog = None
self._studio_tools_dialog = None

@property
def log(self):
Expand Down Expand Up @@ -247,6 +248,24 @@ def show_experimental_tools_dialog(self, parent=None):
dialog.raise_()
dialog.activateWindow()

def get_studio_tools_dialog(self, parent=None):
if self._studio_tools_dialog is None:
from openpype.tools.studio_tools import (
StudioToolsDialog
)

self._studio_tools_dialog = StudioToolsDialog(parent)
return self._studio_tools_dialog

def show_studio_tools_dialog(self, parent=None):
"""Show dialog with experimental tools."""
with qt_app_context():
dialog = self.get_studio_tools_dialog(parent)

dialog.show()
dialog.raise_()
dialog.activateWindow()

def get_tool_by_name(self, tool_name, parent=None, *args, **kwargs):
"""Show tool by it's name.
Expand Down Expand Up @@ -279,6 +298,9 @@ def get_tool_by_name(self, tool_name, parent=None, *args, **kwargs):
elif tool_name == "experimental_tools":
return self.get_experimental_tools_dialog(parent, *args, **kwargs)

elif tool_name == "studio_tools":
return self.get_studio_tools_dialog(parent, *args, **kwargs)

else:
self.log.warning(
"Can't show unknown tool name: \"{}\"".format(tool_name)
Expand Down Expand Up @@ -316,6 +338,9 @@ def show_tool_by_name(self, tool_name, parent=None, *args, **kwargs):
elif tool_name == "experimental_tools":
self.show_experimental_tools_dialog(parent, *args, **kwargs)

elif tool_name == "studio_tools":
self.show_studio_tools_dialog(parent, *args, **kwargs)

else:
self.log.warning(
"Can't show unknown tool name: \"{}\"".format(tool_name)
Expand Down

0 comments on commit 4febd45

Please sign in to comment.