Skip to content

Commit

Permalink
Format code to conform to project settings
Browse files Browse the repository at this point in the history
  • Loading branch information
wgergely committed Nov 6, 2023
1 parent 2236bd7 commit 6e907bd
Show file tree
Hide file tree
Showing 44 changed files with 324 additions and 288 deletions.
26 changes: 14 additions & 12 deletions bookmarks/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from . import common
from . import database
from . import images
from. import log
from . import log


def must_be_initialized(func):
Expand Down Expand Up @@ -1441,7 +1441,7 @@ def execute(index, first=False):
for app in (
'maya', 'maya2017', 'maya2018', 'maya2019', 'maya2020', 'maya2022', 'maya2023', 'maya2024',
'maya2025', 'maya2026'
):
):
executable = common.get_binary(app)
if not executable:
continue
Expand All @@ -1452,48 +1452,48 @@ def execute(index, first=False):
if ext in ('nk', 'nknc'):
executable = common.get_binary('nuke')
if executable:
execute_detached(path, args=[path,])
execute_detached(path, args=[path, ])
return

# Handle Houdini files
if ext == 'hiplc':
for app in ('houdiniinidie', 'houindie', 'houind', 'houdiniind', 'hindie'):
executable = common.get_binary(app)
if executable:
execute_detached(executable, args=[path,])
execute_detached(executable, args=[path, ])
return

if ext == 'hip':
for app in ('houdini', 'houdinifx', 'houfx', 'hfx', 'houdinicore', 'hcore'):
executable = common.get_binary(app)
if executable:
execute_detached(executable, args=[path,])
execute_detached(executable, args=[path, ])
return

# Handle RV files
if ext == 'rv':
for app in ('rv', 'tweakrv', 'shotgunrv', 'shotgridrv', 'sgrv'):
executable = common.get_binary(app)
if executable:
execute_detached(executable, args=[path,])
execute_detached(executable, args=[path, ])
return

# Handle blender files
if ext in ('blend', ):
if ext in ('blend',):
for app in ('blender', 'blender2.8', 'blender2.9', 'blender3', 'blender3.0', 'blender3.1', 'blender3.2',
'blender3.3', 'blender3.4', 'blender3.5'
):
):
executable = common.get_binary(app)
if executable:
execute_detached(executable, args=[path,])
execute_detached(executable, args=[path, ])
return

# Handle After Effects files
if ext in ('aep', ):
if ext in ('aep',):
for app in ('afterfx', 'aftereffects', 'ae', 'afx'):
executable = common.get_binary(app)
if executable:
execute_detached(executable, args=[path,])
execute_detached(executable, args=[path, ])
return

url = QtCore.QUrl.fromLocalFile(path)
Expand Down Expand Up @@ -1641,7 +1641,7 @@ def pick_launcher_item():
"""Slot called when a launcher item was clicked.
"""
from .launcher import gallery as editor
from . import application_launcher as editor
widget = editor.show()
widget.itemSelected.connect(execute_detached)

Expand Down Expand Up @@ -1768,13 +1768,15 @@ def convert_image_sequence(index):
from .external import ffmpeg_widget
ffmpeg_widget.show(index)


@common.debug
@common.error
@selection
def convert_image_sequence_with_akaconvert(index):
from .external import akaconvert
akaconvert.show(index)


def add_zip_template(source, mode, prompt=False):
"""Adds the selected source zip archive as a `mode` template file.
Expand Down
164 changes: 152 additions & 12 deletions bookmarks/launcher/main.py → bookmarks/application_launcher.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
"""Application launcher editor.
"""Application item launcher module.
Each bookmark item can be configured with a list of application items, usually DCCs used
on the given production.
The default launcher item definition is found at
:attr:`~bookmarks.application_launcher.DEFAULT_ITEM`. The item launcher values are stored
in the bookmark item database as an encoded json values.
:mod:`~bookmarks.application_launcher` contains the editor used to add and editor launcher items
via :mod:`bookmarks.editors.bookmark_properties`.
:mod:`~bookmarks.launcher.gallery` is the viewer, used to launch saved items. It is
accessible as a context menu in the item tabs.
"""

import functools

from PySide2 import QtCore, QtWidgets, QtGui

from .. import common
from .. import contextmenu
from .. import images
from .. import ui
from . import actions
from . import common
from . import contextmenu
from . import database
from . import images
from . import ui

