From 47e92a373f6b7567b9a3790a3600ea127bbbdacd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Fri, 24 Jan 2020 15:23:59 +0100 Subject: [PATCH] Expose CutterApplication to Python and add accessor --- src/bindings/bindings.h | 1 + src/bindings/bindings.xml | 3 +++ src/python/cutter.py | 8 ++++++++ 3 files changed, 12 insertions(+) diff --git a/src/bindings/bindings.h b/src/bindings/bindings.h index bde099fb..d725185f 100644 --- a/src/bindings/bindings.h +++ b/src/bindings/bindings.h @@ -7,6 +7,7 @@ #include "../core/Cutter.h" #include "../common/Configuration.h" #include "../core/MainWindow.h" +#include "../CutterApplication.h" #include "../widgets/CutterDockWidget.h" #include "../plugins/CutterPlugin.h" diff --git a/src/bindings/bindings.xml b/src/bindings/bindings.xml index f4065235..be72ca61 100644 --- a/src/bindings/bindings.xml +++ b/src/bindings/bindings.xml @@ -13,6 +13,9 @@ + + + diff --git a/src/python/cutter.py b/src/python/cutter.py index d8c73049..9a7820c0 100644 --- a/src/python/cutter.py +++ b/src/python/cutter.py @@ -6,6 +6,14 @@ try: def core(): return CutterCore.instance() + + def app(): + # see https://forums.autodesk.com/t5/3ds-max-programming/qapplication-instance-returns-qcoreapplication-instance/td-p/9035295 + import shiboken2 + from PySide2 import QtCore + coreapp = QtCore.QCoreApplication.instance() + ptr = shiboken2.getCppPointer(coreapp)[0] + return shiboken2.wrapInstance(ptr, CutterApplication) except ImportError: pass