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 <mahmoud.badri@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
Thomas Hartmann
2019-10-14 15:38:00 +02:00
parent 41a7cd15be
commit db3dc34a12
4 changed files with 23 additions and 10 deletions

View File

@@ -69,6 +69,8 @@ Qt5NodeInstanceClientProxy::Qt5NodeInstanceClientProxy(QObject *parent) :
* because we want to be able to show the 3D Edit View * because we want to be able to show the 3D Edit View
* as a normal QQuickView. * as a normal QQuickView.
* The DesignerWindowManager prevents any window from actually being shown. */ * The DesignerWindowManager prevents any window from actually being shown. */
if (!qEnvironmentVariableIsSet("QMLDESIGNER_QUICK3D_MODE"))
DesignerSupport::activateDesignerWindowManager();
setNodeInstanceServer(new Qt5InformationNodeInstanceServer(this)); setNodeInstanceServer(new Qt5InformationNodeInstanceServer(this));
initializeSocket(); initializeSocket();
} else if (QCoreApplication::arguments().at(2) == QLatin1String("rendermode")) { } else if (QCoreApplication::arguments().at(2) == QLatin1String("rendermode")) {

View File

@@ -71,8 +71,9 @@ void Qt5NodeInstanceServer::initializeView()
DesignerSupport::createOpenGLContext(m_quickView.data()); DesignerSupport::createOpenGLContext(m_quickView.data());
if (QCoreApplication::arguments().at(2) == "editormode") { if (qEnvironmentVariableIsSet("QMLDESIGNER_QUICK3D_MODE")
/* In 'editormode' we do not use the DesignerWindowManager && 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 */ * and since we do not show the QQuickView we have to manually create the OpenGL context */
auto context = new QOpenGLContext(m_quickView); auto context = new QOpenGLContext(m_quickView);
context->setFormat(surfaceFormat); context->setFormat(surfaceFormat);

View File

@@ -133,6 +133,9 @@ int main(int argc, char *argv[])
// subpixel antialiasing and instead use gray. // subpixel antialiasing and instead use gray.
qputenv("QSG_DISTANCEFIELD_ANTIALIASING", "gray"); qputenv("QSG_DISTANCEFIELD_ANTIALIASING", "gray");
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
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 // 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 // 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) { for (int i = 0; i < argc; ++i) {
@@ -142,6 +145,7 @@ int main(int argc, char *argv[])
qputenv("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM", "true"); qputenv("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM", "true");
// This keeps qml2puppet from stealing focus // This keeps qml2puppet from stealing focus
} }
}
#endif #endif
//If a style different from Desktop is set we have to use QGuiApplication //If a style different from Desktop is set we have to use QGuiApplication

View File

@@ -465,6 +465,12 @@ QProcessEnvironment PuppetCreator::processEnvironment() const
QStringList importPaths = m_model->importPaths(); 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 */ /* For the fallback puppet we have to remove the path to the original qtbase plugins to avoid conflics */
if (m_availablePuppetType == FallbackPuppet) if (m_availablePuppetType == FallbackPuppet)
filterOutQtBaseImportPath(&importPaths); filterOutQtBaseImportPath(&importPaths);