#: Default launcher item definition
DEFAULT_ITEM = {
Expand Down Expand Up @@ -46,7 +62,31 @@
THUMBNAIL_EDITOR_SIZE = common.size(common.size_margin) * 5


class LauncherItemEditor(QtWidgets.QDialog):
def close():
"""Opens the :class:`ApplicationLauncherWidget` editor.
"""
if common.launcher_widget is None:
return
try:
common.launcher_widget.close()
common.launcher_widget.deleteLater()
except:
pass
common.launcher_widget = None


def show():
"""Shows the :class:`ApplicationLauncherWidget` editor.
"""
close()
common.launcher_widget = ApplicationLauncherWidget()
common.launcher_widget.open()
return common.launcher_widget


class ApplicationLauncherItemEditor(QtWidgets.QDialog):
"""Widget used to edit launcher items associated with the current bookmark.
"""
Expand Down Expand Up @@ -136,7 +176,7 @@ def _connect_signals(self):

@QtCore.Slot()
def init_data(self, item):
"""Initializes the editor.
"""Initializes the editor data with default data.
"""
self.update_thumbnail_image(item['thumbnail'])
Expand Down Expand Up @@ -277,7 +317,7 @@ def sizeHint(self):
)


class LauncherListContextMenu(contextmenu.BaseContextMenu):
class ApplicationLauncherListContextMenu(contextmenu.BaseContextMenu):
"""Context menu associated with the ThumbnailEditorWidget.
"""
Expand Down Expand Up @@ -309,7 +349,7 @@ def setup(self):
}


class LauncherListWidget(ui.ListWidget):
class ApplicationLauncherListWidget(ui.ListWidget):
"""Widget used to edit launcher items associated with the current bookmark.
"""
Expand Down Expand Up @@ -345,7 +385,7 @@ def contextMenuEvent(self, event):
"""
item = self.itemAt(event.pos())
menu = LauncherListContextMenu(item, parent=self)
menu = ApplicationLauncherListContextMenu(item, parent=self)
pos = event.pos()
pos = self.mapToGlobal(pos)
menu.move(pos)
Expand All @@ -356,7 +396,7 @@ def edit_item(self, item):
"""Slot used top edit a widget item.
"""
editor = LauncherItemEditor(
editor = ApplicationLauncherItemEditor(
data=item.data(QtCore.Qt.UserRole),
parent=self
)
Expand All @@ -370,7 +410,7 @@ def add_new_item(self):
"""Add new item action.
"""
editor = LauncherItemEditor(
editor = ApplicationLauncherItemEditor(
data=None,
parent=self
)
Expand Down Expand Up @@ -411,6 +451,9 @@ def init_data(self, data):

common.check_type(data, dict)

# Sort the data by name
data = {k: v for k, v in sorted(data.items(), key=lambda item: item[1]['name'])}

for idx in data:
self.add_item(data[idx])

Expand Down Expand Up @@ -443,3 +486,100 @@ def setValue(self, v):
"""
self.init_data(v)


class ApplicationLauncherWidget(ui.GalleryWidget):
"""A generic gallery widget used to let the user pick an item.
"""

def __init__(self, parent=None):
super().__init__(
'Application Launcher',
item_height=common.size(common.size_row_height) * 4,
parent=parent
)

def item_generator(self):
"""Yields the available launcher items stored in the bookmark item database.
"""
server = common.active('server')
job = common.active('job')
root = common.active('root')

if not all((server, job, root)):
return

db = database.get(server, job, root)
v = db.value(
db.source(),
'applications',
database.BookmarkTable
)

if not isinstance(v, dict) or not v:
self.close()

if common.show_message(
'The application launcher has not yet been configured.',
body='You can add new items in the current bookmark item\'s property editor. '
'Do you want to open the editor now?',
buttons=[common.YesButton, common.NoButton],
modal=True,
) == QtWidgets.QDialog.Rejected:
return
actions.edit_bookmark()

for k in sorted(v, key=lambda idx: v[idx]['name']):
yield v[k]

def init_data(self):
"""Initializes data.
"""
row = 0
idx = 0

for v in self.item_generator():
if 'name' not in v or not v['name']:
continue
label = v['name']

if 'path' not in v or not v['path']:
continue
path = v['path']

if not QtCore.QFileInfo(path).exists():
continue

if 'thumbnail' not in v or not v['thumbnail']:
thumbnail = images.rsc_pixmap(
'icon',
None,
None,
get_path=True,
)
else:
thumbnail = v['thumbnail']
if 'hidden' not in v or not v['hidden']:
is_hidden = False
else:
is_hidden = v['hidden']

if is_hidden:
continue

item = ui.GalleryItem(
label, path, thumbnail, height=self._item_height, parent=self
)

column = idx % self.columns
if column == 0:
row += 1

self.scroll_area.widget().layout().addWidget(item, row, column)
item.clicked.connect(self.itemSelected)
item.clicked.connect(self.close)

idx += 1
1 change: 1 addition & 0 deletions bookmarks/common/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def get_data_from_value(value, data_type, role=common.PathRole):
return data
return None


def get_task_data(key, task):
"""Get cached data from :attr:`~bookmarks.common.item_data`.
Expand Down
1 change: 0 additions & 1 deletion bookmarks/common/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

from PySide2 import QtCore, QtWidgets


external_binaries = (
'ffmpeg',
'rvpush',
Expand Down
2 changes: 1 addition & 1 deletion bookmarks/common/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def __init__(self, connect_signals=True, parent=None):
lambda *x: common.show_message(
'ShotGrid is connecting, please wait.', disable_animation=True,
buttons=[], message_type=None
)
)
)
self.sgConnectionSuccessful.connect(common.close_message)
self.sgConnectionFailed.connect(common.close_message)
Expand Down
8 changes: 5 additions & 3 deletions bookmarks/common/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,16 +357,18 @@ def close_message():
pass


def show_message(title, body='', disable_animation=False, icon='icon', message_type='info', buttons=None, modal=False,
parent=None):
def show_message(
title, body='', disable_animation=False, icon='icon', message_type='info', buttons=None, modal=False,
parent=None
):
"""Show a message box.
Args:
title (str): The title of the message box.
body (str): The body of the message box.
disable_animation (bool): Whether to show the message box without animation.
icon (str): The icon to use.
message_type (str): The message type. One of 'info', 'success' or 'error'.
message_type (str): The message type. One of 'info', 'success', 'error' or None.
buttons (list): The buttons to show.
modal (bool): Whether the message box should be modal.
parent (QWidget): The parent widget.
Expand Down
Loading

0 comments on commit 6e907bd

Please sign in to comment.