From db3dc34a126b7ef5a5ac60b0c3313d6e4e8d7db1 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Mon, 14 Oct 2019 15:38:00 +0200 Subject: [PATCH] QmlDesigner: Introduce QMLDESIGNER_QUICK3D_MODE We should enable the 3d edit mode only, if there is QtQuick3D import. Additionally there should also be an option in the UI. Change-Id: I2010f2cdd6546c63a2263b8ee02480d4f13177c2 Reviewed-by: Mahmoud Badri Reviewed-by: Miikka Heikkinen --- .../instances/qt5nodeinstanceclientproxy.cpp | 2 ++ .../instances/qt5nodeinstanceserver.cpp | 5 +++-- .../qmlpuppet/qml2puppet/qml2puppetmain.cpp | 20 +++++++++++-------- .../designercore/instances/puppetcreator.cpp | 6 ++++++ 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.cpp index d9fdcda65a7..2ec58bbfbe3 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.cpp @@ -69,6 +69,8 @@ Qt5NodeInstanceClientProxy::Qt5NodeInstanceClientProxy(QObject *parent) : * because we want to be able to show the 3D Edit View * as a normal QQuickView. * The DesignerWindowManager prevents any window from actually being shown. */ + if (!qEnvironmentVariableIsSet("QMLDESIGNER_QUICK3D_MODE")) + DesignerSupport::activateDesignerWindowManager(); setNodeInstanceServer(new Qt5InformationNodeInstanceServer(this)); initializeSocket(); } else if (QCoreApplication::arguments().at(2) == QLatin1String("rendermode")) { diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.cpp index fb8cddb10b8..39653af4129 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.cpp @@ -71,8 +71,9 @@ void Qt5NodeInstanceServer::initializeView() DesignerSupport::createOpenGLContext(m_quickView.data()); - if (QCoreApplication::arguments().at(2) == "editormode") { - /* In 'editormode' we do not use the DesignerWindowManager + if (qEnvironmentVariableIsSet("QMLDESIGNER_QUICK3D_MODE") + && QCoreApplication::arguments().at(2) == "editormode") { + /* In '3d editormode' we do not use the DesignerWindowManager * and since we do not show the QQuickView we have to manually create the OpenGL context */ auto context = new QOpenGLContext(m_quickView); context->setFormat(surfaceFormat); diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppetmain.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppetmain.cpp index 85c8e512d50..10b8487d50b 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppetmain.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppetmain.cpp @@ -133,14 +133,18 @@ int main(int argc, char *argv[]) // subpixel antialiasing and instead use gray. qputenv("QSG_DISTANCEFIELD_ANTIALIASING", "gray"); #ifdef Q_OS_MACOS - // We have to parse the arguments before Q[Gui]Application creation - // Since the Qt arguments are not filtered out, yet we do not know the position of the argument - for (int i = 0; i < argc; ++i) { - const char *arg = argv[i]; - //In previewmode and rendermode we hide the process - if (!qstrcmp(arg, "previewmode") || !qstrcmp(arg, "rendermode")) - qputenv("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM", "true"); - // This keeps qml2puppet from stealing focus + if (!qEnvironmentVariableIsSet("QMLDESIGNER_QUICK3D_MODE")) { + qputenv("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM", "true"); + } else { + // We have to parse the arguments before Q[Gui]Application creation + // Since the Qt arguments are not filtered out, yet we do not know the position of the argument + for (int i = 0; i < argc; ++i) { + const char *arg = argv[i]; + //In previewmode and rendermode we hide the process + if (!qstrcmp(arg, "previewmode") || !qstrcmp(arg, "rendermode")) + qputenv("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM", "true"); + // This keeps qml2puppet from stealing focus + } } #endif diff --git a/src/plugins/qmldesigner/designercore/instances/puppetcreator.cpp b/src/plugins/qmldesigner/designercore/instances/puppetcreator.cpp index 25840c01a35..6cb7a888384 100644 --- a/src/plugins/qmldesigner/designercore/instances/puppetcreator.cpp +++ b/src/plugins/qmldesigner/designercore/instances/puppetcreator.cpp @@ -465,6 +465,12 @@ QProcessEnvironment PuppetCreator::processEnvironment() const QStringList importPaths = m_model->importPaths(); + QmlDesigner::Import import = QmlDesigner::Import::createLibraryImport("QtQuick3D", "1.0"); + + if (m_model->hasImport(import, true, true)) + environment.set("QMLDESIGNER_QUICK3D_MODE", "true"); + + /* For the fallback puppet we have to remove the path to the original qtbase plugins to avoid conflics */ if (m_availablePuppetType == FallbackPuppet) filterOutQtBaseImportPath(&importPaths);