Skip to content

Commit

Permalink
Merge pull request #12 from trevorvanhoof/th/maya_2025_compat
Browse files Browse the repository at this point in the history
Maya 2025 fixes to work with PySide6
  • Loading branch information
theRussetPotato authored Aug 10, 2024
2 parents 620652e + 8cc8a1a commit d2a1bc8
Show file tree
Hide file tree
Showing 16 changed files with 382 additions and 402 deletions.
4 changes: 2 additions & 2 deletions scripts/weights_editor_tool/classes/command_edit_weights.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import copy

from maya import cmds
from PySide2 import QtWidgets

from weights_editor_tool.widgets import weights_table_view
from weights_editor_tool.widgets.widgets_utils import *


class CommandEditWeights(QtWidgets.QUndoCommand):
class CommandEditWeights(QUndoCommand):
"""
Command to edit skin weights.
Expand Down
4 changes: 2 additions & 2 deletions scripts/weights_editor_tool/classes/command_lock_infs.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from maya import cmds

from PySide2 import QtWidgets
from weights_editor_tool.widgets.widgets_utils import *


class CommandLockInfs(QtWidgets.QUndoCommand):
class CommandLockInfs(QUndoCommand):
"""
Command to toggle influence locks.
Expand Down
63 changes: 31 additions & 32 deletions scripts/weights_editor_tool/classes/hotkey.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
from PySide2 import QtCore
from PySide2 import QtGui
from weights_editor_tool.widgets.widgets_utils import *

from weights_editor_tool.enums import Hotkeys


class Hotkey:

Defaults = {
Hotkeys.ToggleTableListViews: {"key": QtCore.Qt.Key_QuoteLeft, "ctrl": True},
Hotkeys.ShowUtilities: {"key": QtCore.Qt.Key_1, "ctrl": True},
Hotkeys.ShowAddPresets: {"key": QtCore.Qt.Key_2, "ctrl": True},
Hotkeys.ShowScalePresets: {"key": QtCore.Qt.Key_3, "ctrl": True},
Hotkeys.ShowSetPresets: {"key": QtCore.Qt.Key_4, "ctrl": True},
Hotkeys.ShowInfList: {"key": QtCore.Qt.Key_5, "ctrl": True},
Hotkeys.ShowInfColors: {"key": QtCore.Qt.Key_6, "ctrl": True},
Hotkeys.MirrorAll: {"key": QtCore.Qt.Key_M, "ctrl": True},
Hotkeys.Prune: {"key": QtCore.Qt.Key_P, "ctrl": True},
Hotkeys.PruneMaxInfs: {"key": QtCore.Qt.Key_P, "ctrl": True, "shift": True},
Hotkeys.RunSmooth: {"key": QtCore.Qt.Key_S, "ctrl": True, "shift": True},
Hotkeys.RunSmoothAllInfs: {"key": QtCore.Qt.Key_D, "ctrl": True, "shift": True},
Hotkeys.Undo: {"key": QtCore.Qt.Key_Z, "ctrl": True, "shift": True},
Hotkeys.Redo: {"key": QtCore.Qt.Key_X, "ctrl": True, "shift": True},
Hotkeys.GrowSelection: {"key": QtCore.Qt.Key_Greater},
Hotkeys.ShrinkSelection: {"key": QtCore.Qt.Key_Less},
Hotkeys.SelectEdgeLoop: {"key": QtCore.Qt.Key_E, "ctrl": True},
Hotkeys.SelectRingLoop: {"key": QtCore.Qt.Key_R, "ctrl": True},
Hotkeys.SelectPerimeter: {"key": QtCore.Qt.Key_T, "ctrl": True},
Hotkeys.SelectShell: {"key": QtCore.Qt.Key_A, "ctrl": True, "shift": True},
Hotkeys.ToggleInfLock: {"key": QtCore.Qt.Key_Space},
Hotkeys.ToggleInfLock2: {"key": QtCore.Qt.Key_L}
Hotkeys.ToggleTableListViews: {"key": Qt.Key_QuoteLeft, "ctrl": True},
Hotkeys.ShowUtilities: {"key": Qt.Key_1, "ctrl": True},
Hotkeys.ShowAddPresets: {"key": Qt.Key_2, "ctrl": True},
Hotkeys.ShowScalePresets: {"key": Qt.Key_3, "ctrl": True},
Hotkeys.ShowSetPresets: {"key": Qt.Key_4, "ctrl": True},
Hotkeys.ShowInfList: {"key": Qt.Key_5, "ctrl": True},
Hotkeys.ShowInfColors: {"key": Qt.Key_6, "ctrl": True},
Hotkeys.MirrorAll: {"key": Qt.Key_M, "ctrl": True},
Hotkeys.Prune: {"key": Qt.Key_P, "ctrl": True},
Hotkeys.PruneMaxInfs: {"key": Qt.Key_P, "ctrl": True, "shift": True},
Hotkeys.RunSmooth: {"key": Qt.Key_S, "ctrl": True, "shift": True},
Hotkeys.RunSmoothAllInfs: {"key": Qt.Key_D, "ctrl": True, "shift": True},
Hotkeys.Undo: {"key": Qt.Key_Z, "ctrl": True, "shift": True},
Hotkeys.Redo: {"key": Qt.Key_X, "ctrl": True, "shift": True},
Hotkeys.GrowSelection: {"key": Qt.Key_Greater},
Hotkeys.ShrinkSelection: {"key": Qt.Key_Less},
Hotkeys.SelectEdgeLoop: {"key": Qt.Key_E, "ctrl": True},
Hotkeys.SelectRingLoop: {"key": Qt.Key_R, "ctrl": True},
Hotkeys.SelectPerimeter: {"key": Qt.Key_T, "ctrl": True},
Hotkeys.SelectShell: {"key": Qt.Key_A, "ctrl": True, "shift": True},
Hotkeys.ToggleInfLock: {"key": Qt.Key_Space},
Hotkeys.ToggleInfLock2: {"key": Qt.Key_L}
}

