Skip to content

Commit

Permalink
Small tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
wgergely committed Nov 11, 2023
1 parent 48f7432 commit e30a534
Show file tree
Hide file tree
Showing 17 changed files with 140 additions and 305 deletions.
16 changes: 0 additions & 16 deletions bookmarks/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,22 +671,6 @@ def toggle_filter_editor():
w.filter_editor.close()


@QtCore.Slot(str)
@QtCore.Slot(str)
@QtCore.Slot(str)
@QtCore.Slot(object)
@must_be_initialized
def asset_identifier_changed(table, source, key, value):
"""Refresh the assets model if the identifier changes.
"""
# All shotgun fields should be prefixed by 'shotgun_'
if not (table == database.BookmarkTable and key == 'identifier'):
return
model = common.source_model(common.AssetTab)
model.reset_data()


def selection(func):
"""Decorator function to ensure `QModelIndexes` passed to worker threads
are in a valid state.
Expand Down
1 change: 0 additions & 1 deletion bookmarks/common/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ def __init__(self, connect_signals=True, parent=None):

self.toggleFavouritesButton.connect(actions.toggle_favourite_items)

self.databaseValueUpdated.connect(actions.asset_identifier_changed)
self.assetAdded.connect(actions.show_asset)

self.taskFolderChanged.connect(actions.set_task_folder)
Expand Down
12 changes: 7 additions & 5 deletions bookmarks/common/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,15 @@ def init_stylesheet():
size_font_medium=int(size(common.size_font_medium)),
size_font_large=int(size(common.size_font_large)),
size_separator=int(size(common.size_separator)),
size_separator2=int(size(common.size_separator) * 2.0),
size_indicator=int(size(common.size_indicator)),
size_indicator1=int(size(common.size_indicator) * 1.33),
size_indicator2=int(size(common.size_indicator) * 1.8),
size_indicator1=int(size(common.size_indicator) * 1.5),
size_indicator2=int(size(common.size_indicator) * 2.0),
size_indicator3=int(size(common.size_indicator) * 3.0),
size_margin=int(size(common.size_margin)),
size_margin2=int(size(common.size_margin) * 2),
size_margin3=int(size(common.size_margin) * 3),
size_margin4=int(size(common.size_margin) * 4),
size_margin2=int(size(common.size_margin) * 2.0),
size_margin3=int(size(common.size_margin) * 3.0),
size_margin4=int(size(common.size_margin) * 4.0),
size_row_height=int(size(common.size_row_height)),
size_row_height2=int(size(common.size_row_height) * 0.8),
color_background=rgb(common.color_background),
Expand Down
78 changes: 40 additions & 38 deletions bookmarks/contextmenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -1641,45 +1641,47 @@ def import_export_properties_menu(self):

self.separator(menu=self.menu[k])

pp = self.index.data(common.ParentPathRole)
if len(pp) == 3:
clipboard = common.BookmarkPropertyClipboard
elif len(pp) == 4:
clipboard = common.AssetPropertyClipboard
else:
clipboard = None

# Copy menu
if self.index.isValid() and clipboard:
self.menu[k][key()] = {
'text': 'Copy properties to clipboard...',
'action': actions.copy_properties,
'icon': ui.get_icon('settings'),
'shortcut': shortcuts.get(
shortcuts.MainWidgetShortcuts,
shortcuts.CopyProperties
).key(),
'description': shortcuts.hint(
shortcuts.MainWidgetShortcuts,
shortcuts.CopyProperties
),
}
# Copy / paste menu
if self.index.isValid():
pp = self.index.data(common.ParentPathRole)

# Paste menu
if self.index.isValid() and clipboard and common.CLIPBOARD[clipboard]:
self.menu[k][key()] = {
'text': 'Paste properties from clipboard',
'action': actions.paste_properties,
'icon': ui.get_icon('settings'),
'shortcut': shortcuts.get(
shortcuts.MainWidgetShortcuts,
shortcuts.PasteProperties
).key(),
'description': shortcuts.hint(
shortcuts.MainWidgetShortcuts,
shortcuts.PasteProperties
),
}
clipboard = None
if len(pp) == 3:
clipboard = common.BookmarkPropertyClipboard
elif len(pp) == 4:
clipboard = common.AssetPropertyClipboard

# Copy menu
if clipboard is not None:
self.menu[k][key()] = {
'text': 'Copy Properties to Clipboard...',
'action': actions.copy_properties,
'icon': ui.get_icon('settings'),
'shortcut': shortcuts.get(
shortcuts.MainWidgetShortcuts,
shortcuts.CopyProperties
).key(),
'description': shortcuts.hint(
shortcuts.MainWidgetShortcuts,
shortcuts.CopyProperties
),
}

# Paste menu
if common.CLIPBOARD[clipboard]:
self.menu[k][key()] = {
'text': 'Paste Properties from Clipboard',
'action': actions.paste_properties,
'icon': ui.get_icon('settings'),
'shortcut': shortcuts.get(
shortcuts.MainWidgetShortcuts,
shortcuts.PasteProperties
).key(),
'description': shortcuts.hint(
shortcuts.MainWidgetShortcuts,
shortcuts.PasteProperties
),
}

self.separator(menu=self.menu[k])
if self.index.isValid():
Expand Down
4 changes: 0 additions & 4 deletions bookmarks/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,6 @@
'sql': 'INT',
'type': int
},
'identifier': {
'sql': 'TEXT',
'type': str
},
'shotgun_domain': {
'sql': 'TEXT',
'type': str
Expand Down
9 changes: 3 additions & 6 deletions bookmarks/editor/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def __init__(
self._frameless = frameless

self.section_buttons = section_buttons
self._section_widgets = []
self.section_headers_widget = None

self.server = server
self.job = job
Expand All @@ -181,7 +181,6 @@ def __init__(

self.thumbnail_editor = None
self._hide_thumbnail_editor = hide_thumbnail_editor
self.section_headers_widget = None

if not self.parent():
common.set_stylesheet(self)
Expand Down Expand Up @@ -267,10 +266,8 @@ def _create_ui(self):

self.section_headers_widget = QtWidgets.QWidget(parent=self)
QtWidgets.QVBoxLayout(self.section_headers_widget)
self.section_headers_widget.layout().setContentsMargins(0, 0, 0, 0)
self.section_headers_widget.layout().setSpacing(
common.size(common.size_indicator) * 2
)
self.section_headers_widget.layout().setContentsMargins(o, o, o, o)
self.section_headers_widget.layout().setSpacing(o)

parent = QtWidgets.QWidget(parent=self)
QtWidgets.QVBoxLayout(parent)
Expand Down
24 changes: 0 additions & 24 deletions bookmarks/editor/bookmark_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,30 +135,6 @@ class BookmarkPropertyEditor(base.BasePropertyEditor):
'e.g. \'150\'',
},
},
3: {
'identifier': {
'name': 'Asset Identifier',
'key': 'identifier',
'validator': None,
'widget': ui.LineEdit,
'placeholder': 'A file name, e.g. \'workspace.mel\'',
'description': 'Only folders containing the file specified '
'above will be read as assets.\n\nUsing the '
'default Maya Workspace the identifier normally '
'is \'workspace.mel\', however any other '
'arbitrary file can be used as long it is '
'present in the root of an asset '
'folder.\n\nWhen left empty all folders in the '
'bookmark will be read.',
'help': 'Only folders containing the file specified here will '
'be read as assets.\nUsing the default Maya Workspace '
'the identifier normally is \'workspace.mel\', '
'however any other arbitrary file can be used as long '
'it is present in the root of an asset folder.\n\nWhen '
'left empty, all folders in the bookmark will be '
'interpreted as assets.',
}
},
4: {
0: {
'name': 'Bookmark Display Name',
Expand Down
11 changes: 11 additions & 0 deletions bookmarks/maya/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
import uuid

try:
from maya import OpenMayaUI
import maya.cmds as cmds
except ImportError:
raise ImportError('Could not find the Maya modules.')

from PySide2 import QtWidgets, QtCore
import shiboken2

from .. import common
from .. import database
Expand Down Expand Up @@ -188,6 +190,15 @@
is imported multiple times.'


def maya_main_window():
"""
Return the Maya main window widget as a Python object
"""
main_window_ptr = OpenMayaUI.MQtUtil.mainWindow()
return shiboken2.wrapInstance(int(main_window_ptr), QtWidgets.QWidget)


def patch_workspace_file_rules():
"""Patches the current maya workspace to use the directories defined in the
active bookmark item's token configuration.
Expand Down
9 changes: 5 additions & 4 deletions bookmarks/maya/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ def show():
"""
close()
common.maya_export_widget = ExportWidget()
common.maya_export_widget.open()
common.maya_export_widget = ExportWidget(parent=mayabase.maya_main_window())
common.set_stylesheet(common.maya_export_widget)
common.maya_export_widget.show()
return common.maya_export_widget


Expand Down Expand Up @@ -493,8 +494,8 @@ class ExportWidget(base.BasePropertyEditor):
#: UI layout definition
sections = {
0: {
'name': 'Export',
'icon': '',
'name': 'Export Object Sets',
'icon': 'set',
'color': common.color(common.color_dark_background),
'groups': {
0: {
Expand Down
8 changes: 7 additions & 1 deletion bookmarks/maya/scripts/aka_character_caches.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,13 @@ def get_cache_path(set_name, ext, makedir=True):
_version += 1

if makedir:
QtCore.QFileInfo(file_path).dir().mkpath('.')
_dir = QtCore.QFileInfo(file_path).dir()
if not _dir.exists():
if _dir.mkpath('.'):
print(f'Created directory: {_dir.path()}')
else:
raise RuntimeError(f'Could not create directory: {_dir.path()}')

return file_path


Expand Down
4 changes: 3 additions & 1 deletion bookmarks/maya/scripts/aka_shader_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import maya.cmds as cmds
from PySide2 import QtCore, QtGui, QtWidgets

from .. import base as mayabase

WINDOW_TITLE = 'Aka Shader Templates'
NUMERIC_TYPES = ['double', 'float', 'long', 'short', 'byte', 'int']

Expand Down Expand Up @@ -914,7 +916,7 @@ def run():
except:

pass
instance = PresetsWidget()
instance = PresetsWidget(parent=mayabase.get_maya_window())
instance.show()


Expand Down
Loading

0 comments on commit e30a534

Please sign in to comment.