|
394 | 394 | "QGLFormat", |
395 | 395 | "QGLWidget" |
396 | 396 | ], |
| 397 | + "QtPrintSupport": [ |
| 398 | + "QAbstractPrintDialog", |
| 399 | + "QPageSetupDialog", |
| 400 | + "QPrintDialog", |
| 401 | + "QPrintEngine", |
| 402 | + "QPrintPreviewDialog", |
| 403 | + "QPrintPreviewWidget", |
| 404 | + "QPrinter", |
| 405 | + "QPrinterInfo" |
| 406 | + ], |
397 | 407 | "QtSql": [ |
398 | 408 | "QSql", |
399 | 409 | "QSqlDatabase", |
|
706 | 716 | "QtCore.Signal": "QtCore.Signal", |
707 | 717 | "QtCore.Slot": "QtCore.Slot", |
708 | 718 | "QtGui.QItemSelectionRange": "QtCore.QItemSelectionRange", |
| 719 | + "QtGui.QAbstractPrintDialog": "QtPrintSupport.QAbstractPrintDialog", |
| 720 | + "QtGui.QPageSetupDialog": "QtPrintSupport.QPageSetupDialog", |
| 721 | + "QtGui.QPrintDialog": "QtPrintSupport.QPrintDialog", |
| 722 | + "QtGui.QPrintEngine": "QtPrintSupport.QPrintEngine", |
| 723 | + "QtGui.QPrintPreviewDialog": "QtPrintSupport.QPrintPreviewDialog", |
| 724 | + "QtGui.QPrintPreviewWidget": "QtPrintSupport.QPrintPreviewWidget", |
| 725 | + "QtGui.QPrinter": "QtPrintSupport.QPrinter", |
| 726 | + "QtGui.QPrinterInfo": "QtPrintSupport.QPrinterInfo", |
709 | 727 | }, |
710 | 728 | "PyQt4": { |
711 | 729 | "QtGui.QAbstractProxyModel": "QtCore.QAbstractProxyModel", |
|
717 | 735 | "QtCore.pyqtSignal": "QtCore.Signal", |
718 | 736 | "QtCore.pyqtSlot": "QtCore.Slot", |
719 | 737 | "QtGui.QItemSelectionRange": "QtCore.QItemSelectionRange", |
| 738 | + "QtGui.QAbstractPrintDialog": "QtPrintSupport.QAbstractPrintDialog", |
| 739 | + "QtGui.QPageSetupDialog": "QtPrintSupport.QPageSetupDialog", |
| 740 | + "QtGui.QPrintDialog": "QtPrintSupport.QPrintDialog", |
| 741 | + "QtGui.QPrintEngine": "QtPrintSupport.QPrintEngine", |
| 742 | + "QtGui.QPrintPreviewDialog": "QtPrintSupport.QPrintPreviewDialog", |
| 743 | + "QtGui.QPrintPreviewWidget": "QtPrintSupport.QPrintPreviewWidget", |
| 744 | + "QtGui.QPrinter": "QtPrintSupport.QPrinter", |
| 745 | + "QtGui.QPrinterInfo": "QtPrintSupport.QPrinterInfo", |
720 | 746 | } |
721 | 747 | } |
722 | 748 |
|
@@ -910,16 +936,34 @@ def _reassign_misplaced_members(binding): |
910 | 936 | src_module, src_member = src.split(".") |
911 | 937 | dst_module, dst_member = dst.split(".") |
912 | 938 |
|
| 939 | + # Get the member we want to store in the namesapce. |
913 | 940 | try: |
914 | | - src_object = getattr(Qt, dst_module) |
| 941 | + dst_value = getattr(getattr(Qt, "_" + src_module), src_member) |
915 | 942 | except AttributeError: |
916 | | - # Skip reassignment of non-existing members. |
917 | | - # This can happen if a request was made to |
918 | | - # rename a member that didn't exist, for example |
| 943 | + # If the member we want to store in the namespace does not exist, |
| 944 | + # there is no need to continue. This can happen if a request was |
| 945 | + # made to rename a member that didn't exist, for example |
919 | 946 | # if QtWidgets isn't available on the target platform. |
| 947 | + _log("Misplaced member has no source: {}".format(src)) |
920 | 948 | continue |
921 | 949 |
|
922 | | - dst_value = getattr(getattr(Qt, "_" + src_module), src_member) |
| 950 | + try: |
| 951 | + src_object = getattr(Qt, dst_module) |
| 952 | + except AttributeError: |
| 953 | + if dst_module not in _common_members: |
| 954 | + # Only create the Qt parent module if its listed in |
| 955 | + # _common_members. Without this check, if you remove QtCore |
| 956 | + # from _common_members, the default _misplaced_members will add |
| 957 | + # Qt.QtCore so it can add Signal, Slot, etc. |
| 958 | + msg = 'Not creating missing member module "{m}" for "{c}"' |
| 959 | + _log(msg.format(m=dst_module, c=dst_member)) |
| 960 | + continue |
| 961 | + # If the dst is valid but the Qt parent module does not exist |
| 962 | + # then go ahead and create a new module to contain the member. |
| 963 | + setattr(Qt, dst_module, _new_module(dst_module)) |
| 964 | + src_object = getattr(Qt, dst_module) |
| 965 | + # Enable direct import of the new module |
| 966 | + sys.modules[__name__ + "." + dst_module] = src_object |
923 | 967 |
|
924 | 968 | setattr( |
925 | 969 | src_object, |
@@ -1546,6 +1590,9 @@ def _install(): |
1546 | 1590 |
|
1547 | 1591 | setattr(our_submodule, member, their_member) |
1548 | 1592 |
|
| 1593 | + # Enable direct import of QtCompat |
| 1594 | + sys.modules['Qt.QtCompat'] = Qt.QtCompat |
| 1595 | + |
1549 | 1596 | # Backwards compatibility |
1550 | 1597 | if hasattr(Qt.QtCompat, 'loadUi'): |
1551 | 1598 | Qt.QtCompat.load_ui = Qt.QtCompat.loadUi |
|
0 commit comments