def __init__(self, caption, key, func, ctrl=False, shift=False, alt=False):
Expand All @@ -46,9 +45,9 @@ def serialize_key_event(key_event):

# Only include shift for alphabetical characters or it won't work.
return {
"shift": char.lower() != char and (QtCore.Qt.SHIFT & modifiers > 0),
"ctrl": QtCore.Qt.CTRL & modifiers > 0,
"alt": QtCore.Qt.ALT & modifiers > 0,
"shift": char.lower() != char and (Qt.SHIFT & modifiers > 0),
"ctrl": Qt.CTRL & modifiers > 0,
"alt": Qt.ALT & modifiers > 0,
"key": key_event.key()
}

Expand All @@ -67,16 +66,16 @@ def create_from_default(cls, caption, func):
)

def key_code(self):
ctrl = QtCore.Qt.CTRL if self.ctrl else 0
shift = QtCore.Qt.SHIFT if self.shift else 0
alt = QtCore.Qt.ALT if self.alt else 0
return self.key | ctrl | shift | alt
ctrl = int(self.ctrl)
shift = int(self.shift)
alt = int(self.alt)
return int(self.key) | ctrl | shift | alt

def key_to_string(self):
ctrl = "Ctrl" if self.ctrl else None
shift = "Shift" if self.shift else None
alt = "Alt" if self.alt else None
key = QtGui.QKeySequence(self.key).toString()
key = QKeySequence(self.key).toString()
return " + ".join(filter(None, [ctrl, shift, alt, key]))

def matches(self, other_hotkey):
Expand Down
9 changes: 4 additions & 5 deletions scripts/weights_editor_tool/classes/skinned_obj.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
import glob
import os
import random
import glob
import sys

if sys.version_info < (3, 0):
import cPickle
Expand All @@ -12,8 +12,7 @@
from maya import OpenMaya
from maya.api import OpenMaya as om2

from PySide2 import QtGui
from PySide2 import QtWidgets
from weights_editor_tool.widgets.widgets_utils import *

from weights_editor_tool import constants
from weights_editor_tool.enums import ColorTheme
Expand Down Expand Up @@ -579,7 +578,7 @@ def collect_influence_colors(self, sat=250, brightness=150):
hue_step = 360.0 / (len(infs))

for i, inf in enumerate(infs):
color = QtGui.QColor()
color = QColor()
color.setHsv(hue_step * i, sat, brightness)
color.toRgb()

Expand Down
Loading

0 comments on commit d2a1bc8

Please sign in to comment.