Skip to content

Commit

Permalink
Merge pull request #998 from BigRoy/bugfix/scriptsmenu_run_command_py…
Browse files Browse the repository at this point in the history
…side6

Fix support for scriptsmenu running commands in PySide6
  • Loading branch information
iLLiCiTiT authored Nov 8, 2024
2 parents 244d83e + e9f7784 commit bf23647
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions client/ayon_core/vendor/python/scriptsmenu/action.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os

from qtpy import QtWidgets
from qtpy import QtWidgets, QT6


class Action(QtWidgets.QAction):
Expand Down Expand Up @@ -112,20 +112,21 @@ def run_command(self):
Run the command of the instance or copy the command to the active shelf
based on the current modifiers.
If callbacks have been registered with fouind modifier integer the
If callbacks have been registered with found modifier integer the
function will trigger all callbacks. When a callback function returns a
non zero integer it will not execute the action's command
"""

# get the current application and its linked keyboard modifiers
app = QtWidgets.QApplication.instance()
modifiers = app.keyboardModifiers()
if not QT6:
modifiers = int(modifiers)

# If the menu has a callback registered for the current modifier
# we run the callback instead of the action itself.
registered = self._root.registered_callbacks
callbacks = registered.get(int(modifiers), [])
callbacks = registered.get(modifiers, [])
for callback in callbacks:
signal = callback(self)
if signal != 0:
Expand Down
4 changes: 2 additions & 2 deletions client/ayon_core/vendor/python/scriptsmenu/launchformaya.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import maya.mel as mel

import scriptsmenu
from qtpy import QtCore, QtWidgets
from qtpy import QtCore, QtWidgets, QT6

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -130,7 +130,7 @@ def main(title="Scripts", parent=None, objectName=None):

# Register control + shift callback to add to shelf (maya behavior)
modifiers = QtCore.Qt.ControlModifier | QtCore.Qt.ShiftModifier
if int(cmds.about(version=True)) < 2025:
if not QT6:
modifiers = int(modifiers)

menu.register_callback(modifiers, to_shelf)
Expand Down

0 comments on commit bf23647

Please sign in to comment.