Skip to content

Commit

Permalink
Fix for PySide2 (Maya 2024)
Browse files Browse the repository at this point in the history
  • Loading branch information
mottosso authored May 6, 2024
1 parent e28e04a commit 3caf230
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion Qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"QFileSystemWatcher",
"QGenericArgument",
"QGenericReturnArgument",
"QHistoryState",
"QItemSelection",
"QItemSelectionRange",
"QIODevice",
"QLibraryInfo",
Expand Down Expand Up @@ -925,6 +925,9 @@ def createWidget(self, class_name, parent=None, name=""):
These members from the original submodule are misplaced relative PySide2
NOTE: For bindings where a member is not replaced, they still
need to be added such that they are added to Qt.py
"""
_misplaced_members = {
"PySide6": {
Expand Down Expand Up @@ -967,6 +970,9 @@ def createWidget(self, class_name, parent=None, name=""):
"QtCore.Property": "QtCore.Property",
"QtCore.Signal": "QtCore.Signal",
"QtCore.Slot": "QtCore.Slot",
"QtCore.QRegExp": "QtCore.QRegExp",
"QtWidgets.QShortcut": "QtWidgets.QShortcut",
"QtGui.QRegExpValidator": "QtGui.QRegExpValidator",
"QtCore.QAbstractProxyModel": "QtCore.QAbstractProxyModel",
"QtCore.QSortFilterProxyModel": "QtCore.QSortFilterProxyModel",
"QtCore.QItemSelection": "QtCore.QItemSelection",
Expand Down Expand Up @@ -998,6 +1004,8 @@ def createWidget(self, class_name, parent=None, name=""):
"sip.unwrapinstance": ["QtCompat.getCppPointer", _getcpppointer],
"sip.isdeleted": ["QtCompat.isValid", _isvalid],
"QtWidgets.qApp": "QtWidgets.QApplication.instance()",
"QtGui.QRegExpValidator": "QtGui.QRegExpValidator",
"QtCore.QRegExp": "QtCore.QRegExp",
"QtCore.QCoreApplication.translate": [
"QtCompat.translate", _translate
],
Expand All @@ -1007,6 +1015,7 @@ def createWidget(self, class_name, parent=None, name=""):
"QtCore.qInstallMessageHandler": [
"QtCompat.qInstallMessageHandler", _qInstallMessageHandler
],
"QtWidgets.QShortcut": "QtWidgets.QShortcut",
"QtWidgets.QStyleOptionViewItem": "QtCompat.QStyleOptionViewItemV4",
"QtMultimedia.QSound": "QtMultimedia.QSound",
},
Expand All @@ -1018,18 +1027,21 @@ def createWidget(self, class_name, parent=None, name=""):
"QtGui.QItemSelectionModel": "QtCore.QItemSelectionModel",
"QtGui.QItemSelectionRange": "QtCore.QItemSelectionRange",
"QtGui.QAbstractPrintDialog": "QtPrintSupport.QAbstractPrintDialog",
"QtGui.QRegExpValidator": "QtGui.QRegExpValidator",
"QtGui.QPageSetupDialog": "QtPrintSupport.QPageSetupDialog",
"QtGui.QPrintDialog": "QtPrintSupport.QPrintDialog",
"QtGui.QPrintEngine": "QtPrintSupport.QPrintEngine",
"QtGui.QPrintPreviewDialog": "QtPrintSupport.QPrintPreviewDialog",
"QtGui.QPrintPreviewWidget": "QtPrintSupport.QPrintPreviewWidget",
"QtGui.QPrinter": "QtPrintSupport.QPrinter",
"QtWidgets.QShortcut": "QtWidgets.QShortcut",
"QtGui.QPrinterInfo": "QtPrintSupport.QPrinterInfo",
"QtUiTools.QUiLoader": ["QtCompat.loadUi", _loadUi],
"shiboken.wrapInstance": ["QtCompat.wrapInstance", _wrapinstance],
"shiboken.unwrapInstance": ["QtCompat.getCppPointer", _getcpppointer],
"shiboken.isValid": ["QtCompat.isValid", _isvalid],
"QtGui.qApp": "QtWidgets.QApplication.instance()",
"QtCore.QRegExp": "QtCore.QRegExp",
"QtCore.QCoreApplication.translate": [
"QtCompat.translate", _translate
],
Expand All @@ -1053,9 +1065,11 @@ def createWidget(self, class_name, parent=None, name=""):
"QtCore.pyqtSlot": "QtCore.Slot",
"QtGui.QItemSelectionRange": "QtCore.QItemSelectionRange",
"QtGui.QAbstractPrintDialog": "QtPrintSupport.QAbstractPrintDialog",
"QtGui.QRegExpValidator": "QtGui.QRegExpValidator",
"QtGui.QPageSetupDialog": "QtPrintSupport.QPageSetupDialog",
"QtGui.QPrintDialog": "QtPrintSupport.QPrintDialog",
"QtGui.QPrintEngine": "QtPrintSupport.QPrintEngine",
"QtWidgets.QShortcut": "QtWidgets.QShortcut",
"QtGui.QPrintPreviewDialog": "QtPrintSupport.QPrintPreviewDialog",
"QtGui.QPrintPreviewWidget": "QtPrintSupport.QPrintPreviewWidget",
"QtGui.QPrinter": "QtPrintSupport.QPrinter",
Expand All @@ -1066,6 +1080,7 @@ def createWidget(self, class_name, parent=None, name=""):
"sip.isdeleted": ["QtCompat.isValid", _isvalid],
"QtCore.QString": "str",
"QtGui.qApp": "QtWidgets.QApplication.instance()",
"QtCore.QRegExp": "QtCore.QRegExp",
"QtCore.QCoreApplication.translate": [
"QtCompat.translate", _translate
],
Expand Down Expand Up @@ -1297,6 +1312,8 @@ def _reassign_misplaced_members(binding):
"""

print(binding, "HALLO?")

for src, dst in _misplaced_members[binding].items():
dst_value = None

Expand All @@ -1315,6 +1332,8 @@ def _reassign_misplaced_members(binding):
if len(dst_parts) > 1:
dst_member = dst_parts[1]

print("replacing %s.%s -> %s.%s" % (src_module, src_member, dst_module, dst_member))

# Get the member we want to store in the namesapce.
if not dst_value:
try:
Expand Down Expand Up @@ -1539,6 +1558,7 @@ def _pyside2():
Qt.QtCompat.setSectionResizeMode = \
Qt._QtWidgets.QHeaderView.setSectionResizeMode

print("ARADFA")
_reassign_misplaced_members("PySide2")
_build_compatibility_members("PySide2")

Expand Down Expand Up @@ -1910,6 +1930,7 @@ def _install():
b for b in QT_PREFERRED_BINDING.split(os.pathsep) if b
)

print("Installing Qt.py")
order = preferred_order or default_order

available = {
Expand Down Expand Up @@ -1995,6 +2016,7 @@ def _install():
Qt.QtCompat.load_ui = Qt.QtCompat.loadUi


print("RSHRFJsndfljsdnjk")
_install()

# Setup Binding Enum states
Expand Down

0 comments on commit 3caf230

Please sign in to comment.