mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
tasks are selectable if app will be launched if in maya context, maya is openable
This commit is contained in:
parent
348babed8b
commit
ebc19182eb
2 changed files with 67 additions and 9 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
|
from subprocess import Popen
|
||||||
try:
|
try:
|
||||||
import ftrack_api_old as ftrack_api
|
import ftrack_api_old as ftrack_api
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
@ -21,8 +21,9 @@ class Window(QtWidgets.QDialog):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None, context=None):
|
||||||
super(Window, self).__init__(parent)
|
super(Window, self).__init__(parent)
|
||||||
|
self.context = context
|
||||||
project_name = io.active_project()
|
project_name = io.active_project()
|
||||||
self.setWindowTitle("Asset creator ({0})".format(project_name))
|
self.setWindowTitle("Asset creator ({0})".format(project_name))
|
||||||
self.setFocusPolicy(QtCore.Qt.StrongFocus)
|
self.setFocusPolicy(QtCore.Qt.StrongFocus)
|
||||||
|
|
@ -86,11 +87,17 @@ class Window(QtWidgets.QDialog):
|
||||||
# Add button
|
# Add button
|
||||||
btns_widget = QtWidgets.QWidget()
|
btns_widget = QtWidgets.QWidget()
|
||||||
btns_widget.setContentsMargins(0, 0, 0, 0)
|
btns_widget.setContentsMargins(0, 0, 0, 0)
|
||||||
btn_layout = QtWidgets.QVBoxLayout(btns_widget)
|
btn_layout = QtWidgets.QHBoxLayout(btns_widget)
|
||||||
btn_create_asset = QtWidgets.QPushButton("Create asset")
|
btn_create_asset = QtWidgets.QPushButton("Create asset")
|
||||||
btn_create_asset.setToolTip(
|
btn_create_asset.setToolTip(
|
||||||
"Creates all neccessary components for asset"
|
"Creates all neccessary components for asset"
|
||||||
)
|
)
|
||||||
|
checkbox_app = None
|
||||||
|
if self.context is not None:
|
||||||
|
checkbox_app = QtWidgets.QCheckBox("Open {}".format(
|
||||||
|
self.context.capitalize())
|
||||||
|
)
|
||||||
|
btn_layout.addWidget(checkbox_app)
|
||||||
btn_layout.addWidget(btn_create_asset)
|
btn_layout.addWidget(btn_create_asset)
|
||||||
|
|
||||||
task_view = QtWidgets.QTreeView()
|
task_view = QtWidgets.QTreeView()
|
||||||
|
|
@ -130,6 +137,9 @@ class Window(QtWidgets.QDialog):
|
||||||
"label": {
|
"label": {
|
||||||
"message": message,
|
"message": message,
|
||||||
},
|
},
|
||||||
|
"view": {
|
||||||
|
"tasks": task_view
|
||||||
|
},
|
||||||
"model": {
|
"model": {
|
||||||
"assets": assets,
|
"assets": assets,
|
||||||
"tasks": task_model
|
"tasks": task_model
|
||||||
|
|
@ -140,7 +150,8 @@ class Window(QtWidgets.QDialog):
|
||||||
"parent": input_parent,
|
"parent": input_parent,
|
||||||
"name": input_name,
|
"name": input_name,
|
||||||
"assetbuild": combo_assetbuilt,
|
"assetbuild": combo_assetbuilt,
|
||||||
"tasktemplate": combo_task_template
|
"tasktemplate": combo_task_template,
|
||||||
|
"open_app": checkbox_app
|
||||||
},
|
},
|
||||||
"buttons": {
|
"buttons": {
|
||||||
"create_asset": btn_create_asset
|
"create_asset": btn_create_asset
|
||||||
|
|
@ -154,6 +165,8 @@ class Window(QtWidgets.QDialog):
|
||||||
combo_task_template.currentTextChanged.connect(
|
combo_task_template.currentTextChanged.connect(
|
||||||
self.on_task_template_changed
|
self.on_task_template_changed
|
||||||
)
|
)
|
||||||
|
if self.context is not None:
|
||||||
|
checkbox_app.toggled.connect(self.on_app_checkbox_change)
|
||||||
# on start
|
# on start
|
||||||
self.on_start()
|
self.on_start()
|
||||||
|
|
||||||
|
|
@ -161,6 +174,15 @@ class Window(QtWidgets.QDialog):
|
||||||
|
|
||||||
self.echo("Connected to project: {0}".format(project_name))
|
self.echo("Connected to project: {0}".format(project_name))
|
||||||
|
|
||||||
|
def open_app(self):
|
||||||
|
if self.context == 'maya':
|
||||||
|
Popen("maya")
|
||||||
|
else:
|
||||||
|
message = QtWidgets.QMessageBox(self)
|
||||||
|
message.setWindowTitle("App is not set")
|
||||||
|
message.setIcon(QtWidgets.QMessageBox.Critical)
|
||||||
|
message.show()
|
||||||
|
|
||||||
def on_start(self):
|
def on_start(self):
|
||||||
# Load config
|
# Load config
|
||||||
preset_path = pypelib.get_presets_path()
|
preset_path = pypelib.get_presets_path()
|
||||||
|
|
@ -394,6 +416,29 @@ class Window(QtWidgets.QDialog):
|
||||||
session.create('TypedContextLink', link_data)
|
session.create('TypedContextLink', link_data)
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
|
checkbox_app = self.data['inputs']['open_app']
|
||||||
|
if checkbox_app is not None and checkbox_app.isChecked() is True:
|
||||||
|
origin_asset = api.Session.get('AVALON_TASK', None)
|
||||||
|
origin_task = api.Session.get('AVALON_TASK', None)
|
||||||
|
asset_name = name
|
||||||
|
task_view = self.data["view"]["tasks"]
|
||||||
|
task_model = self.data["model"]["tasks"]
|
||||||
|
try:
|
||||||
|
index = task_view.selectedIndexes()[0]
|
||||||
|
except Exception:
|
||||||
|
message.setText("No task is selected. App won't be launched")
|
||||||
|
message.show()
|
||||||
|
return
|
||||||
|
task_name = task_model.itemData(index)[0]
|
||||||
|
try:
|
||||||
|
api.update_current_task(task=task_name, asset=asset_name)
|
||||||
|
self.open_app()
|
||||||
|
finally:
|
||||||
|
if origin_task is not None and origin_asset is not None:
|
||||||
|
api.update_current_task(
|
||||||
|
task=origin_task, asset=origin_asset
|
||||||
|
)
|
||||||
|
|
||||||
message.setWindowTitle("Asset Created")
|
message.setWindowTitle("Asset Created")
|
||||||
message.setText("Asset Created successfully")
|
message.setText("Asset Created successfully")
|
||||||
message.setIcon(QtWidgets.QMessageBox.Information)
|
message.setIcon(QtWidgets.QMessageBox.Information)
|
||||||
|
|
@ -458,6 +503,14 @@ class Window(QtWidgets.QDialog):
|
||||||
ab_combobox.clear()
|
ab_combobox.clear()
|
||||||
ab_combobox.addItems(types)
|
ab_combobox.addItems(types)
|
||||||
|
|
||||||
|
def on_app_checkbox_change(self):
|
||||||
|
task_model = self.data['model']['tasks']
|
||||||
|
app_checkbox = self.data['inputs']['open_app']
|
||||||
|
if app_checkbox.isChecked() is True:
|
||||||
|
task_model.selectable = True
|
||||||
|
else:
|
||||||
|
task_model.selectable = False
|
||||||
|
|
||||||
def on_outlink_checkbox_change(self):
|
def on_outlink_checkbox_change(self):
|
||||||
checkbox_outlink = self.data['inputs']['outlink_cb']
|
checkbox_outlink = self.data['inputs']['outlink_cb']
|
||||||
outlink_input = self.data['inputs']['outlink']
|
outlink_input = self.data['inputs']['outlink']
|
||||||
|
|
@ -496,7 +549,7 @@ class Window(QtWidgets.QDialog):
|
||||||
parent_input.setText('< Nothing is selected >')
|
parent_input.setText('< Nothing is selected >')
|
||||||
|
|
||||||
|
|
||||||
def show(root=None, debug=False, parent=None):
|
def show(parent=None, debug=False, context=None):
|
||||||
"""Display Loader GUI
|
"""Display Loader GUI
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
|
@ -515,7 +568,7 @@ def show(root=None, debug=False, parent=None):
|
||||||
io.install()
|
io.install()
|
||||||
|
|
||||||
with parentlib.application():
|
with parentlib.application():
|
||||||
window = Window(parent)
|
window = Window(parent, context)
|
||||||
window.setStyleSheet(style.load_stylesheet())
|
window.setStyleSheet(style.load_stylesheet())
|
||||||
window.show()
|
window.show()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -189,6 +189,7 @@ class TasksTemplateModel(TreeModel):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(TasksTemplateModel, self).__init__()
|
super(TasksTemplateModel, self).__init__()
|
||||||
|
self.selectable = True
|
||||||
self._icons = {
|
self._icons = {
|
||||||
"__default__": awesome.icon("fa.folder-o",
|
"__default__": awesome.icon("fa.folder-o",
|
||||||
color=style.colors.default)
|
color=style.colors.default)
|
||||||
|
|
@ -222,8 +223,12 @@ class TasksTemplateModel(TreeModel):
|
||||||
self.endResetModel()
|
self.endResetModel()
|
||||||
|
|
||||||
def flags(self, index):
|
def flags(self, index):
|
||||||
|
if self.selectable is False:
|
||||||
|
return QtCore.Qt.ItemIsEnabled
|
||||||
|
else:
|
||||||
return (
|
return (
|
||||||
QtCore.Qt.ItemIsEnabled
|
QtCore.Qt.ItemIsEnabled |
|
||||||
|
QtCore.Qt.ItemIsSelectable
|
||||||
)
|
)
|
||||||
|
|
||||||
def data(self, index, role):
|
def data(self, index, role):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue